Compare commits

..

2 Commits

Author SHA1 Message Date
Elian Doran
54c8322960 chore(react/promoted_attributes): multiplicity 2025-11-13 08:17:32 +02:00
Elian Doran
3d0d1fa36e chore(react/promoted_attributes): basic structures 2025-11-12 10:21:28 +02:00
137 changed files with 1589 additions and 2831 deletions

View File

@@ -155,10 +155,6 @@ jobs:
- name: Update build info
run: pnpm run chore:update-build-info
- name: Update nightly version
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: pnpm run chore:ci-update-nightly-version
- name: Run the TypeScript build
run: pnpm run server:build

View File

@@ -57,7 +57,7 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Update nightly version
run: pnpm run chore:ci-update-nightly-version
run: npm run chore:ci-update-nightly-version
- name: Run the build
uses: ./.github/actions/build-electron
with:

2
.nvmrc
View File

@@ -1 +1 @@
24.11.1
24.11.0

View File

@@ -38,15 +38,15 @@
"@playwright/test": "1.56.1",
"@stylistic/eslint-plugin": "5.5.0",
"@types/express": "5.0.5",
"@types/node": "24.10.1",
"@types/yargs": "17.0.35",
"@types/node": "24.10.0",
"@types/yargs": "17.0.34",
"@vitest/coverage-v8": "3.2.4",
"eslint": "9.39.1",
"eslint-plugin-simple-import-sort": "12.1.1",
"esm": "3.2.25",
"jsdoc": "4.0.5",
"lorem-ipsum": "2.0.8",
"rcedit": "5.0.1",
"rcedit": "5.0.0",
"rimraf": "6.1.0",
"tslib": "2.8.1"
},

View File

@@ -9,7 +9,7 @@
"keywords": [],
"author": "Elian Doran <contact@eliandoran.me>",
"license": "AGPL-3.0-only",
"packageManager": "pnpm@10.22.0",
"packageManager": "pnpm@10.21.0",
"devDependencies": {
"@redocly/cli": "2.11.1",
"archiver": "7.0.1",

View File

@@ -25,7 +25,7 @@
"@fullcalendar/timegrid": "6.1.19",
"@maplibre/maplibre-gl-leaflet": "0.1.3",
"@mermaid-js/layout-elk": "0.2.0",
"@mind-elixir/node-menu": "5.0.1",
"@mind-elixir/node-menu": "5.0.0",
"@popperjs/core": "2.11.8",
"@triliumnext/ckeditor5": "workspace:*",
"@triliumnext/codemirror": "workspace:*",
@@ -36,7 +36,7 @@
"autocomplete.js": "0.38.1",
"bootstrap": "5.3.8",
"boxicons": "2.1.4",
"color": "5.0.3",
"color": "5.0.2",
"dayjs": "1.11.19",
"dayjs-plugin-utc": "0.1.2",
"debounce": "3.0.0",
@@ -55,11 +55,11 @@
"mark.js": "8.11.1",
"marked": "16.4.2",
"mermaid": "11.12.1",
"mind-elixir": "5.3.6",
"mind-elixir": "5.3.5",
"normalize.css": "8.0.1",
"panzoom": "9.4.3",
"preact": "10.27.2",
"react-i18next": "16.3.3",
"react-i18next": "16.2.4",
"reveal.js": "5.2.1",
"svg-pan-zoom": "3.6.2",
"tabulator-tables": "6.3.1",

View File

@@ -6,7 +6,6 @@ import type { Froca } from "../services/froca-interface.js";
import type FAttachment from "./fattachment.js";
import type { default as FAttribute, AttributeType } from "./fattribute.js";
import utils from "../services/utils.js";
import search from "../services/search.js";
const LABEL = "label";
const RELATION = "relation";
@@ -256,23 +255,6 @@ export default class FNote {
return this.children;
}
async getChildNoteIdsWithArchiveFiltering(includeArchived = false) {
const isHiddenNote = this.noteId.startsWith("_");
const isSearchNote = this.type === "search";
if (!includeArchived && !isHiddenNote && !isSearchNote) {
const unorderedIds = new Set(await search.searchForNoteIds(`note.parents.noteId="${this.noteId}" #!archived`));
const results: string[] = [];
for (const id of this.children) {
if (unorderedIds.has(id)) {
results.push(id);
}
}
return results;
} else {
return this.children;
}
}
async getSubtreeNoteIds(includeArchived = false) {
let noteIds: (string | string[])[] = [];
for (const child of await this.getChildNotes()) {
@@ -806,16 +788,6 @@ export default class FNote {
return this.getAttributeValue(LABEL, name);
}
getLabelOrRelation(nameWithPrefix: string) {
if (nameWithPrefix.startsWith("#")) {
return this.getLabelValue(nameWithPrefix.substring(1));
} else if (nameWithPrefix.startsWith("~")) {
return this.getRelationValue(nameWithPrefix.substring(1));
} else {
return this.getLabelValue(nameWithPrefix);
}
}
/**
* @param name - relation name
* @returns relation value if relation exists, null otherwise
@@ -867,7 +839,8 @@ export default class FNote {
return [];
}
const promotedAttrs = this.getAttributeDefinitions()
const promotedAttrs = this.getAttributes()
.filter((attr) => attr.isDefinition())
.filter((attr) => {
const def = attr.getDefinition();
@@ -887,11 +860,6 @@ export default class FNote {
return promotedAttrs;
}
getAttributeDefinitions() {
return this.getAttributes()
.filter((attr) => attr.isDefinition());
}
hasAncestor(ancestorNoteId: string, followTemplates = false, visitedNoteIds: Set<string> | null = null) {
if (this.noteId === ancestorNoteId) {
return true;

View File

@@ -3,7 +3,7 @@ import { DESKTOP_FLOATING_BUTTONS } from "../widgets/FloatingButtonsDefinitions.
import ApiLog from "../widgets/api_log.jsx";
import ClosePaneButton from "../widgets/buttons/close_pane_button.js";
import CloseZenModeButton from "../widgets/close_zen_button.jsx";
import ContentHeader from "../widgets/containers/content_header.js";
import ContentHeader from "../widgets/containers/content-header.js";
import CreatePaneButton from "../widgets/buttons/create_pane_button.js";
import FindWidget from "../widgets/find.js";
import FlexContainer from "../widgets/containers/flex_container.js";
@@ -21,7 +21,6 @@ import NoteTreeWidget from "../widgets/note_tree.js";
import NoteWrapperWidget from "../widgets/note_wrapper.js";
import options from "../services/options.js";
import PasswordNoteSetDialog from "../widgets/dialogs/password_not_set.js";
import PromotedAttributesWidget from "../widgets/promoted_attributes.js";
import QuickSearchWidget from "../widgets/quick_search.js";
import ReadOnlyNoteInfoBar from "../widgets/ReadOnlyNoteInfoBar.jsx";
import Ribbon from "../widgets/ribbon/Ribbon.jsx";
@@ -44,6 +43,7 @@ import UploadAttachmentsDialog from "../widgets/dialogs/upload_attachments.js";
import utils from "../services/utils.js";
import WatchedFileUpdateStatusWidget from "../widgets/watched_file_update_status.js";
import NoteDetail from "../widgets/NoteDetail.jsx";
import PromotedAttributes from "../widgets/PromotedAttributes.jsx";
export default class DesktopLayout {
@@ -140,7 +140,7 @@ export default class DesktopLayout {
.child(<ReadOnlyNoteInfoBar />)
.child(<SharedInfo />)
)
.child(new PromotedAttributesWidget())
.child(<PromotedAttributes />)
.child(<SqlTableSchemas />)
.child(<NoteDetail />)
.child(<NoteList media="screen" />)

View File

@@ -10,7 +10,7 @@ import LauncherContainer from "../widgets/containers/launcher_container.js";
import MobileDetailMenu from "../widgets/mobile_widgets/mobile_detail_menu.js";
import NoteList from "../widgets/collections/NoteList.jsx";
import NoteTitleWidget from "../widgets/note_title.js";
import ContentHeader from "../widgets/containers/content_header.js";
import ContentHeader from "../widgets/containers/content-header.js";
import NoteTreeWidget from "../widgets/note_tree.js";
import NoteWrapperWidget from "../widgets/note_wrapper.js";
import PromotedAttributesWidget from "../widgets/promoted_attributes.js";

View File

@@ -2,7 +2,7 @@ import { KeyboardActionNames } from "@triliumnext/commons";
import keyboardActionService, { getActionSync } from "../services/keyboard_actions.js";
import note_tooltip from "../services/note_tooltip.js";
import utils from "../services/utils.js";
import { h, JSX, render } from "preact";
import { should } from "vitest";
export interface ContextMenuOptions<T> {
x: number;
@@ -15,11 +15,6 @@ export interface ContextMenuOptions<T> {
onHide?: () => void;
}
export interface CustomMenuItem {
kind: "custom",
componentFn: () => JSX.Element;
}
export interface MenuSeparatorItem {
kind: "separator";
}
@@ -56,7 +51,7 @@ export interface MenuCommandItem<T> {
columns?: number;
}
export type MenuItem<T> = MenuCommandItem<T> | CustomMenuItem | MenuSeparatorItem | MenuHeader;
export type MenuItem<T> = MenuCommandItem<T> | MenuSeparatorItem | MenuHeader;
export type MenuHandler<T> = (item: MenuCommandItem<T>, e: JQuery.MouseDownEvent<HTMLElement, undefined, HTMLElement, HTMLElement>) => void;
export type ContextMenuEvent = PointerEvent | MouseEvent | JQuery.ContextMenuEvent;
@@ -207,14 +202,118 @@ class ContextMenu {
$group.append($("<h6>").addClass("dropdown-header").text(item.title));
shouldResetGroup = true;
} else {
if ("kind" in item && item.kind === "custom") {
// Custom menu item
$group.append(this.createCustomMenuItem(item));
} else {
// Standard menu item
$group.append(this.createMenuItem(item));
const $icon = $("<span>");
if ("uiIcon" in item || "checked" in item) {
const icon = (item.checked ? "bx bx-check" : item.uiIcon);
if (icon) {
$icon.addClass(icon);
} else {
$icon.append("&nbsp;");
}
}
const $link = $("<span>")
.append($icon)
.append(" &nbsp; ") // some space between icon and text
.append(item.title);
if ("badges" in item && item.badges) {
for (let badge of item.badges) {
const badgeElement = $(`<span class="badge">`).text(badge.title);
if (badge.className) {
badgeElement.addClass(badge.className);
}
$link.append(badgeElement);
}
}
if ("keyboardShortcut" in item && item.keyboardShortcut) {
const shortcuts = getActionSync(item.keyboardShortcut).effectiveShortcuts;
if (shortcuts) {
const allShortcuts: string[] = [];
for (const effectiveShortcut of shortcuts) {
allShortcuts.push(effectiveShortcut.split("+")
.map(key => `<kbd>${key}</kbd>`)
.join("+"));
}
if (allShortcuts.length) {
const container = $("<span>").addClass("keyboard-shortcut");
container.append($(allShortcuts.join(",")));
$link.append(container);
}
}
} else if ("shortcut" in item && item.shortcut) {
$link.append($("<kbd>").text(item.shortcut));
}
const $item = $("<li>")
.addClass("dropdown-item")
.append($link)
.on("contextmenu", (e) => false)
// important to use mousedown instead of click since the former does not change focus
// (especially important for focused text for spell check)
.on("mousedown", (e) => {
e.stopPropagation();
if (e.which !== 1) {
// only left click triggers menu items
return false;
}
if (this.isMobile && "items" in item && item.items) {
const $item = $(e.target).closest(".dropdown-item");
$item.toggleClass("submenu-open");
$item.find("ul.dropdown-menu").toggleClass("show");
return false;
}
if ("handler" in item && item.handler) {
item.handler(item, e);
}
this.options?.selectMenuItemHandler(item, e);
// it's important to stop the propagation especially for sub-menus, otherwise the event
// might be handled again by top-level menu
return false;
});
$item.on("mouseup", (e) => {
// Prevent submenu from failing to expand on mobile
if (!this.isMobile || !("items" in item && item.items)) {
e.stopPropagation();
// Hide the content menu on mouse up to prevent the mouse event from propagating to the elements below.
this.hide();
return false;
}
});
if ("enabled" in item && item.enabled !== undefined && !item.enabled) {
$item.addClass("disabled");
}
if ("items" in item && item.items) {
$item.addClass("dropdown-submenu");
$link.addClass("dropdown-toggle");
const $subMenu = $("<ul>").addClass("dropdown-menu");
const hasColumns = !!item.columns && item.columns > 1;
if (!this.isMobile && hasColumns) {
$subMenu.css("column-count", item.columns!);
}
this.addItems($subMenu, item.items, hasColumns);
$item.append($subMenu);
}
$group.append($item);
// After adding a menu item, if the previous item was a separator or header,
// reset the group so that the next item will be appended directly to the parent.
if (shouldResetGroup) {
@@ -225,126 +324,6 @@ class ContextMenu {
}
}
private createCustomMenuItem(item: CustomMenuItem) {
const element = document.createElement("li");
element.classList.add("dropdown-custom-item");
render(h(item.componentFn, {}), element);
return element;
}
private createMenuItem(item: MenuCommandItem<any>) {
const $icon = $("<span>");
if ("uiIcon" in item || "checked" in item) {
const icon = (item.checked ? "bx bx-check" : item.uiIcon);
if (icon) {
$icon.addClass(icon);
} else {
$icon.append("&nbsp;");
}
}
const $link = $("<span>")
.append($icon)
.append(" &nbsp; ") // some space between icon and text
.append(item.title);
if ("badges" in item && item.badges) {
for (let badge of item.badges) {
const badgeElement = $(`<span class="badge">`).text(badge.title);
if (badge.className) {
badgeElement.addClass(badge.className);
}
$link.append(badgeElement);
}
}
if ("keyboardShortcut" in item && item.keyboardShortcut) {
const shortcuts = getActionSync(item.keyboardShortcut).effectiveShortcuts;
if (shortcuts) {
const allShortcuts: string[] = [];
for (const effectiveShortcut of shortcuts) {
allShortcuts.push(effectiveShortcut.split("+")
.map(key => `<kbd>${key}</kbd>`)
.join("+"));
}
if (allShortcuts.length) {
const container = $("<span>").addClass("keyboard-shortcut");
container.append($(allShortcuts.join(",")));
$link.append(container);
}
}
} else if ("shortcut" in item && item.shortcut) {
$link.append($("<kbd>").text(item.shortcut));
}
const $item = $("<li>")
.addClass("dropdown-item")
.append($link)
.on("contextmenu", (e) => false)
// important to use mousedown instead of click since the former does not change focus
// (especially important for focused text for spell check)
.on("mousedown", (e) => {
e.stopPropagation();
if (e.which !== 1) {
// only left click triggers menu items
return false;
}
if (this.isMobile && "items" in item && item.items) {
const $item = $(e.target).closest(".dropdown-item");
$item.toggleClass("submenu-open");
$item.find("ul.dropdown-menu").toggleClass("show");
return false;
}
if ("handler" in item && item.handler) {
item.handler(item, e);
}
this.options?.selectMenuItemHandler(item, e);
// it's important to stop the propagation especially for sub-menus, otherwise the event
// might be handled again by top-level menu
return false;
});
$item.on("mouseup", (e) => {
// Prevent submenu from failing to expand on mobile
if (!this.isMobile || !("items" in item && item.items)) {
e.stopPropagation();
// Hide the content menu on mouse up to prevent the mouse event from propagating to the elements below.
this.hide();
return false;
}
});
if ("enabled" in item && item.enabled !== undefined && !item.enabled) {
$item.addClass("disabled");
}
if ("items" in item && item.items) {
$item.addClass("dropdown-submenu");
$link.addClass("dropdown-toggle");
const $subMenu = $("<ul>").addClass("dropdown-menu");
const hasColumns = !!item.columns && item.columns > 1;
if (!this.isMobile && hasColumns) {
$subMenu.css("column-count", item.columns!);
}
this.addItems($subMenu, item.items, hasColumns);
$item.append($subMenu);
}
return $item;
}
async hide() {
this.options?.onHide?.();
this.$widget.removeClass("show");

View File

@@ -1,9 +0,0 @@
import FNote from "../../entities/fnote"
export interface ColorPickerMenuItemProps {
note: FNote | null;
}
export default function ColorPickerMenuItem(props: ColorPickerMenuItemProps) {
return <span>Color Picker</span>
}

View File

@@ -1,4 +1,3 @@
import ColorPickerMenuItem from "./custom-items/ColorPickerMenuItem.jsx";
import treeService from "../services/tree.js";
import froca from "../services/froca.js";
import clipboard from "../services/clipboard.js";
@@ -256,12 +255,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
keyboardShortcut: "searchInSubtree",
uiIcon: "bx bx-search",
enabled: notSearch && noSelectedNotes
},
{
kind: "custom",
componentFn: () => ColorPickerMenuItem({note})
},
}
];
return items.filter((row) => row !== null) as MenuItem<TreeCommandNames>[];
}

View File

@@ -90,8 +90,7 @@ const HIDDEN_ATTRIBUTES = [
"viewType",
"geolocation",
"docName",
"webViewSrc",
"archived"
"webViewSrc"
];
async function renderNormalAttributes(note: FNote) {

View File

@@ -22,15 +22,6 @@ export async function setLabel(noteId: string, name: string, value: string = "",
});
}
export async function setRelation(noteId: string, name: string, value: string = "", isInheritable = false) {
await server.put(`notes/${noteId}/set-attribute`, {
type: "relation",
name: name,
value: value,
isInheritable
});
}
async function removeAttributeById(noteId: string, attributeId: string) {
await server.remove(`notes/${noteId}/attributes/${attributeId}`);
}
@@ -60,23 +51,6 @@ function removeOwnedLabelByName(note: FNote, labelName: string) {
return false;
}
/**
* Removes a relation identified by its name from the given note, if it exists. Note that the relation must be owned, i.e.
* it will not remove inherited attributes.
*
* @param note the note from which to remove the relation.
* @param relationName the name of the relation to remove.
* @returns `true` if an attribute was identified and removed, `false` otherwise.
*/
function removeOwnedRelationByName(note: FNote, relationName: string) {
const relation = note.getOwnedRelation(relationName);
if (relation) {
removeAttributeById(note.noteId, relation.attributeId);
return true;
}
return false;
}
/**
* Sets the attribute of the given note to the provided value if its truthy, or removes the attribute if the value is falsy.
* For an attribute with an empty value, pass an empty string instead.
@@ -142,10 +116,8 @@ function isAffecting(attrRow: AttributeRow, affectedNote: FNote | null | undefin
export default {
addLabel,
setLabel,
setRelation,
setAttribute,
removeAttributeById,
removeOwnedLabelByName,
removeOwnedRelationByName,
isAffecting
};

View File

@@ -76,11 +76,6 @@ function getHue(color: ColorInstance) {
}
}
export function getReadableTextColor(bgColor: string) {
const colorInstance = Color(bgColor);
return colorInstance.isLight() ? "#000" : "#fff";
}
export default {
createClassForColor
};

View File

@@ -1,5 +1,4 @@
import type FNote from "../entities/fnote.js";
import { applyReferenceLinks } from "../widgets/type_widgets/text/read_only_helper.js";
import { getCurrentLanguage } from "./i18n.js";
import { formatCodeBlocks } from "./syntax_highlight.js";
@@ -11,18 +10,18 @@ export default function renderDoc(note: FNote) {
if (docName) {
// find doc based on language
const url = getUrl(docName, getCurrentLanguage());
$content.load(url, async (response, status) => {
$content.load(url, (response, status) => {
// fallback to english doc if no translation available
if (status === "error") {
const fallbackUrl = getUrl(docName, "en");
$content.load(fallbackUrl, async () => {
await processContent(fallbackUrl, $content)
$content.load(fallbackUrl, () => {
processContent(fallbackUrl, $content)
resolve($content);
});
return;
}
await processContent(url, $content);
processContent(url, $content);
resolve($content);
});
} else {
@@ -33,7 +32,7 @@ export default function renderDoc(note: FNote) {
});
}
async function processContent(url: string, $content: JQuery<HTMLElement>) {
function processContent(url: string, $content: JQuery<HTMLElement>) {
const dir = url.substring(0, url.lastIndexOf("/"));
// Images are relative to the docnote but that will not work when rendered in the application since the path breaks.
@@ -43,9 +42,6 @@ async function processContent(url: string, $content: JQuery<HTMLElement>) {
});
formatCodeBlocks($content);
// Apply reference links.
await applyReferenceLinks($content[0]);
}
function getUrl(docNameValue: string, language: string) {

View File

@@ -29,8 +29,6 @@ async function getActionsForScope(scope: string) {
}
async function setupActionsForElement(scope: string, $el: JQuery<HTMLElement>, component: Component) {
if (!$el[0]) return [];
const actions = await getActionsForScope(scope);
const bindings: ShortcutBinding[] = [];

View File

@@ -150,16 +150,11 @@ async function createLink(notePath: string | undefined, options: CreateLinkOptio
$container.append($noteLink);
if (showNotePath) {
let pathSegments: string[];
if (notePath == "root") {
pathSegments = ["⌂"];
} else {
const resolvedPathSegments = (await treeService.resolveNotePathToSegments(notePath)) || [];
resolvedPathSegments.pop(); // Remove last element
const resolvedPathSegments = (await treeService.resolveNotePathToSegments(notePath)) || [];
resolvedPathSegments.pop(); // Remove last element
const resolvedPath = resolvedPathSegments.join("/");
pathSegments = await treeService.getNotePathTitleComponents(resolvedPath);
}
const resolvedPath = resolvedPathSegments.join("/");
const pathSegments = await treeService.getNotePathTitleComponents(resolvedPath);
if (pathSegments) {
if (pathSegments.length) {
@@ -307,8 +302,7 @@ export function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDo
// Right click is handled separately.
const isMiddleClick = evt && "which" in evt && evt.which === 2;
const targetIsBlank = ($link?.attr("target") === "_blank");
const isDoubleClick = isLeftClick && evt?.type === "dblclick";
const openInNewTab = (isLeftClick && ctrlKey) || isDoubleClick || isMiddleClick || targetIsBlank;
const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick || targetIsBlank;
const activate = (isLeftClick && ctrlKey && shiftKey) || (isMiddleClick && shiftKey);
const openInNewWindow = isLeftClick && evt?.shiftKey && !ctrlKey;
@@ -329,18 +323,16 @@ export function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDo
const withinEditLink = $link?.hasClass("ck-link-actions__preview");
const outsideOfCKEditor = !$link || $link.closest("[contenteditable]").length === 0;
if (openInNewTab || openInNewWindow || (isLeftClick && (withinEditLink || outsideOfCKEditor))) {
if (openInNewTab || (withinEditLink && (isLeftClick || isMiddleClick)) || (outsideOfCKEditor && (isLeftClick || isMiddleClick))) {
if (hrefLink.toLowerCase().startsWith("http") || hrefLink.startsWith("api/")) {
window.open(hrefLink, "_blank");
} else if ((hrefLink.toLowerCase().startsWith("file:") || hrefLink.toLowerCase().startsWith("geo:")) && utils.isElectron()) {
const electron = utils.dynamicRequire("electron");
electron.shell.openPath(hrefLink);
} else {
// Enable protocols supported by CKEditor 5 to be clickable.
if (ALLOWED_PROTOCOLS.some((protocol) => hrefLink.toLowerCase().startsWith(protocol + ":"))) {
if ( utils.isElectron()) {
const electron = utils.dynamicRequire("electron");
electron.shell.openExternal(hrefLink);
} else {
window.open(hrefLink, "_blank");
}
window.open(hrefLink, "_blank");
}
}
}
@@ -476,9 +468,18 @@ $(document).on("auxclick", "a", goToLink); // to handle the middle button
// TODO: Check why the event is not supported.
//@ts-ignore
$(document).on("contextmenu", "a", linkContextMenu);
// TODO: Check why the event is not supported.
//@ts-ignore
$(document).on("dblclick", "a", goToLink);
$(document).on("dblclick", "a", (e) => {
e.preventDefault();
e.stopPropagation();
const $link = $(e.target).closest("a");
const address = $link.attr("href");
if (address && address.startsWith("http")) {
window.open(address, "_blank");
}
});
$(document).on("mousedown", "a", (e) => {
if (e.which === 2) {

View File

@@ -1,21 +1,11 @@
import type { AttachmentRow, EtapiTokenRow, NoteType, OptionNames } from "@triliumnext/commons";
import type { AttachmentRow, EtapiTokenRow, OptionNames } from "@triliumnext/commons";
import type { AttributeType } from "../entities/fattribute.js";
import type { EntityChange } from "../server_types.js";
// TODO: Deduplicate with server.
interface NoteRow {
blobId: string;
dateCreated: string;
dateModified: string;
isDeleted?: boolean;
isProtected?: boolean;
mime: string;
noteId: string;
title: string;
type: NoteType;
utcDateCreated: string;
utcDateModified: string;
}
// TODO: Deduplicate with BranchRow from `rows.ts`/

View File

@@ -77,11 +77,11 @@ function closePersistent(id: string) {
$(`#toast-${id}`).remove();
}
function showMessage(message: string, delay = 2000, icon = "check") {
function showMessage(message: string, delay = 2000) {
console.debug(utils.now(), "message:", message);
toast({
icon,
icon: "check",
message: message,
autohide: true,
delay

View File

@@ -16,10 +16,6 @@
background-color: var(--root-background);
}
body.mobile #root-widget {
background-color: var(--main-background-color);
}
body {
--native-titlebar-darwin-x-offset: 10;
--native-titlebar-darwin-y-offset: 12 !important;

View File

@@ -690,8 +690,7 @@
"convert_into_attachment_failed": "笔记 '{{title}}' 转换失败。",
"convert_into_attachment_successful": "笔记 '{{title}}' 已成功转换为附件。",
"convert_into_attachment_prompt": "确定要将笔记 '{{title}}' 转换为父笔记的附件吗?",
"print_pdf": "导出为 PDF...",
"open_note_on_server": "在服务器上打开笔记"
"print_pdf": "导出为 PDF..."
},
"onclick_button": {
"no_click_handler": "按钮组件'{{componentId}}'没有定义点击处理程序"
@@ -1111,8 +1110,7 @@
"title": "内容宽度",
"default_description": "Trilium默认会限制内容的最大宽度以提高在宽屏中全屏时的可读性。",
"max_width_label": "内容最大宽度(像素)",
"max_width_unit": "像素",
"centerContent": "保持内容居中"
"max_width_unit": "像素"
},
"native_title_bar": {
"title": "原生标题栏(需要重新启动应用)",
@@ -2084,11 +2082,5 @@
},
"calendar_view": {
"delete_note": "删除笔记..."
},
"read-only-info": {
"read-only-note": "当前正在查看一个只读笔记。",
"auto-read-only-note": "这条笔记以只读模式显示便于快速加载。",
"auto-read-only-learn-more": "了解更多",
"edit-note": "编辑笔记"
}
}

View File

@@ -2035,8 +2035,7 @@
"add-column": "Add Column",
"add-column-placeholder": "Enter column name...",
"edit-note-title": "Click to edit note title",
"edit-column-title": "Click to edit column title",
"column-already-exists": "This column already exists on the board."
"edit-column-title": "Click to edit column title"
},
"presentation_view": {
"edit-slide": "Edit this slide",

View File

@@ -41,7 +41,7 @@
"prefix": "接頭辞: ",
"branch_prefix_saved": "ブランチの接頭辞が保存されました。",
"edit_branch_prefix_multiple": "{{count}} ブランチのブランチ接頭辞を編集",
"branch_prefix_saved_multiple": "{{count}} ブランチのブランチ接頭辞が保存されました。",
"branch_prefix_saved_multiple": "{{count}} 個のブランチのブランチ接頭辞が保存されました。",
"affected_branches": "影響を受けるブランチ {{count}}:"
},
"global_menu": {
@@ -456,8 +456,7 @@
"convert_into_attachment_failed": "ノート '{{title}}' の変換に失敗しました。",
"convert_into_attachment_successful": "ノート '{{title}}' は添付ファイルに変換されました。",
"convert_into_attachment_prompt": "本当にノート '{{title}}' を親ノートの添付ファイルに変換しますか?",
"note_attachments": "ノートの添付ファイル",
"open_note_on_server": "サーバー上のノートを開く"
"note_attachments": "ノートの添付ファイル"
},
"command_palette": {
"export_note_title": "ノートをエクスポート",

View File

@@ -302,10 +302,7 @@
"edit_branch_prefix": "Editează prefixul ramurii",
"help_on_tree_prefix": "Informații despre prefixe de ierarhie",
"prefix": "Prefix: ",
"save": "Salvează",
"edit_branch_prefix_multiple": "Editează prefixul pentru {{count}} ramuri",
"branch_prefix_saved_multiple": "Prefixul a fost modificat pentru {{count}} ramuri.",
"affected_branches": "Ramuri afectate ({{count}}):"
"save": "Salvează"
},
"bulk_actions": {
"affected_notes": "Notițe afectate",
@@ -540,8 +537,7 @@
"opml_version_1": "OPML v1.0 - text simplu",
"opml_version_2": "OPML v2.0 - permite și HTML",
"format_html": "HTML - recomandat deoarece păstrează toata formatarea",
"format_pdf": "PDF - cu scopul de printare sau partajare.",
"share-format": "HTML pentru publicare web - folosește aceeași temă pentru notițele partajate, dar se pot publica într-un website static."
"format_pdf": "PDF - cu scopul de printare sau partajare."
},
"fast_search": {
"description": "Căutarea rapidă dezactivează căutarea la nivel de conținut al notițelor cu scopul de a îmbunătăți performanța de căutare pentru baze de date mari.",
@@ -757,8 +753,7 @@
"placeholder": "Introduceți etichetele HTML, câte unul pe linie",
"reset_button": "Resetează la lista implicită",
"title": "Etichete HTML la importare"
},
"importZipRecommendation": "Când importați un fișier ZIP, ierarhia notițelor va reflecta structura subdirectoarelor din arhivă."
}
},
"include_archived_notes": {
"include_archived_notes": "Include notițele arhivate"
@@ -804,8 +799,7 @@
"default_description": "În mod implicit Trilium limitează lățimea conținutului pentru a îmbunătăți lizibilitatea pentru ferestrele maximizate pe ecrane late.",
"max_width_label": "Lungimea maximă a conținutului",
"max_width_unit": "pixeli",
"title": "Lățime conținut",
"centerContent": "Centrează conținutul"
"title": "Lățime conținut"
},
"mobile_detail_menu": {
"delete_this_note": "Șterge această notiță",
@@ -862,8 +856,7 @@
"convert_into_attachment_failed": "Nu s-a putut converti notița „{{title}}”.",
"convert_into_attachment_successful": "Notița „{{title}}” a fost convertită în atașament.",
"convert_into_attachment_prompt": "Doriți convertirea notiței „{{title}}” într-un atașament al notiței părinte?",
"print_pdf": "Exportare ca PDF...",
"open_note_on_server": "Deschide notița pe server"
"print_pdf": "Exportare ca PDF..."
},
"note_erasure_timeout": {
"deleted_notes_erased": "Notițele șterse au fost eliminate permanent.",
@@ -1253,11 +1246,11 @@
"timeout_unit": "milisecunde"
},
"table_of_contents": {
"description": "Cuprinsul va apărea în notițele de tip text atunci când notița are un număr de titluri mai mare decât cel definit. Acest număr se poate personaliza:",
"description": "Tabela de conținut va apărea în notițele de tip text atunci când notița are un număr de titluri mai mare decât cel definit. Acest număr se poate personaliza:",
"unit": "titluri",
"disable_info": "De asemenea se poate dezactiva cuprinsul setând o valoare foarte mare.",
"shortcut_info": "Se poate configura și o scurtatură pentru a comuta rapid vizibilitatea panoului din dreapta (inclusiv cuprinsul) în Opțiuni -> Scurtături (denumirea „toggleRightPane”).",
"title": "Cuprins"
"disable_info": "De asemenea se poate dezactiva tabela de conținut setând o valoare foarte mare.",
"shortcut_info": "Se poate configura și o scurtatură pentru a comuta rapid vizibilitatea panoului din dreapta (inclusiv tabela de conținut) în Opțiuni -> Scurtături (denumirea „toggleRightPane”).",
"title": "Tabelă de conținut"
},
"text_auto_read_only_size": {
"description": "Marchează pragul în care o notiță de o anumită dimensiune va fi afișată în mod de citire (pentru motive de performanță).",
@@ -1510,9 +1503,7 @@
"window-on-top": "Menține fereastra mereu vizibilă"
},
"note_detail": {
"could_not_find_typewidget": "Nu s-a putut găsi widget-ul corespunzător tipului „{{type}}”",
"printing": "Imprimare în curs...",
"printing_pdf": "Exportare ca PDF în curs..."
"could_not_find_typewidget": "Nu s-a putut găsi widget-ul corespunzător tipului „{{type}}”"
},
"note_title": {
"placeholder": "introduceți titlul notiței aici..."
@@ -2023,8 +2014,7 @@
"new-item-placeholder": "Introduceți titlul notiței...",
"add-column-placeholder": "Introduceți denumirea coloanei...",
"edit-note-title": "Clic pentru a edita titlul notiței",
"edit-column-title": "Clic pentru a edita titlul coloanei",
"column-already-exists": "Această coloană deja există."
"edit-column-title": "Clic pentru a edita titlul coloanei"
},
"command_palette": {
"tree-action-name": "Listă de notițe: {{name}}",
@@ -2086,14 +2076,5 @@
"edit-slide": "Editați acest slide",
"start-presentation": "Începeți prezentarea",
"slide-overview": "Afișați o imagine de ansamblu a slide-urilor"
},
"read-only-info": {
"read-only-note": "Vizualizați o notiță în modul doar în citire.",
"auto-read-only-note": "Această notiță este afișată în modul doar în citire din motive de performanță.",
"auto-read-only-learn-more": "Mai multe detalii",
"edit-note": "Editează notița"
},
"calendar_view": {
"delete_note": "Șterge notița..."
}
}

View File

@@ -687,8 +687,7 @@
"convert_into_attachment_failed": "筆記 '{{title}}' 轉換失敗。",
"convert_into_attachment_successful": "筆記 '{{title}}' 已成功轉換為附件。",
"convert_into_attachment_prompt": "確定要將筆記 '{{title}}' 轉換為父級筆記的附件嗎?",
"print_pdf": "匯出為 PDF…",
"open_note_on_server": "在伺服器上開啟筆記"
"print_pdf": "匯出為 PDF…"
},
"onclick_button": {
"no_click_handler": "按鈕元件'{{componentId}}'沒有定義點擊時的處理方式"
@@ -1108,8 +1107,7 @@
"title": "內容寬度",
"default_description": "Trilium 預設會限制內容的最大寬度以提高在寬螢幕中全螢幕時的可讀性。",
"max_width_label": "內容最大寬度(像素)",
"max_width_unit": "像素",
"centerContent": "將內容置中"
"max_width_unit": "像素"
},
"native_title_bar": {
"title": "原生標題列(需要重新啟動程式)",
@@ -2084,11 +2082,5 @@
},
"calendar_view": {
"delete_note": "刪除筆記…"
},
"read-only-info": {
"read-only-note": "目前正在檢視唯讀筆記。",
"auto-read-only-note": "此筆記以唯讀模式顯示以加快載入速度。",
"auto-read-only-learn-more": "了解更多",
"edit-note": "編輯筆記"
}
}

View File

@@ -0,0 +1,91 @@
body.mobile .promoted-attributes-widget {
/* https://github.com/zadam/trilium/issues/4468 */
flex-shrink: 0.4;
overflow: auto;
}
.component.promoted-attributes-widget {
contain: none;
}
.promoted-attributes-container {
margin: 0 1.5em;
overflow: auto;
max-height: 400px;
flex-wrap: wrap;
display: table;
}
.promoted-attribute-cell {
display: flex;
align-items: center;
margin: 10px;
display: table-row;
}
.promoted-attribute-cell > label {
user-select: none;
font-weight: bold;
vertical-align: middle;
}
.promoted-attribute-cell > * {
display: table-cell;
padding: 1px 0;
}
.promoted-attribute-cell div.input-group {
margin-inline-start: 10px;
display: flex;
min-height: 40px;
}
.promoted-attribute-cell strong {
word-break:keep-all;
white-space: nowrap;
}
.promoted-attribute-cell input[type="checkbox"] {
width: 22px !important;
flex-grow: 0;
width: unset;
}
/* Restore default apperance */
.promoted-attribute-cell input[type="number"],
.promoted-attribute-cell input[type="checkbox"] {
appearance: auto;
}
.promoted-attribute-cell input[type="color"] {
width: 24px;
height: 24px;
margin-top: 2px;
appearance: none;
padding: 0;
border: 0;
outline: none;
border-radius: 25% !important;
}
.promoted-attribute-cell input[type="color"]::-webkit-color-swatch-wrapper {
padding: 0;
}
.promoted-attribute-cell input[type="color"]::-webkit-color-swatch {
border: none;
border-radius: 25%;
}
.promoted-attribute-label-color input[type="hidden"][value=""] + input[type="color"] {
position: relative;
opacity: 0.5;
}
.promoted-attribute-label-color input[type="hidden"][value=""] + input[type="color"]:after {
content: "";
position: absolute;
top: 10px;
inset-inline-start: 0px;
inset-inline-end: 0;
height: 2px;
background: rgba(0, 0, 0, 0.5);
transform: rotate(45deg);
pointer-events: none;
}

View File

@@ -0,0 +1,120 @@
import { useEffect, useState } from "preact/hooks";
import "./PromotedAttributes.css";
import { useNoteContext, useNoteLabel } from "./react/hooks";
import { Attribute } from "../services/attribute_parser";
import { ComponentChild } from "preact";
import FAttribute from "../entities/fattribute";
import { t } from "../services/i18n";
import ActionButton from "./react/ActionButton";
export default function PromotedAttributes() {
const { note } = useNoteContext();
const [ promotedAttributes, setPromotedAttributes ] = useState<ComponentChild[]>();
const [ viewType ] = useNoteLabel(note, "viewType");
useEffect(() => {
if (!note) {
setPromotedAttributes([]);
return;
}
const promotedDefAttrs = note.getPromotedDefinitionAttributes();
const ownedAttributes = note.getOwnedAttributes();
// attrs are not resorted if position changes after the initial load
// promoted attrs are sorted primarily by order of definitions, but with multi-valued promoted attrs
// the order of attributes is important as well
ownedAttributes.sort((a, b) => a.position - b.position);
let promotedAttributes: ComponentChild[] = [];
for (const definitionAttr of promotedDefAttrs) {
const valueType = definitionAttr.name.startsWith("label:") ? "label" : "relation";
const valueName = definitionAttr.name.substr(valueType.length + 1);
let valueAttrs = ownedAttributes.filter((el) => el.name === valueName && el.type === valueType) as Attribute[];
if (valueAttrs.length === 0) {
valueAttrs.push({
attributeId: "",
type: valueType,
name: valueName,
value: ""
});
}
if (definitionAttr.getDefinition().multiplicity === "single") {
valueAttrs = valueAttrs.slice(0, 1);
}
for (const valueAttr of valueAttrs) {
promotedAttributes.push(<PromotedAttributeCell
noteId={note.noteId}
definitionAttr={definitionAttr}
valueAttr={valueAttr} valueName={valueName} />)
}
}
setPromotedAttributes(promotedAttributes);
console.log("Got ", promotedAttributes);
}, [ note ]);
return (
<div className="promoted-attributes-widget">
{viewType !== "table" && (
<div className="promoted-attributes-container">
{promotedAttributes}
</div>
)}
</div>
);
}
function PromotedAttributeCell({ noteId, definitionAttr, valueAttr, valueName }: {
noteId: string;
definitionAttr: FAttribute;
valueAttr: Attribute;
valueName: string;
}) {
const definition = definitionAttr.getDefinition();
const id = `value-${valueAttr.attributeId}`;
return (
<div className="promoted-attribute-cell">
<label
for={id}
>{definition.promotedAlias ?? valueName}</label>
<div className="input-group">
<input
className="form-control promoted-attribute-input"
tabindex={200 + definitionAttr.position}
id={id}
// if not owned, we'll force creation of a new attribute instead of updating the inherited one
data-attribute-id={valueAttr.noteId === noteId ? valueAttr.attributeId ?? "" : ""}
data-attribute-type={valueAttr.type}
data-attribute-name={valueAttr.name}
value={valueAttr.value}
placeholder={t("promoted_attributes.unset-field-placeholder")}
/>
</div>
<div />
{definition.multiplicity === "multi" && (
<td className="multiplicity">
<ActionButton
icon="bx bx-plus"
className="pointer tn-tool-button"
text={t("promoted_attributes.add_new_attribute")}
noIconActionClass
/>
<ActionButton
icon="bx bx-trash"
className="pointer tn-tool-button"
text={t("promoted_attributes.remove_this_attribute")}
noIconActionClass
/>
</td>
)}
</div>
)
}

View File

@@ -1,31 +0,0 @@
.user-attributes {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
margin-top: 8px;
}
.user-attributes .user-attribute {
padding: 2px 10px;
border-radius: 9999px;
white-space: nowrap;
background-color: var(--chip-bg, rgba(0, 0, 0, 0.08));
color: var(--chip-fg, inherit);
border: 1px solid var(--chip-border, rgba(0, 0, 0, 0.15));
font-size: 12px;
line-height: 1.2;
}
.user-attributes .user-attribute:hover {
background-color: var(--chip-bg-hover, rgba(0, 0, 0, 0.12));
border-color: var(--chip-border-hover, rgba(0, 0, 0, 0.22));
}
.user-attributes .user-attribute .name {
font-weight: 600;
}
.user-attributes .user-attribute .value {
opacity: 0.9;
}

View File

@@ -1,134 +0,0 @@
import { useState } from "preact/hooks";
import FNote from "../../entities/fnote";
import "./UserAttributesList.css";
import { useTriliumEvent } from "../react/hooks";
import attributes from "../../services/attributes";
import { DefinitionObject } from "../../services/promoted_attribute_definition_parser";
import { formatDateTime } from "../../utils/formatters";
import { ComponentChildren, CSSProperties } from "preact";
import Icon from "../react/Icon";
import NoteLink from "../react/NoteLink";
import { getReadableTextColor } from "../../services/css_class_manager";
interface UserAttributesListProps {
note: FNote;
ignoredAttributes?: string[];
}
interface AttributeWithDefinitions {
friendlyName: string;
name: string;
type: string;
value: string;
def: DefinitionObject;
}
export default function UserAttributesDisplay({ note, ignoredAttributes }: UserAttributesListProps) {
const userAttributes = useNoteAttributesWithDefinitions(note, ignoredAttributes);
return userAttributes?.length > 0 && (
<div className="user-attributes">
{userAttributes?.map(attr => buildUserAttribute(attr))}
</div>
)
}
function useNoteAttributesWithDefinitions(note: FNote, attributesToIgnore: string[] = []): AttributeWithDefinitions[] {
const [ userAttributes, setUserAttributes ] = useState<AttributeWithDefinitions[]>(getAttributesWithDefinitions(note, attributesToIgnore));
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
if (loadResults.getAttributeRows().some(attr => attributes.isAffecting(attr, note))) {
setUserAttributes(getAttributesWithDefinitions(note, attributesToIgnore));
}
});
return userAttributes;
}
function UserAttribute({ attr, children, style }: { attr: AttributeWithDefinitions, children: ComponentChildren, style?: CSSProperties }) {
const className = `${attr.type === "label" ? "label" + " " + attr.def.labelType : "relation"}`;
return (
<span key={attr.friendlyName} className={`user-attribute type-${className}`} style={style}>
{children}
</span>
)
}
function buildUserAttribute(attr: AttributeWithDefinitions): ComponentChildren {
const defaultLabel = <><strong>{attr.friendlyName}:</strong>{" "}</>;
let content: ComponentChildren;
let style: CSSProperties | undefined;
if (attr.type === "label") {
let value = attr.value;
switch (attr.def.labelType) {
case "number":
let formattedValue = value;
const numberValue = Number(value);
if (!Number.isNaN(numberValue) && attr.def.numberPrecision) formattedValue = numberValue.toFixed(attr.def.numberPrecision);
content = <>{defaultLabel}{formattedValue}</>;
break;
case "date":
case "datetime": {
const date = new Date(value);
const timeFormat = attr.def.labelType !== "date" ? "short" : "none";
const formattedValue = formatDateTime(date, "short", timeFormat);
content = <>{defaultLabel}{formattedValue}</>;
break;
}
case "time": {
const date = new Date(`1970-01-01T${value}Z`);
const formattedValue = formatDateTime(date, "none", "short");
content = <>{defaultLabel}{formattedValue}</>;
break;
}
case "boolean":
content = <><Icon icon={value === "true" ? "bx bx-check-square" : "bx bx-square"} />{" "}<strong>{attr.friendlyName}</strong></>;
break;
case "url":
content = <a href={value} target="_blank" rel="noopener noreferrer">{attr.friendlyName}</a>;
break;
case "color":
style = { backgroundColor: value, color: getReadableTextColor(value) };
content = <>{attr.friendlyName}</>;
break;
case "text":
default:
content = <>{defaultLabel}{value}</>;
break;
}
} else if (attr.type === "relation") {
content = <>{defaultLabel}<NoteLink notePath={attr.value} showNoteIcon /></>;
}
return <UserAttribute attr={attr} style={style}>{content}</UserAttribute>
}
function getAttributesWithDefinitions(note: FNote, attributesToIgnore: string[] = []): AttributeWithDefinitions[] {
const attributeDefintions = note.getAttributeDefinitions();
const result: AttributeWithDefinitions[] = [];
for (const attr of attributeDefintions) {
const def = attr.getDefinition();
const [ type, name ] = attr.name.split(":", 2);
const friendlyName = def?.promotedAlias || name;
const props: Omit<AttributeWithDefinitions, "value"> = { def, name, type, friendlyName };
if (attributesToIgnore.includes(name)) continue;
if (type === "label") {
const labels = note.getLabels(name);
for (const label of labels) {
if (!label.value) continue;
result.push({ ...props, value: label.value } );
}
} else if (type === "relation") {
const relations = note.getRelations(name);
for (const relation of relations) {
if (!relation.value) continue;
result.push({ ...props, value: relation.value } );
}
}
}
return result;
}

View File

@@ -77,8 +77,8 @@ export function CustomNoteList<T extends object>({ note, isEnabled: shouldEnable
props = {
note, noteIds, notePath,
highlightedTokens,
viewConfig: viewModeConfig.config,
saveConfig: viewModeConfig.storeFn,
viewConfig: viewModeConfig[0],
saveConfig: viewModeConfig[1],
onReady: onReady ?? (() => {}),
...restProps
}
@@ -141,7 +141,7 @@ export function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOpt
async function getNoteIds(note: FNote) {
if (viewType === "list" || viewType === "grid" || viewType === "table" || note.type === "search") {
return await note.getChildNoteIdsWithArchiveFiltering(includeArchived);
return note.getChildNoteIds();
} else {
return await note.getSubtreeNoteIds(includeArchived);
}
@@ -192,11 +192,7 @@ export function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOpt
}
export function useViewModeConfig<T extends object>(note: FNote | null | undefined, viewType: ViewTypeOptions | undefined) {
const [ viewConfig, setViewConfig ] = useState<{
config: T | undefined;
storeFn: (data: T) => void;
note: FNote;
}>();
const [ viewConfig, setViewConfig ] = useState<[T | undefined, (data: T) => void]>();
useEffect(() => {
if (!note || !viewType) return;
@@ -204,14 +200,12 @@ export function useViewModeConfig<T extends object>(note: FNote | null | undefin
const viewStorage = new ViewModeStorage<T>(note, viewType);
viewStorage.restore().then(config => {
const storeFn = (config: T) => {
setViewConfig({ note, config, storeFn });
setViewConfig([ config, storeFn ]);
viewStorage.store(config);
};
setViewConfig({ note, config, storeFn });
setViewConfig([ config, storeFn ]);
});
}, [ note, viewType ]);
// Only expose config for the current note, avoid leaking notes when switching between them.
if (viewConfig?.note !== note) return undefined;
return viewConfig;
}

View File

@@ -1,4 +1,3 @@
import { BulkAction } from "@triliumnext/commons";
import { BoardViewData } from ".";
import appContext from "../../../components/app_context";
import FNote from "../../../entities/fnote";
@@ -13,25 +12,15 @@ import { ColumnMap } from "./data";
export default class BoardApi {
private isRelationMode: boolean;
statusAttribute: string;
constructor(
private byColumn: ColumnMap | undefined,
public columns: string[],
private parentNote: FNote,
statusAttribute: string,
private statusAttribute: string,
private viewConfig: BoardViewData,
private saveConfig: (newConfig: BoardViewData) => void,
private setBranchIdToEdit: (branchId: string | undefined) => void
) {
this.isRelationMode = statusAttribute.startsWith("~");
if (statusAttribute.startsWith("~") || statusAttribute.startsWith("#")) {
statusAttribute = statusAttribute.substring(1);
}
this.statusAttribute = statusAttribute;
};
) {};
async createNewItem(column: string, title: string) {
try {
@@ -53,11 +42,7 @@ export default class BoardApi {
}
async changeColumn(noteId: string, newColumn: string) {
if (this.isRelationMode) {
await attributes.setRelation(noteId, this.statusAttribute, newColumn);
} else {
await attributes.setLabel(noteId, this.statusAttribute, newColumn);
}
await attributes.setLabel(noteId, this.statusAttribute, newColumn);
}
async addNewColumn(columnName: string) {
@@ -75,20 +60,22 @@ export default class BoardApi {
// Add the new column to persisted data if it doesn't exist
const existingColumn = this.viewConfig.columns.find(col => col.value === columnName);
if (existingColumn) return false;
this.viewConfig.columns.push({ value: columnName });
this.saveConfig(this.viewConfig);
return true;
if (!existingColumn) {
this.viewConfig.columns.push({ value: columnName });
this.saveConfig(this.viewConfig);
}
}
async removeColumn(column: string) {
// Remove the value from the notes.
const noteIds = this.byColumn?.get(column)?.map(item => item.note.noteId) || [];
await executeBulkActions(noteIds, [
{
name: "deleteLabel",
labelName: this.statusAttribute
}
]);
const action: BulkAction = this.isRelationMode
? { name: "deleteRelation", relationName: this.statusAttribute }
: { name: "deleteLabel", labelName: this.statusAttribute }
await executeBulkActions(noteIds, [ action ]);
this.viewConfig.columns = (this.viewConfig.columns ?? []).filter(col => col.value !== column);
this.saveConfig(this.viewConfig);
}
@@ -97,10 +84,13 @@ export default class BoardApi {
const noteIds = this.byColumn?.get(oldValue)?.map(item => item.note.noteId) || [];
// Change the value in the notes.
const action: BulkAction = this.isRelationMode
? { name: "updateRelationTarget", relationName: this.statusAttribute, targetNoteId: newValue }
: { name: "updateLabelValue", labelName: this.statusAttribute, labelValue: newValue }
await executeBulkActions(noteIds, [ action ]);
await executeBulkActions(noteIds, [
{
name: "updateLabelValue",
labelName: this.statusAttribute,
labelValue: newValue
}
]);
// Rename the column in the persisted data.
for (const column of this.viewConfig.columns || []) {
@@ -177,11 +167,7 @@ export default class BoardApi {
removeFromBoard(noteId: string) {
const note = froca.getNoteFromCache(noteId);
if (!note) return;
if (this.isRelationMode) {
return attributes.removeOwnedRelationByName(note, this.statusAttribute);
} else {
return attributes.removeOwnedLabelByName(note, this.statusAttribute);
}
return attributes.removeOwnedLabelByName(note, this.statusAttribute);
}
async moveWithinBoard(noteId: string, sourceBranchId: string, sourceIndex: number, targetIndex: number, sourceColumn: string, targetColumn: string) {

View File

@@ -6,8 +6,6 @@ import { BoardViewContext, TitleEditor } from ".";
import { ContextMenuEvent } from "../../../menus/context_menu";
import { openNoteContextMenu } from "./context_menu";
import { t } from "../../../services/i18n";
import UserAttributesDisplay from "../../attribute_widgets/UserAttributesList";
import { useTriliumEvent } from "../../react/hooks";
export const CARD_CLIPBOARD_TYPE = "trilium/board-card";
@@ -41,13 +39,6 @@ export default function Card({
const [ isVisible, setVisible ] = useState(true);
const [ title, setTitle ] = useState(note.title);
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
const row = loadResults.getEntityRow("notes", note.noteId);
if (row) {
setTitle(row.title);
}
});
const handleDragStart = useCallback((e: DragEvent) => {
e.dataTransfer!.effectAllowed = 'move';
const data: CardDragData = { noteId: note.noteId, branchId: branch.branchId, fromColumn: column, index };
@@ -117,7 +108,6 @@ export default function Card({
title={t("board_view.edit-note-title")}
onClick={handleEdit}
/>
<UserAttributesDisplay note={note} ignoredAttributes={[api.statusAttribute]} />
</>
) : (
<TitleEditor
@@ -127,7 +117,7 @@ export default function Card({
setTitle(newTitle);
}}
dismiss={() => api.dismissEditingTitle()}
mode="multiline"
multiline
/>
)}
</div>

View File

@@ -12,7 +12,6 @@ import Card, { CARD_CLIPBOARD_TYPE, CardDragData } from "./card";
import { JSX } from "preact/jsx-runtime";
import froca from "../../../services/froca";
import { DragData, TREE_CLIPBOARD_TYPE } from "../../note_tree";
import NoteLink from "../../react/NoteLink";
interface DragContext {
column: string;
@@ -28,14 +27,12 @@ export default function Column({
api,
onColumnHover,
isAnyColumnDragging,
isInRelationMode
}: {
columnItems?: { note: FNote, branch: FBranch }[];
isDraggingColumn: boolean,
api: BoardApi,
onColumnHover?: (index: number, mouseX: number, rect: DOMRect) => void,
isAnyColumnDragging?: boolean,
isInRelationMode: boolean
isAnyColumnDragging?: boolean
} & DragContext) {
const [ isVisible, setVisible ] = useState(true);
const { columnNameToEdit, setColumnNameToEdit, dropTarget, draggedCard, dropPosition } = useContext(BoardViewContext)!;
@@ -106,13 +103,7 @@ export default function Column({
>
{!isEditing ? (
<>
<span className="title">
{isInRelationMode
? <NoteLink notePath={column} showNoteIcon />
: column}
</span>
<span className="counter-badge">{columnItems?.length ?? 0}</span>
<div className="spacer" />
<span className="title">{column}</span>
<span
className="edit-icon icon bx bx-edit-alt"
title={t("board_view.edit-column-title")}
@@ -124,7 +115,6 @@ export default function Column({
currentValue={column}
save={newTitle => api.renameColumn(column, newTitle)}
dismiss={() => setColumnNameToEdit?.(undefined)}
mode={isInRelationMode ? "relation" : "normal"}
/>
)}
</h3>
@@ -188,7 +178,7 @@ function AddNewItem({ column, api }: { column: string, api: BoardApi }) {
placeholder={t("board_view.new-item-placeholder")}
save={(title) => api.createNewItem(column, title)}
dismiss={() => setIsCreatingNewItem(false)}
mode="multiline" isNewItem
multiline isNewItem
/>
)}
</div>

View File

@@ -57,8 +57,7 @@ export async function getBoardData(parentNote: FNote, groupByColumn: string, per
return {
byColumn,
newPersistedData,
isInRelationMode: groupByColumn.startsWith("~")
newPersistedData
};
}
@@ -71,7 +70,7 @@ async function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupB
await recursiveGroupBy(note.getChildBranches(), byColumn, groupByColumn, includeArchived, seenNoteIds);
}
const group = note.getLabelOrRelation(groupByColumn);
const group = note.getLabelValue(groupByColumn);
if (!group || seenNoteIds.has(note.noteId)) {
continue;
}

View File

@@ -9,12 +9,6 @@
--card-padding: 0.6em;
}
body.mobile .board-view {
scroll-snap-type: x mandatory;
-webkit-overflow-scrolling: touch;
scroll-behavior: smooth;
}
.board-view-container {
height: 100%;
display: flex;
@@ -37,12 +31,6 @@ body.mobile .board-view {
flex-direction: column;
}
body.mobile .board-view-container .board-column {
width: 75vw;
max-width: 300px;
scroll-snap-align: center;
}
.board-view-container .board-column.drag-over {
border-color: var(--main-text-color);
background-color: var(--hover-item-background-color);
@@ -65,21 +53,7 @@ body.mobile .board-view-container .board-column {
align-items: center;
}
.board-view-container .board-column h3 a {
text-decoration: none;
color: inherit;
}
.board-view-container .board-column h3 .counter-badge {
background-color: var(--muted-text-color);
color: var(--main-background-color);
border-radius: 12px;
padding: 0.1em 0.6em;
font-size: 0.75em;
margin-inline-start: 0.5em;
}
.board-view-container .board-column h3 > .spacer {
.board-view-container .board-column h3 > .title {
flex-grow: 1;
}

View File

@@ -13,8 +13,6 @@ import Column from "./column";
import BoardApi from "./api";
import FormTextArea from "../../react/FormTextArea";
import FNote from "../../../entities/fnote";
import NoteAutocomplete from "../../react/NoteAutocomplete";
import toast from "../../../services/toast";
export interface BoardViewData {
columns?: BoardColumnData[];
@@ -44,11 +42,10 @@ interface BoardViewContextData {
export const BoardViewContext = createContext<BoardViewContextData | undefined>(undefined);
export default function BoardView({ note: parentNote, noteIds, viewConfig, saveConfig }: ViewModeProps<BoardViewData>) {
const [ statusAttributeWithPrefix ] = useNoteLabelWithDefault(parentNote, "board:groupBy", "status");
const [ statusAttribute ] = useNoteLabelWithDefault(parentNote, "board:groupBy", "status");
const [ includeArchived ] = useNoteLabelBoolean(parentNote, "includeArchived");
const [ byColumn, setByColumn ] = useState<ColumnMap>();
const [ columns, setColumns ] = useState<string[]>();
const [ isInRelationMode, setIsRelationMode ] = useState(false);
const [ draggedCard, setDraggedCard ] = useState<{ noteId: string, branchId: string, fromColumn: string, index: number } | null>(null);
const [ dropTarget, setDropTarget ] = useState<string | null>(null);
const [ dropPosition, setDropPosition ] = useState<{ column: string, index: number } | null>(null);
@@ -58,8 +55,8 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
const [ branchIdToEdit, setBranchIdToEdit ] = useState<string>();
const [ columnNameToEdit, setColumnNameToEdit ] = useState<string>();
const api = useMemo(() => {
return new Api(byColumn, columns ?? [], parentNote, statusAttributeWithPrefix, viewConfig ?? {}, saveConfig, setBranchIdToEdit );
}, [ byColumn, columns, parentNote, statusAttributeWithPrefix, viewConfig, saveConfig, setBranchIdToEdit ]);
return new Api(byColumn, columns ?? [], parentNote, statusAttribute, viewConfig ?? {}, saveConfig, setBranchIdToEdit );
}, [ byColumn, columns, parentNote, statusAttribute, viewConfig, saveConfig, setBranchIdToEdit ]);
const boardViewContext = useMemo<BoardViewContextData>(() => ({
api,
parentNote,
@@ -81,9 +78,8 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
]);
function refresh() {
getBoardData(parentNote, statusAttributeWithPrefix, viewConfig ?? {}, includeArchived).then(({ byColumn, newPersistedData, isInRelationMode }) => {
getBoardData(parentNote, statusAttribute, viewConfig ?? {}, includeArchived).then(({ byColumn, newPersistedData }) => {
setByColumn(byColumn);
setIsRelationMode(isInRelationMode);
if (newPersistedData) {
viewConfig = { ...newPersistedData };
@@ -98,7 +94,7 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
});
}
useEffect(refresh, [ parentNote, noteIds, viewConfig, statusAttributeWithPrefix ]);
useEffect(refresh, [ parentNote, noteIds, viewConfig ]);
const handleColumnDrop = useCallback((fromIndex: number, toIndex: number) => {
const newColumns = api.reorderColumn(fromIndex, toIndex);
@@ -114,7 +110,7 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
// Check if any changes affect our board
const hasRelevantChanges =
// React to changes in status attribute for notes in this board
loadResults.getAttributeRows().some(attr => attr.name === api.statusAttribute && noteIds.includes(attr.noteId!)) ||
loadResults.getAttributeRows().some(attr => attr.name === statusAttribute && noteIds.includes(attr.noteId!)) ||
// React to changes in note title
loadResults.getNoteIds().some(noteId => noteIds.includes(noteId)) ||
// React to changes in branches for subchildren (e.g., moved, added, or removed notes)
@@ -175,7 +171,6 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
<div className="column-drop-placeholder show" />
)}
<Column
isInRelationMode={isInRelationMode}
api={api}
column={column}
columnIndex={index}
@@ -190,14 +185,14 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
<div className="column-drop-placeholder show" />
)}
<AddNewColumn api={api} isInRelationMode={isInRelationMode} />
<AddNewColumn api={api} />
</div>
</BoardViewContext.Provider>
</div>
)
}
function AddNewColumn({ api, isInRelationMode }: { api: BoardApi, isInRelationMode: boolean }) {
function AddNewColumn({ api }: { api: BoardApi }) {
const [ isCreatingNewColumn, setIsCreatingNewColumn ] = useState(false);
const addColumnCallback = useCallback(() => {
@@ -214,28 +209,22 @@ function AddNewColumn({ api, isInRelationMode }: { api: BoardApi, isInRelationMo
: (
<TitleEditor
placeholder={t("board_view.add-column-placeholder")}
save={async (columnName) => {
const created = await api.addNewColumn(columnName);
if (!created) {
toast.showMessage(t("board_view.column-already-exists"), undefined, "bx bx-duplicate");
}
}}
save={(columnName) => api.addNewColumn(columnName)}
dismiss={() => setIsCreatingNewColumn(false)}
isNewItem
mode={isInRelationMode ? "relation" : "normal"}
/>
)}
</div>
)
}
export function TitleEditor({ currentValue, placeholder, save, dismiss, mode, isNewItem }: {
export function TitleEditor({ currentValue, placeholder, save, dismiss, multiline, isNewItem }: {
currentValue?: string;
placeholder?: string;
save: (newValue: string) => void;
dismiss: () => void;
multiline?: boolean;
isNewItem?: boolean;
mode?: "normal" | "multiline" | "relation";
}) {
const inputRef = useRef<any>(null);
const focusElRef = useRef<Element>(null);
@@ -243,11 +232,13 @@ export function TitleEditor({ currentValue, placeholder, save, dismiss, mode, is
const shouldDismiss = useRef(false);
useEffect(() => {
focusElRef.current = document.activeElement !== document.body ? document.activeElement : null;
focusElRef.current = document.activeElement;
inputRef.current?.focus();
inputRef.current?.select();
}, [ inputRef ]);
const Element = multiline ? FormTextArea : FormTextBox;
useEffect(() => {
if (dismissOnNextRefreshRef.current) {
dismiss();
@@ -255,62 +246,31 @@ export function TitleEditor({ currentValue, placeholder, save, dismiss, mode, is
}
});
const onKeyDown = (e: TargetedKeyboardEvent<HTMLInputElement | HTMLTextAreaElement> | KeyboardEvent) => {
if (e.key === "Enter" || e.key === "Escape") {
e.preventDefault();
e.stopPropagation();
if (focusElRef.current instanceof HTMLElement) {
shouldDismiss.current = (e.key === "Escape");
focusElRef.current.focus();
} else {
dismiss();
}
}
};
const onBlur = (newValue: string) => {
if (!shouldDismiss.current && newValue.trim() && (newValue !== currentValue || isNewItem)) {
save(newValue);
dismissOnNextRefreshRef.current = true;
} else {
dismiss();
}
};
if (mode !== "relation") {
const Element = mode === "multiline" ? FormTextArea : FormTextBox;
return (
<Element
inputRef={inputRef}
currentValue={currentValue ?? ""}
placeholder={placeholder}
autoComplete="trilium-title-entry" // forces the auto-fill off better than the "off" value.
rows={mode === "multiline" ? 4 : undefined}
onKeyDown={onKeyDown}
onBlur={onBlur}
/>
);
} else {
return (
<NoteAutocomplete
inputRef={inputRef}
noteId={currentValue ?? ""}
opts={{
hideAllButtons: true,
allowCreatingNotes: true
}}
onKeyDown={(e) => {
if (e.key === "Escape") {
dismiss();
return (
<Element
inputRef={inputRef}
currentValue={currentValue ?? ""}
placeholder={placeholder}
autoComplete="trilium-title-entry" // forces the auto-fill off better than the "off" value.
rows={multiline ? 4 : undefined}
onKeyDown={(e: TargetedKeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {
if (e.key === "Enter" || e.key === "Escape") {
e.preventDefault();
e.stopPropagation();
shouldDismiss.current = (e.key === "Escape");
if (focusElRef.current instanceof HTMLElement) {
focusElRef.current.focus();
}
}}
onBlur={() => dismiss()}
noteIdChanged={(newValue) => {
}
}}
onBlur={(newValue) => {
if (!shouldDismiss.current && newValue.trim() && (newValue !== currentValue || isNewItem)) {
save(newValue);
dismissOnNextRefreshRef.current = true;
} else {
dismiss();
}}
/>
);
}
}
}}
/>
);
}

View File

@@ -2,7 +2,6 @@ import FNote from "../../../entities/fnote";
import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";
import link_context_menu from "../../../menus/link_context_menu";
import branches from "../../../services/branches";
import froca from "../../../services/froca";
import { t } from "../../../services/i18n";
export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, parentNote: FNote) {
@@ -19,20 +18,8 @@ export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, par
title: t("calendar_view.delete_note"),
uiIcon: "bx bx-trash",
handler: async () => {
const noteToDelete = await froca.getNote(noteId);
if (!noteToDelete) return;
let branchIdToDelete: string | null = null;
for (const parentBranch of noteToDelete.getParentBranches()) {
const parentNote = await parentBranch.getNote();
if (parentNote?.hasAncestor(parentNote.noteId)) {
branchIdToDelete = parentBranch.branchId;
}
}
if (branchIdToDelete) {
await branches.deleteNotes([ branchIdToDelete ], false, false);
}
const branchId = parentNote.childToBranch[noteId];
await branches.deleteNotes([ branchId ], false, false);
}
}
],

View File

@@ -91,7 +91,6 @@ export default function CalendarView({ note, noteIds }: ViewModeProps<CalendarVi
const [ hideWeekends ] = useNoteLabelBoolean(note, "calendar:hideWeekends");
const [ weekNumbers ] = useNoteLabelBoolean(note, "calendar:weekNumbers");
const [ calendarView, setCalendarView ] = useNoteLabel(note, "calendar:view");
const [ initialDate ] = useNoteLabel(note, "calendar:initialDate");
const initialView = useRef(calendarView);
const viewSpacedUpdate = useSpacedUpdate(() => setCalendarView(initialView.current));
useResizeObserver(containerRef, () => calendarRef.current?.updateSize());
@@ -135,7 +134,6 @@ export default function CalendarView({ note, noteIds }: ViewModeProps<CalendarVi
height="90%"
nowIndicator
handleWindowResize={false}
initialDate={initialDate || undefined}
locale={locale}
{...editingProps}
eventDidMount={eventDidMount}

View File

@@ -16,10 +16,6 @@
flex-grow: 1;
}
.note-book-card.archived {
opacity: 0.5;
}
.note-book-card:not(.expanded) .note-book-content {
padding: 10px
}

View File

@@ -64,7 +64,7 @@ function ListNoteCard({ note, parentNote, expand, highlightedTokens }: { note: F
return (
<div
className={`note-book-card no-tooltip-preview ${isExpanded ? "expanded" : ""} ${note.isArchived ? "archived" : ""}`}
className={`note-book-card no-tooltip-preview ${isExpanded ? "expanded" : ""}`}
data-note-id={note.noteId}
>
<h5 className="note-book-header">
@@ -100,7 +100,7 @@ function GridNoteCard({ note, parentNote, highlightedTokens }: { note: FNote, pa
return (
<div
className={`note-book-card no-tooltip-preview block-link ${note.isArchived ? "archived" : ""}`}
className={`note-book-card no-tooltip-preview block-link`}
data-href={`#${notePath}`}
data-note-id={note.noteId}
onClick={(e) => link.goToLink(e)}

View File

@@ -15,7 +15,6 @@ export default class ContentHeader extends Container<BasicWidget> {
constructor() {
super();
this.class("content-header-widget");
this.css("contain", "unset");
this.resizeObserver = new ResizeObserver(this.onResize.bind(this));
}

View File

@@ -12,102 +12,6 @@ import type { Attribute } from "../services/attribute_parser.js";
import type FAttribute from "../entities/fattribute.js";
import type { EventData } from "../components/app_context.js";
const TPL = /*html*/`
<div class="promoted-attributes-widget">
<style>
body.mobile .promoted-attributes-widget {
/* https://github.com/zadam/trilium/issues/4468 */
flex-shrink: 0.4;
overflow: auto;
}
.promoted-attributes-container {
margin: 0 1.5em;
overflow: auto;
max-height: 400px;
flex-wrap: wrap;
display: table;
}
.promoted-attribute-cell {
display: flex;
align-items: center;
margin: 10px;
display: table-row;
}
.promoted-attribute-cell > label {
user-select: none;
font-weight: bold;
vertical-align: middle;
}
.promoted-attribute-cell > * {
display: table-cell;
padding: 1px 0;
}
.promoted-attribute-cell div.input-group {
margin-inline-start: 10px;
display: flex;
min-height: 40px;
}
.promoted-attribute-cell strong {
word-break:keep-all;
white-space: nowrap;
}
.promoted-attribute-cell input[type="checkbox"] {
width: 22px !important;
flex-grow: 0;
width: unset;
}
/* Restore default apperance */
.promoted-attribute-cell input[type="number"],
.promoted-attribute-cell input[type="checkbox"] {
appearance: auto;
}
.promoted-attribute-cell input[type="color"] {
width: 24px;
height: 24px;
margin-top: 2px;
appearance: none;
padding: 0;
border: 0;
outline: none;
border-radius: 25% !important;
}
.promoted-attribute-cell input[type="color"]::-webkit-color-swatch-wrapper {
padding: 0;
}
.promoted-attribute-cell input[type="color"]::-webkit-color-swatch {
border: none;
border-radius: 25%;
}
.promoted-attribute-label-color input[type="hidden"][value=""] + input[type="color"] {
position: relative;
opacity: 0.5;
}
.promoted-attribute-label-color input[type="hidden"][value=""] + input[type="color"]:after {
content: "";
position: absolute;
top: 10px;
inset-inline-start: 0px;
inset-inline-end: 0;
height: 2px;
background: rgba(0, 0, 0, 0.5);
transform: rotate(45deg);
pointer-events: none;
}
</style>
<div class="promoted-attributes-container"></div>
</div>`;
// TODO: Deduplicate
interface AttributeResult {
attributeId: string;
@@ -117,115 +21,17 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
private $container!: JQuery<HTMLElement>;
get name() {
return "promotedAttributes";
}
get toggleCommand() {
return "toggleRibbonTabPromotedAttributes";
}
doRender() {
this.$widget = $(TPL);
this.$widget = $("");
this.contentSized();
this.$container = this.$widget.find(".promoted-attributes-container");
}
getTitle(note: FNote) {
const promotedDefAttrs = note.getPromotedDefinitionAttributes();
if (promotedDefAttrs.length === 0) {
return { show: false };
}
return {
show: true,
activate: options.is("promotedAttributesOpenInRibbon"),
title: t("promoted_attributes.promoted_attributes"),
icon: "bx bx-table"
};
}
async refreshWithNote(note: FNote) {
this.$container.empty();
const promotedDefAttrs = note.getPromotedDefinitionAttributes();
const ownedAttributes = note.getOwnedAttributes();
// attrs are not resorted if position changes after the initial load
// promoted attrs are sorted primarily by order of definitions, but with multi-valued promoted attrs
// the order of attributes is important as well
ownedAttributes.sort((a, b) => a.position - b.position);
if (promotedDefAttrs.length === 0 || note.getLabelValue("viewType") === "table") {
this.toggleInt(false);
return;
}
const $cells: JQuery<HTMLElement>[] = [];
for (const definitionAttr of promotedDefAttrs) {
const valueType = definitionAttr.name.startsWith("label:") ? "label" : "relation";
const valueName = definitionAttr.name.substr(valueType.length + 1);
let valueAttrs = ownedAttributes.filter((el) => el.name === valueName && el.type === valueType) as Attribute[];
if (valueAttrs.length === 0) {
valueAttrs.push({
attributeId: "",
type: valueType,
name: valueName,
value: ""
});
}
if (definitionAttr.getDefinition().multiplicity === "single") {
valueAttrs = valueAttrs.slice(0, 1);
}
for (const valueAttr of valueAttrs) {
const $cell = await this.createPromotedAttributeCell(definitionAttr, valueAttr, valueName);
if ($cell) {
$cells.push($cell);
}
}
}
// we replace the whole content in one step, so there can't be any race conditions
// (previously we saw promoted attributes doubling)
this.$container.empty().append(...$cells);
this.toggleInt(true);
}
async createPromotedAttributeCell(definitionAttr: FAttribute, valueAttr: Attribute, valueName: string) {
const definition = definitionAttr.getDefinition();
const id = `value-${valueAttr.attributeId}`;
// .on("change", (event) => this.promotedAttributeChanged(event));
const $input = $("<input>")
.prop("tabindex", 200 + definitionAttr.position)
.prop("id", id)
.attr("data-attribute-id", valueAttr.noteId === this.noteId ? valueAttr.attributeId ?? "" : "") // if not owned, we'll force creation of a new attribute instead of updating the inherited one
.attr("data-attribute-type", valueAttr.type)
.attr("data-attribute-name", valueAttr.name)
.prop("value", valueAttr.value)
.prop("placeholder", t("promoted_attributes.unset-field-placeholder"))
.addClass("form-control")
.addClass("promoted-attribute-input")
.on("change", (event) => this.promotedAttributeChanged(event));
const $actionCell = $("<div>");
const $multiplicityCell = $("<td>").addClass("multiplicity").attr("nowrap", "true");
const $wrapper = $('<div class="promoted-attribute-cell">')
.append(
$("<label>")
.prop("for", id)
.text(definition.promotedAlias ?? valueName)
)
.append($("<div>").addClass("input-group").append($input))
.append($actionCell)
.append($multiplicityCell);
if (valueAttr.type === "label") {
$wrapper.addClass(`promoted-attribute-label-${definition.labelType}`);
if (definition.labelType === "text") {
@@ -359,8 +165,6 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
if (definition.multiplicity === "multi") {
const $addButton = $("<span>")
.addClass("bx bx-plus pointer tn-tool-button")
.prop("title", t("promoted_attributes.add_new_attribute"))
.on("click", async () => {
const $new = await this.createPromotedAttributeCell(
definitionAttr,

View File

@@ -5,7 +5,7 @@ import type { RefObject } from "preact";
import type { CSSProperties } from "preact/compat";
import { useSyncedRef } from "./hooks";
interface NoteAutocompleteProps {
interface NoteAutocompleteProps {
id?: string;
inputRef?: RefObject<HTMLInputElement>;
text?: string;
@@ -15,15 +15,13 @@ interface NoteAutocompleteProps {
opts?: Omit<Options, "container">;
onChange?: (suggestion: Suggestion | null) => void;
onTextChange?: (text: string) => void;
onKeyDown?: (e: KeyboardEvent) => void;
onBlur?: (newValue: string) => void;
noteIdChanged?: (noteId: string) => void;
noteId?: string;
}
export default function NoteAutocomplete({ id, inputRef: externalInputRef, text, placeholder, onChange, onTextChange, container, containerStyle, opts, noteId, noteIdChanged, onKeyDown, onBlur }: NoteAutocompleteProps) {
export default function NoteAutocomplete({ id, inputRef: externalInputRef, text, placeholder, onChange, onTextChange, container, containerStyle, opts, noteId, noteIdChanged }: NoteAutocompleteProps) {
const ref = useSyncedRef<HTMLInputElement>(externalInputRef);
useEffect(() => {
if (!ref.current) return;
const $autoComplete = $(ref.current);
@@ -59,12 +57,6 @@ export default function NoteAutocomplete({ id, inputRef: externalInputRef, text,
if (onTextChange) {
$autoComplete.on("input", () => onTextChange($autoComplete[0].value));
}
if (onKeyDown) {
$autoComplete.on("keydown", (e) => e.originalEvent && onKeyDown(e.originalEvent));
}
if (onBlur) {
$autoComplete.on("blur", () => onBlur($autoComplete.getSelectedNoteId() ?? ""));
}
}, [opts, container?.current]);
useEffect(() => {
@@ -89,4 +81,4 @@ export default function NoteAutocomplete({ id, inputRef: externalInputRef, text,
placeholder={placeholder ?? t("add_link.search_note")} />
</div>
);
}
}

View File

@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from "preact/hooks";
import link, { ViewScope } from "../../services/link";
import { useImperativeSearchHighlighlighting, useTriliumEvent } from "./hooks";
import { useImperativeSearchHighlighlighting } from "./hooks";
interface NoteLinkOpts {
className?: string;
@@ -19,11 +19,9 @@ interface NoteLinkOpts {
export default function NoteLink({ className, notePath, showNotePath, showNoteIcon, style, noPreview, noTnLink, highlightedTokens, title, viewScope, noContextMenu }: NoteLinkOpts) {
const stringifiedNotePath = Array.isArray(notePath) ? notePath.join("/") : notePath;
const noteId = stringifiedNotePath.split("/").at(-1);
const ref = useRef<HTMLSpanElement>(null);
const [ jqueryEl, setJqueryEl ] = useState<JQuery<HTMLElement>>();
const highlightSearch = useImperativeSearchHighlighlighting(highlightedTokens);
const [ noteTitle, setNoteTitle ] = useState<string>();
useEffect(() => {
link.createLink(stringifiedNotePath, {
@@ -32,7 +30,7 @@ export default function NoteLink({ className, notePath, showNotePath, showNoteIc
showNoteIcon,
viewScope
}).then(setJqueryEl);
}, [ stringifiedNotePath, showNotePath, title, viewScope, noteTitle ]);
}, [ stringifiedNotePath, showNotePath, title, viewScope ]);
useEffect(() => {
if (!ref.current || !jqueryEl) return;
@@ -40,16 +38,6 @@ export default function NoteLink({ className, notePath, showNotePath, showNoteIc
highlightSearch(ref.current);
}, [ jqueryEl, highlightedTokens ]);
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
// React to note title changes, but only if the title is not overwritten.
if (!title && noteId) {
const entityRow = loadResults.getEntityRow("notes", noteId);
if (entityRow) {
setNoteTitle(entityRow.title);
}
}
});
if (style) {
jqueryEl?.css(style);
}

View File

@@ -406,17 +406,14 @@ export function useNoteLabelWithDefault(note: FNote | undefined | null, labelNam
}
export function useNoteLabelBoolean(note: FNote | undefined | null, labelName: FilterLabelsByType<boolean>): [ boolean, (newValue: boolean) => void] {
const [, forceRender] = useState({});
const [ labelValue, setLabelValue ] = useState<boolean>(!!note?.hasLabel(labelName));
useEffect(() => {
forceRender({});
}, [ note ]);
useEffect(() => setLabelValue(!!note?.hasLabel(labelName)), [ note ]);
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
for (const attr of loadResults.getAttributeRows()) {
if (attr.type === "label" && attr.name === labelName && attributes.isAffecting(attr, note)) {
forceRender({});
break;
setLabelValue(!attr.isDeleted);
}
}
});
@@ -433,7 +430,6 @@ export function useNoteLabelBoolean(note: FNote | undefined | null, labelName: F
useDebugValue(labelName);
const labelValue = !!note?.hasLabel(labelName);
return [ labelValue, setter ] as const;
}

View File

@@ -59,12 +59,13 @@ function CollectionTypeSwitcher({ viewType, setViewType }: { viewType: string, s
function BookProperties({ viewType, note, properties }: { viewType: ViewTypeOptions, note: FNote, properties: BookProperty[] }) {
return (
<>
{properties.map(property => (
{properties.map(property => (
<div className={`type-${property}`}>
{mapPropertyView({ note, property })}
{mapPropertyView({ note, property })}
</div>
))}
))}
{viewType !== "list" && viewType !== "grid" && (
<CheckboxPropertyView
note={note} property={{
bindToLabel: "includeArchived",
@@ -72,6 +73,7 @@ function BookProperties({ viewType, note, properties }: { viewType: ViewTypeOpti
type: "checkbox"
}}
/>
)}
</>
)
}

View File

@@ -81,7 +81,7 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {
await attributes.removeAttributeById(noteId, expandedAttr.attributeId);
}
triggerCommand("refreshNoteList", { noteId });
triggerCommand("refreshNoteList", { noteId: noteId });
},
},
{

View File

@@ -7,6 +7,7 @@ import { useTriliumEvent } from "../react/hooks";
import { refToJQuerySelector } from "../react/react_utils";
export default function Doc({ note, viewScope, ntxId }: TypeWidgetProps) {
const [ html, setHtml ] = useState<string>();
const initialized = useRef<Promise<void> | null>(null);
const containerRef = useRef<HTMLDivElement>(null);
@@ -14,7 +15,7 @@ export default function Doc({ note, viewScope, ntxId }: TypeWidgetProps) {
if (!note) return;
initialized.current = renderDoc(note).then($content => {
containerRef.current?.replaceChildren(...$content);
setHtml($content.html());
});
}, [ note ]);
@@ -25,9 +26,10 @@ export default function Doc({ note, viewScope, ntxId }: TypeWidgetProps) {
});
return (
<div
ref={containerRef}
<RawHtmlBlock
containerRef={containerRef}
className={`note-detail-doc-content ck-content ${viewScope?.viewMode === "contextual-help" ? "contextual-help" : ""}`}
html={html}
/>
);
}

View File

@@ -1,16 +1,15 @@
import { useCallback, useEffect, useRef } from "preact/hooks";
import { TypeWidgetProps } from "./type_widget";
import { MindElixirData, MindElixirInstance, Operation, Options, default as VanillaMindElixir } from "mind-elixir";
import { MindElixirData, MindElixirInstance, Operation, default as VanillaMindElixir } from "mind-elixir";
import { HTMLAttributes, RefObject } from "preact";
// allow node-menu plugin css to be bundled by webpack
import nodeMenu from "@mind-elixir/node-menu";
import "mind-elixir/style";
import "@mind-elixir/node-menu/dist/style.css";
import "./MindMap.css";
import { useEditorSpacedUpdate, useNoteLabelBoolean, useSyncedRef, useTriliumEvent, useTriliumEvents, useTriliumOption } from "../react/hooks";
import { useEditorSpacedUpdate, useNoteLabelBoolean, useSyncedRef, useTriliumEvent, useTriliumEvents } from "../react/hooks";
import { refToJQuerySelector } from "../react/react_utils";
import utils from "../../services/utils";
import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons";
const NEW_TOPIC_NAME = "";
@@ -22,24 +21,6 @@ interface MindElixirProps {
onChange?: () => void;
}
const LOCALE_MAPPINGS: Record<DISPLAYABLE_LOCALE_IDS, Options["locale"] | null> = {
ar: null,
cn: "zh_CN",
de: null,
en: "en",
en_rtl: "en",
es: "es",
fr: "fr",
it: "it",
ja: "ja",
pt: "pt",
pt_br: "pt",
ro: null,
ru: "ru",
tw: "zh_TW",
uk: null
};
export default function MindMap({ note, ntxId, noteContext }: TypeWidgetProps) {
const apiRef = useRef<MindElixirInstance>(null);
const containerRef = useRef<HTMLDivElement>(null);
@@ -129,14 +110,12 @@ export default function MindMap({ note, ntxId, noteContext }: TypeWidgetProps) {
function MindElixir({ containerRef: externalContainerRef, containerProps, apiRef: externalApiRef, onChange, editable }: MindElixirProps) {
const containerRef = useSyncedRef<HTMLDivElement>(externalContainerRef, null);
const apiRef = useRef<MindElixirInstance>(null);
const [ locale ] = useTriliumOption("locale");
function reinitialize() {
if (!containerRef.current) return;
const mind = new VanillaMindElixir({
el: containerRef.current,
locale: LOCALE_MAPPINGS[locale as DISPLAYABLE_LOCALE_IDS] ?? undefined,
editable
});
@@ -164,7 +143,7 @@ function MindElixir({ containerRef: externalContainerRef, containerProps, apiRef
if (data) {
apiRef.current?.init(data);
}
}, [ editable, locale ]);
}, [ editable ]);
// On change listener.
useEffect(() => {

View File

@@ -1,7 +1,7 @@
import { Excalidraw } from "@excalidraw/excalidraw";
import { TypeWidgetProps } from "../type_widget";
import "@excalidraw/excalidraw/index.css";
import { useNoteLabelBoolean, useTriliumOption } from "../../react/hooks";
import { useNoteLabelBoolean } from "../../react/hooks";
import { useCallback, useMemo, useRef } from "preact/hooks";
import { type ExcalidrawImperativeAPI, type AppState } from "@excalidraw/excalidraw/types";
import options from "../../../services/options";
@@ -9,8 +9,6 @@ import "./Canvas.css";
import { NonDeletedExcalidrawElement } from "@excalidraw/excalidraw/element/types";
import { goToLinkExt } from "../../../services/link";
import useCanvasPersistence from "./persistence";
import { LANGUAGE_MAPPINGS } from "./i18n";
import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons";
// currently required by excalidraw, in order to allows self-hosting fonts locally.
// this avoids making excalidraw load the fonts from an external CDN.
@@ -23,7 +21,6 @@ export default function Canvas({ note, noteContext }: TypeWidgetProps) {
const documentStyle = window.getComputedStyle(document.documentElement);
return documentStyle.getPropertyValue("--theme-style")?.trim() as AppState["theme"];
}, []);
const [ locale ] = useTriliumOption("locale");
const persistence = useCanvasPersistence(note, noteContext, apiRef, themeStyle, isReadOnly);
/** Use excalidraw's native zoom instead of the global zoom. */
@@ -61,7 +58,6 @@ export default function Canvas({ note, noteContext }: TypeWidgetProps) {
detectScroll={false}
handleKeyboardGlobally={false}
autoFocus={false}
langCode={LANGUAGE_MAPPINGS[locale as DISPLAYABLE_LOCALE_IDS] ?? undefined}
UIOptions={{
canvasActions: {
saveToActiveFile: false,

View File

@@ -1,29 +0,0 @@
import { LOCALES } from "@triliumnext/commons";
import { readdirSync } from "fs";
import { join } from "path";
import { describe, expect, it } from "vitest";
import { LANGUAGE_MAPPINGS } from "./i18n.js";
const localeDir = join(__dirname, "../../../../../../node_modules/@excalidraw/excalidraw/dist/prod/locales");
describe("Canvas i18n", () => {
it("all languages are mapped correctly", () => {
// Read the node_modules dir to obtain all the supported locales.
const supportedLanguageCodes = new Set<string>();
for (const file of readdirSync(localeDir)) {
if (file.startsWith("percentages")) continue;
const match = file.match("^[a-z]{2,3}(?:-[A-Z]{2,3})?");
if (!match) continue;
supportedLanguageCodes.add(match[0]);
}
// Cross-check the locales.
for (const locale of LOCALES) {
if (locale.contentOnly || locale.devOnly) continue;
const languageCode = LANGUAGE_MAPPINGS[locale.id];
if (!supportedLanguageCodes.has(languageCode)) {
expect.fail(`Unable to find locale for ${locale.id} -> ${languageCode}.`)
}
}
});
});

View File

@@ -1,19 +0,0 @@
import type { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons";
export const LANGUAGE_MAPPINGS: Record<DISPLAYABLE_LOCALE_IDS, string | null> = {
ar: "ar-SA",
cn: "zh-CN",
de: "de-DE",
en: "en",
en_rtl: "en",
es: "es-ES",
fr: "fr-FR",
it: "it-IT",
ja: "ja-JP",
pt: "pt-PT",
pt_br: "pt-BR",
ro: "ro-RO",
ru: "ru-RU",
tw: "zh-TW",
uk: "uk-UA"
};

View File

@@ -203,7 +203,7 @@ function Font({ title, fontFamilyOption, fontSizeOption }: { title: string, font
<FormTextBoxWithUnit
name="tree-font-size"
type="number" min={50} max={200} step={10}
currentValue={fontSize} onBlur={setFontSize}
currentValue={fontSize} onChange={setFontSize}
unit={t("units.percentage")}
/>
</FormGroup>

View File

@@ -1,10 +1,9 @@
import { HTMLProps, RefObject, useEffect, useImperativeHandle, useRef, useState } from "preact/compat";
import { PopupEditor, ClassicEditor, EditorWatchdog, type WatchdogConfig, CKTextEditor, TemplateDefinition } from "@triliumnext/ckeditor5";
import { buildConfig, BuildEditorOptions } from "./config";
import { useKeyboardShortcuts, useLegacyImperativeHandlers, useNoteContext, useSyncedRef, useTriliumOption } from "../../react/hooks";
import { useLegacyImperativeHandlers, useSyncedRef } from "../../react/hooks";
import link from "../../../services/link";
import froca from "../../../services/froca";
import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons";
export type BoxSize = "small" | "medium" | "full";
@@ -38,11 +37,7 @@ interface CKEditorWithWatchdogProps extends Pick<HTMLProps<HTMLDivElement>, "cla
export default function CKEditorWithWatchdog({ containerRef: externalContainerRef, content, contentLanguage, className, tabIndex, isClassicEditor, watchdogRef: externalWatchdogRef, watchdogConfig, onNotificationWarning, onWatchdogStateChange, onChange, onEditorInitialized, editorApi, templates }: CKEditorWithWatchdogProps) {
const containerRef = useSyncedRef<HTMLDivElement>(externalContainerRef, null);
const watchdogRef = useRef<EditorWatchdog>(null);
const [ uiLanguage ] = useTriliumOption("locale");
const [ editor, setEditor ] = useState<CKTextEditor>();
const { parentComponent } = useNoteContext();
useKeyboardShortcuts("text-detail", containerRef, parentComponent);
useImperativeHandle(editorApi, () => ({
hasSelection() {
@@ -158,7 +153,6 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerRe
const editor = await buildEditor(container, !!isClassicEditor, {
forceGplLicense: false,
isClassicEditor: !!isClassicEditor,
uiLanguage: uiLanguage as DISPLAYABLE_LOCALE_IDS,
contentLanguage: contentLanguage ?? null,
templates
});
@@ -183,7 +177,7 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerRe
watchdog.create(container);
return () => watchdog.destroy();
}, [ contentLanguage, templates, uiLanguage ]);
}, [ contentLanguage, templates ]);
// React to content changes.
useEffect(() => editor?.setData(content ?? ""), [ editor, content ]);

View File

@@ -32,11 +32,11 @@ body.mobile .note-detail-editable-text {
.note-detail-editable-text h5 { font-size: 1.1em; }
.note-detail-editable-text h6 { font-size: 1.0em; }
body.heading-style-markdown .note-detail-editable-text h2::before { content: "##\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-editable-text h3::before { content: "###\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-editable-text h4:not(.include-note-title)::before { content: "####\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-editable-text h5::before { content: "#####\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-editable-text h6::before { content: "######\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-editable-text h2::before { content: "##\\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-editable-text h3::before { content: "###\\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-editable-text h4:not(.include-note-title)::before { content: "####\\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-editable-text h5::before { content: "#####\\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-editable-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
body.heading-style-underline .note-detail-editable-text h2 { border-bottom: 1px solid var(--main-border-color); }
body.heading-style-underline .note-detail-editable-text h3 { border-bottom: 1px solid var(--main-border-color); }

View File

@@ -196,12 +196,14 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext
});
}
useKeyboardShortcuts("text-detail", containerRef, parentComponent);
useTriliumEvent("insertDateTimeToText", ({ ntxId: eventNtxId }) => {
if (eventNtxId !== ntxId) return;
const date = new Date();
const customDateTimeFormat = options.get("customDateTimeFormat");
const dateString = utils.formatDateTime(date, customDateTimeFormat);
console.log("Insert text ", ntxId, eventNtxId, dateString);
addTextToEditor(dateString);
});
useTriliumEvent("addTextToActiveEditor", ({ text }) => {

View File

@@ -6,12 +6,12 @@
.note-detail-readonly-text h5 { font-size: 1.1em; }
.note-detail-readonly-text h6 { font-size: 1.0em; }
body.heading-style-markdown .note-detail-readonly-text h1::before { content: "#\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h2::before { content: "##\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h3::before { content: "###\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h4:not(.include-note-title)::before { content: "####\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h5::before { content: "#####\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h6::before { content: "######\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h1::before { content: "#\\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h2::before { content: "##\\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h3::before { content: "###\\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h4:not(.include-note-title)::before { content: "####\\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h5::before { content: "#####\\2004"; color: var(--muted-text-color); }
body.heading-style-markdown .note-detail-readonly-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
body.heading-style-underline .note-detail-readonly-text h1 { border-bottom: 1px solid var(--main-border-color); }
body.heading-style-underline .note-detail-readonly-text h2 { border-bottom: 1px solid var(--main-border-color); }

View File

@@ -17,7 +17,6 @@ import link from "../../../services/link";
import { formatCodeBlocks } from "../../../services/syntax_highlight";
import TouchBar, { TouchBarButton, TouchBarSpacer } from "../../react/TouchBar";
import appContext from "../../../components/app_context";
import { applyReferenceLinks } from "./read_only_helper";
export default function ReadOnlyText({ note, noteContext, ntxId }: TypeWidgetProps) {
const blob = useNoteBlob(note);
@@ -123,3 +122,10 @@ function applyMath(container: HTMLDivElement) {
renderMathInElement(equation, { trust: true });
}
}
function applyReferenceLinks(container: HTMLDivElement) {
const referenceLinks = container.querySelectorAll<HTMLDivElement>("a.reference-link");
for (const referenceLink of referenceLinks) {
link.loadReferenceLinkTitle($(referenceLink));
}
}

View File

@@ -1,39 +0,0 @@
import { DISPLAYABLE_LOCALE_IDS, LOCALES } from "@triliumnext/commons";
import { describe, expect, it, vi } from "vitest";
vi.mock('../../../services/options.js', () => ({
default: {
get(name: string) {
if (name === "allowedHtmlTags") return "[]";
return undefined;
},
getJson: () => []
}
}));
describe("CK config", () => {
it("maps all languages correctly", async () => {
const { buildConfig } = await import("./config.js");
for (const locale of LOCALES) {
if (locale.contentOnly || locale.devOnly) continue;
const config = await buildConfig({
uiLanguage: locale.id as DISPLAYABLE_LOCALE_IDS,
contentLanguage: locale.id,
forceGplLicense: false,
isClassicEditor: false,
templates: []
});
let expectedLocale = locale.id.substring(0, 2);
if (expectedLocale === "cn") expectedLocale = "zh";
if (expectedLocale === "tw") expectedLocale = "zh-tw";
if (locale.id !== "en") {
expect((config.language as any).ui).toMatch(new RegExp(`^${expectedLocale}`));
expect(config.translations, locale.id).toBeDefined();
expect(config.translations, locale.id).toHaveLength(2);
}
}
});
});

View File

@@ -1,5 +1,5 @@
import { ALLOWED_PROTOCOLS, DISPLAYABLE_LOCALE_IDS, MIME_TYPE_AUTO } from "@triliumnext/commons";
import { buildExtraCommands, type EditorConfig, getCkLocale, PREMIUM_PLUGINS, TemplateDefinition } from "@triliumnext/ckeditor5";
import { ALLOWED_PROTOCOLS, MIME_TYPE_AUTO } from "@triliumnext/commons";
import { buildExtraCommands, type EditorConfig, PREMIUM_PLUGINS, TemplateDefinition } from "@triliumnext/ckeditor5";
import { getHighlightJsNameForMime } from "../../../services/mime_types.js";
import options from "../../../services/options.js";
import { ensureMimeTypesForHighlighting, isSyntaxHighlightEnabled } from "../../../services/syntax_highlight.js";
@@ -17,7 +17,6 @@ export const OPEN_SOURCE_LICENSE_KEY = "GPL";
export interface BuildEditorOptions {
forceGplLicense: boolean;
isClassicEditor: boolean;
uiLanguage: DISPLAYABLE_LOCALE_IDS;
contentLanguage: string | null;
templates: TemplateDefinition[];
}
@@ -162,8 +161,9 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfi
htmlSupport: {
allow: JSON.parse(options.get("allowedHtmlTags"))
},
removePlugins: getDisabledPlugins(),
...await getCkLocale(opts.uiLanguage)
// This value must be kept in sync with the language defined in webpack.config.js.
language: "en",
removePlugins: getDisabledPlugins()
};
// Set up content language.

View File

@@ -1,13 +0,0 @@
import link from "../../../services/link";
export async function applyReferenceLinks(container: HTMLDivElement | HTMLElement) {
const referenceLinks = container.querySelectorAll<HTMLDivElement>("a.reference-link");
for (const referenceLink of referenceLinks) {
await link.loadReferenceLinkTitle($(referenceLink));
// Wrap in a <span> to match the design while in CKEditor.
const spanEl = document.createElement("span");
spanEl.replaceChildren(...referenceLink.childNodes);
referenceLink.replaceChildren(spanEl);
}
}

View File

@@ -35,7 +35,7 @@
"@triliumnext/commons": "workspace:*",
"@triliumnext/server": "workspace:*",
"copy-webpack-plugin": "13.0.1",
"electron": "38.7.0",
"electron": "38.6.0",
"@electron-forge/cli": "7.10.2",
"@electron-forge/maker-deb": "7.10.2",
"@electron-forge/maker-dmg": "7.10.2",

View File

@@ -13,7 +13,7 @@
"devDependencies": {
"@types/better-sqlite3": "7.6.13",
"@types/mime-types": "3.0.1",
"@types/yargs": "17.0.35"
"@types/yargs": "17.0.34"
},
"scripts": {
"dev": "tsx src/main.ts",

View File

@@ -12,7 +12,7 @@
"@triliumnext/desktop": "workspace:*",
"@types/fs-extra": "11.0.4",
"copy-webpack-plugin": "13.0.1",
"electron": "38.7.0",
"electron": "38.6.0",
"fs-extra": "11.3.2"
},
"scripts": {

View File

@@ -1,4 +1,4 @@
FROM node:24.11.1-bullseye-slim AS builder
FROM node:24.11.0-bullseye-slim AS builder
RUN corepack enable
# Install native dependencies since we might be building cross-platform.
@@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
# We have to use --no-frozen-lockfile due to CKEditor patches
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
FROM node:24.11.1-bullseye-slim
FROM node:24.11.0-bullseye-slim
# Install only runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \

View File

@@ -1,4 +1,4 @@
FROM node:24.11.1-alpine AS builder
FROM node:24.11.0-alpine AS builder
RUN corepack enable
# Install native dependencies since we might be building cross-platform.
@@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
# We have to use --no-frozen-lockfile due to CKEditor patches
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
FROM node:24.11.1-alpine
FROM node:24.11.0-alpine
# Install runtime dependencies
RUN apk add --no-cache su-exec shadow

View File

@@ -1,4 +1,4 @@
FROM node:24.11.1-alpine AS builder
FROM node:24.11.0-alpine AS builder
RUN corepack enable
# Install native dependencies since we might be building cross-platform.
@@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
# We have to use --no-frozen-lockfile due to CKEditor patches
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
FROM node:24.11.1-alpine
FROM node:24.11.0-alpine
# Create a non-root user with configurable UID/GID
ARG USER=trilium
ARG UID=1001

View File

@@ -1,4 +1,4 @@
FROM node:24.11.1-bullseye-slim AS builder
FROM node:24.11.0-bullseye-slim AS builder
RUN corepack enable
# Install native dependencies since we might be building cross-platform.
@@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
# We have to use --no-frozen-lockfile due to CKEditor patches
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
FROM node:24.11.1-bullseye-slim
FROM node:24.11.0-bullseye-slim
# Create a non-root user with configurable UID/GID
ARG USER=trilium
ARG UID=1001

View File

@@ -30,7 +30,7 @@
"node-html-parser": "7.0.1"
},
"devDependencies": {
"@anthropic-ai/sdk": "0.69.0",
"@anthropic-ai/sdk": "0.68.0",
"@braintree/sanitize-url": "7.1.1",
"@electron/remote": "2.1.3",
"@preact/preset-vite": "2.10.2",
@@ -81,7 +81,7 @@
"debounce": "3.0.0",
"debug": "4.4.3",
"ejs": "3.1.10",
"electron": "38.7.0",
"electron": "38.6.0",
"electron-debug": "4.1.0",
"electron-window-state": "5.0.3",
"escape-html": "1.0.3",
@@ -98,19 +98,19 @@
"http-proxy-agent": "7.0.2",
"https-proxy-agent": "7.0.6",
"i18next": "25.6.2",
"i18next-fs-backend": "2.6.1",
"i18next-fs-backend": "2.6.0",
"image-type": "6.0.0",
"ini": "6.0.0",
"is-animated": "2.0.2",
"is-svg": "6.1.0",
"jimp": "1.6.0",
"js-yaml": "4.1.1",
"js-yaml": "4.1.0",
"marked": "16.4.2",
"mime-types": "3.0.1",
"multer": "2.0.2",
"normalize-strings": "1.1.1",
"ollama": "0.6.3",
"openai": "6.9.0",
"ollama": "0.6.2",
"openai": "6.8.1",
"rand-token": "1.0.1",
"safe-compare": "1.1.4",
"sanitize-filename": "1.6.3",

File diff suppressed because one or more lines are too long

View File

@@ -23,29 +23,6 @@
</ol>
<p>These attributes play a crucial role in organizing, categorizing, and
enhancing the functionality of notes.</p>
<h2>Types of attributes</h2>
<p>Conceptually there are two types of attributes (applying to both labels
and relations):</p>
<ol>
<li><strong>System attributes</strong>
<br>As the name suggest, these attributes have a special meaning since they
are interpreted by Trilium. For example the <code>color</code> attribute
will change the color of the note as displayed in the&nbsp;<a class="reference-link"
href="#root/_help_oPVyFC7WL2Lp">Note Tree</a>&nbsp;and links, and <code>iconClass</code> will
change the icon of a note.</li>
<li><strong>User-defined attributes</strong>
<br>These are free-form labels or relations that can be used by the user.
They can be used purely for categorization purposes (especially if combined
with&nbsp;<a class="reference-link" href="#root/_help_eIg8jdvaoNNd">Search</a>),
or they can be given meaning through the use of&nbsp;<a class="reference-link"
href="#root/_help_CdNpE2pqjmI6">Scripting</a>.</li>
</ol>
<p>In practice, Trilium makes no direct distinction of whether an attribute
is a system one or a user-defined one. A label or relation is considered
a system attribute if it matches one of the built-in names (e.g. like the
aforementioned <code>iconClass</code>). Keep this in mind when creating
&nbsp;<a class="reference-link" href="#root/_help_OFXdgB2nNk1F">Promoted Attributes</a>&nbsp;in
order not to accidentally alter a system attribute (unless intended).</p>
<h2>Viewing the list of attributes</h2>
<p>Both the labels and relations for the current note are displayed in the <em>Owned Attributes</em> section
of the&nbsp;<a class="reference-link" href="#root/_help_BlN9DFI679QC">Ribbon</a>,
@@ -54,14 +31,13 @@
only be viewed.</p>
<p>In the list of attributes, labels are prefixed with the <code>#</code> character
whereas relations are prefixed with the <code>~</code> character.</p>
<h2>Attribute Definitions and Promoted Attributes</h2>
<p><a class="reference-link" href="#root/_help_OFXdgB2nNk1F">Promoted Attributes</a>&nbsp;create
a form-like editing experience for attributes, which makes it easy to enhancing
the organization and management of attributes</p>
<h2>Multiplicity</h2>
<p>Attributes in Trilium can be "multi-valued", meaning multiple attributes
with the same name can co-exist. This can be combined with&nbsp;<a class="reference-link"
href="#root/_help_OFXdgB2nNk1F">Promoted Attributes</a>&nbsp;to easily add them.</p>
with the same name can co-exist.</p>
<h2>Attribute Definitions and Promoted Attributes</h2>
<p>Special labels create "label/attribute" definitions, enhancing the organization
and management of attributes. For more details, see&nbsp;<a class="reference-link"
href="#root/_help_OFXdgB2nNk1F">Promoted Attributes</a>.</p>
<h2>Attribute Inheritance</h2>
<p>Trilium supports attribute inheritance, allowing child notes to inherit
attributes from their parents. For more information, see&nbsp;<a class="reference-link"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -1,116 +1,31 @@
<figure class="image image_resized" style="width:61.4%;">
<img style="aspect-ratio:938/368;" src="Promoted Attributes_image.png"
width="938" height="368">
</figure>
<p>Promoted attributes are <a href="#root/_help_zEY4DaJG4YT5">attributes</a> which
are displayed prominently in the UI which allow them to be easily viewed
and edited.</p>
<p>One way of seeing promoted attributes is as a kind of form with several
fields. Each field is just regular attribute, the only difference is that
they appear on the note itself.</p>
are considered important and thus are "promoted" onto the main note UI.
See example below:</p>
<p>
<img src="Promoted Attributes_promot.png">
</p>
<p>You can see the note having kind of form with several fields. Each of
these is just regular attribute, the only difference is that they appear
on the note itself.</p>
<p>Attributes can be pretty useful since they allow for querying and script
automation etc. but they are also inconveniently hidden. This allows you
to select few of the important ones and push them to the front of the user.</p>
<p>Now, how do we make attribute to appear on the UI?</p>
<h2>Attribute definition</h2>
<p>In order to have promoted attributes, there needs to be a way to define
them.</p>
<figure class="image image-style-align-right image_resized" style="width:38.82%;">
<img style="aspect-ratio:492/346;" src="1_Promoted Attributes_image.png"
width="492" height="346">
</figure>
<p>Technically, attributes are only name-value pairs where both name and
value are strings.</p>
<p>The <em>Attribute definition</em> specifies how should this value be interpreted:</p>
<ul>
<li>Is it just string, or is it a date?</li>
<li>Should we allow multiple values or note?</li>
<li>Should we <em>promote</em> the attribute or not?</li>
</ul>
<h2>Creating a new promoted attribute definition</h2>
<p>To create a new promoted attribute:</p>
<ol>
<li>Go to a note.</li>
<li>Go to <em>Owned Attributes</em> in the&nbsp;<a class="reference-link" href="#root/_help_BlN9DFI679QC">Ribbon</a>.</li>
<li>Press the + button.</li>
<li>Select either <em>Add new label definition</em> or <em>Add new relation definition</em>.</li>
<li>Select the name which will be name of the label or relation that will
be created when the promoted attribute is edited.</li>
<li>Ensure <em>Promoted</em> is checked in order to display it at the top of
notes.</li>
<li>Optionally, choose an <em>Alias</em> which will be displayed next to the
promoted attribute instead of the attribute name. Generally it's best to
choose a “user-friendly” name since it can contain spaces and other characters
which are not supported as attribute names.</li>
<li>Check <em>Inheritable</em> to apply it to this note and all its descendants.
To keep it only for the current note, un-check it.</li>
<li>Press “Save &amp; Close” to apply the changes.</li>
</ol>
<h2>How attribute definitions actually work</h2>
<p>When a new promoted attribute definition is created, it creates a corresponding
label prefixed with either <code>label</code> or <code>relation</code>, depending
on the definition type:</p><pre><code class="language-text-x-trilium-auto">#label:myColor(inheritable)="promoted,alias=Color,multi,color"</code></pre>
<p>The only purpose of the attribute definition is to set up a template.
If the attribute was marked as promoted, then it's also displayed to the
user for easy editing.</p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<figure class="image">
<img style="aspect-ratio:495/157;" src="2_Promoted Attributes_image.png"
width="495" height="157">
</figure>
</td>
<td>Notice how the promoted attribute definition only creates a “Due date”
box above the text content.</td>
</tr>
<tr>
<td>
<figure class="image">
<img style="aspect-ratio:663/160;" src="3_Promoted Attributes_image.png"
width="663" height="160">
</figure>
</td>
<td>Once a value is set by the user, a new label (or relation, depending on
the type) is created. The name of the attribute matches one set when creating
the promoted attribute.</td>
</tr>
</tbody>
</table>
<p>Attribute is always name-value pair where both name and value are strings.</p>
<p><em>Attribute definition</em> specifies how should this value be interpreted
- is it just string, or is it a date? Should we allow multiple values or
note? And importantly, should we <em>promote</em> the attribute or not?</p>
<p>
<img src="Promoted Attributes_image.png">
</p>
<p>You can notice tag attribute definition. These "definition" attributes
define how the "value" attributes should behave.</p>
<p>So there's one attribute for value and one for definition. But notice
how an definition attribute can be made <a href="#root/_help_bwZpz2ajCEwO">Inheritable</a>,
meaning that it's also applied to all descendant notes. In this case, the
definition used for the whole sub-tree while "value" attributes are for
each not individually.</p>
<h2>Using system attributes</h2>
<p>It's possible to create promoted attributes out of system attributes,
to be able to easily alter them.</p>
<p>Here are a few practical examples:</p>
<ul>
<li><a class="reference-link" href="#root/_help_GTwFsgaA0lCt">Collections</a>&nbsp;already
make use of this practice, for example:
<ul>
<li>Calendars add “Start Date”, “End Date”, “Start Time” and “End Time” as
promoted attributes. These map to system attributes such as <code>startDate</code> which
are then interpreted by the calendar view.</li>
<li><a class="reference-link" href="#root/_help_zP3PMqaG71Ct">Presentation</a>&nbsp;adds
a “Background” promoted attribute for each of the slide to easily be able
to customize.</li>
</ul>
</li>
<li>The Trilium documentation (which is edited in Trilium) uses a promoted
attribute to be able to easily edit the <code>#shareAlias</code> (see&nbsp;
<a
class="reference-link" href="#root/_help_R9pX4DGra2Vt">Sharing</a>) in order to form clean URLs.</li>
<li>If you always edit a particular system attribute such as <code>#color</code>,
simply create a promoted attribute for it to make it easier.</li>
</ul>
how definition attribute is <a href="#root/_help_bwZpz2ajCEwO">Inheritable</a>,
meaning that it's also applied to all descendant note. So in a way, this
definition is used for the whole subtree while "value" attributes are applied
only for this note.</p>
<h3>Inverse relation</h3>
<p>Some relations always occur in pairs - my favorite example is on the family.
If you have a note representing husband and note representing wife, then
@@ -118,7 +33,7 @@
This is bidirectional relationship - meaning that if a relation is pointing
from husband to wife then there should be always another relation pointing
from wife to husband.</p>
<p>Another example is with parent-child relationship. Again these always
<p>Another example is with parent - child relationship. Again these always
occur in pairs, but in this case it's not exact same relation - the one
going from parent to child might be called <code>isParentOf</code> and the
other one going from child to parent might be called <code>isChildOf</code>.</p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -112,12 +112,6 @@
<td>When present (regardless of value), it will show the number of the week
on the calendar.</td>
</tr>
<tr>
<td><code>#calendar:initialDate</code>
</td>
<td>Change the date the calendar opens on. When not present, the calendar
opens on the current date.</td>
</tr>
<tr>
<td><code>#calendar:view</code>
</td>

View File

@@ -1,9 +1,8 @@
<aside class="admonition important">
<p><a class="reference-link" href="#root/_help_zEY4DaJG4YT5">Attributes</a><a class="reference-link"
href="#root/_help_OFXdgB2nNk1F">Promoted Attributes</a><a class="reference-link"
href="#root/_help_zEY4DaJG4YT5">Attributes</a>Starting with Trilium v0.97.0,
the geo map has been converted from a standalone <a href="#root/_help_KSZ04uQ2D1St">note type</a> to
a type of view for the&nbsp;<a class="reference-link" href="#root/_help_0ESUbbAxVnoK">Note List</a>.&nbsp;</p>
<p>Starting with Trilium v0.97.0, the geo map has been converted from a standalone
<a
href="#root/_help_KSZ04uQ2D1St">note type</a>to a type of view for the&nbsp;<a class="reference-link"
href="#root/_help_0ESUbbAxVnoK">Note List</a>.&nbsp;</p>
</aside>
<figure class="image image-style-align-center">
<img style="aspect-ratio:892/675;" src="9_Geo Map_image.png"
@@ -69,7 +68,7 @@
<td>To create a marker, first navigate to the desired point on the map. Then
press the
<img src="10_Geo Map_image.png">button in the&nbsp;<a href="#root/_help_XpOYSgsLkTJy">Floating buttons</a>&nbsp;(top-right)
area.&nbsp;&nbsp;&nbsp;&nbsp;
area.&nbsp;&nbsp;&nbsp;
<br>
<br>If the button is not visible, make sure the button section is visible
by pressing the chevron button (
@@ -83,7 +82,7 @@
width="1730" height="416">
</td>
<td>Once pressed, the map will enter in the insert mode, as illustrated by
the notification.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
the notification.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
<br>Simply click the point on the map where to place the marker, or the Escape
key to cancel.</td>
@@ -113,8 +112,7 @@
<li>Right click anywhere on the map, where to place the newly created marker
(and corresponding note).</li>
<li>Select <em>Add a marker at this location</em>.</li>
<li>Enter the name of the ne<a class="reference-link" href="#root/_help_oPVyFC7WL2Lp">Note Tree</a>wly
created note.</li>
<li>Enter the name of the newly created note.</li>
<li>The map should be updated with the new marker.</li>
</ol>
<h3>Adding an existing note on note from the note tree</h3>
@@ -223,10 +221,10 @@ width="1288" height="278">
</figure>
</td>
<td>Go to Google Maps on the web and look for a desired location, right click
on it and a context menu will show up.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
on it and a context menu will show up.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
<br>Simply click on the first item displaying the coordinates and they will
be copied to clipboard.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
be copied to clipboard.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
<br>Then paste the value inside the text box into the <code>#geolocation</code> attribute
of a child note of the map (don't forget to surround the value with a <code>"</code> character).</td>
@@ -284,7 +282,7 @@ width="1288" height="278">
width="696" height="480">
</td>
<td>The address will be visible in the top-left of the screen, in the place
of the search bar.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
of the search bar.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
<br>Select the coordinates and copy them into the clipboard.</td>
</tr>
@@ -341,7 +339,7 @@ width="1288" height="278">
width="620" height="530">
</figure>
</td>
<td>When going back to the map, the track should now be visible.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<td>When going back to the map, the track should now be visible.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
<br>The start and end points of the track are indicated by the two blue markers.</td>
</tr>

View File

@@ -1,5 +1,5 @@
<figure class="image">
<img style="aspect-ratio:918/248;" src="2_Kanban Board_image.png"
<img style="aspect-ratio:918/248;" src="Kanban Board_image.png"
width="918" height="248">
</figure>
<p>The Board view presents sub-notes in columns for a Kanban-like experience.
@@ -70,22 +70,7 @@
<li>If there are many notes within the column, move the mouse over the column
and use the mouse wheel to scroll.</li>
</ul>
<h3>Working with the note tree</h3>
<p>It's also possible to add items on the board using the&nbsp;<a class="reference-link"
href="#root/_help_oPVyFC7WL2Lp">Note Tree</a>.</p>
<ol>
<li>Select the desired note in the&nbsp;<a class="reference-link" href="#root/_help_oPVyFC7WL2Lp">Note Tree</a>.</li>
<li>Hold the mouse on the note and drag it to the to the desired column.</li>
</ol>
<p>This works for:</p>
<ul>
<li>Notes that are not children of the board, case in which a <a href="#root/_help_IakOLONlIfGI">clone</a> will
be created.</li>
<li>Notes that are children of the board, but not yet assigned on the board.</li>
<li>Notes that are children of the board, case in which they will be moved
to the new column.</li>
</ul>
<h3>Keyboard interaction</h3>
<h2>Keyboard interaction</h2>
<p>The board view has mild support for keyboard-based navigation:</p>
<ul>
<li>Use <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> to navigate between
@@ -97,81 +82,16 @@
<li>To dismiss a rename of a note or a column, press <kbd>Escape</kbd>.</li>
</ul>
<h2>Configuration</h2>
<h3>Displaying custom attributes</h3>
<figure class="image image-style-align-center">
<img style="aspect-ratio:531/485;" src="Kanban Board_image.png"
width="531" height="485">
</figure>
<p>Note attributes can be displayed on the board to enhance it with custom
information such as adding a Due date for your tasks.</p>
<p>This feature works exclusively via attribute definitions (<a class="reference-link"
href="#root/_help_OFXdgB2nNk1F">Promoted Attributes</a>). The easiest way to
add these is:</p>
<ol>
<li>Go to board note.</li>
<li>In the ribbon select <em>Owned Attributes</em> → plus button → <em>Add new label/relation definition</em>.</li>
<li>Configure the attribute as desired.</li>
<li>Check <em>Inheritable</em> to make it applicable to child notes automatically.</li>
</ol>
<p>After creating the attribute, click on a note and fill in the promoted
attributes which should then reflect inside the board.</p>
<p>Of note:</p>
<ul>
<li>Both promoted and non-promoted attribute definitions are supported. The
only difference is that non-promoted attributes don't have an “Alias” for
assigning a custom name.</li>
<li>Both “Single value” and “Multi value” attributes are supported. In case
of multi-value, a badge is displayed for every instance of the attribute.</li>
<li>All label types are supported, including dates, booleans and URLs.</li>
<li>Relation attributes are also supported as well, showing a link with the
target note title and icon.</li>
<li>Currently, it's not possible to adjust which promoted attributes are displayed,
since all promoted attributes will be displayed (except the <code>board:groupBy</code> one).
There are plans to improve upon this being able to hide promoted attributes
individually.</li>
</ul>
<h3>Grouping by another label</h3>
<h3>Grouping by another attribute</h3>
<p>By default, the label used to group the notes is <code>#status</code>.
It is possible to use a different label if needed by defining a label named <code>#board:groupBy</code> with
the value being the attribute to use (with or without <code>#</code> attribute
prefix).</p>
<h3>Grouping by relations</h3>
<figure class="image image-style-align-right">
<img style="aspect-ratio:535/245;" src="1_Kanban Board_image.png"
width="535" height="245">
</figure>
<p>A more advanced use-case is grouping by <a href="#root/_help_Cq5X6iKQop6R">Relations</a>.</p>
<p>During this mode:</p>
<ul>
<li>The columns represent the <em>target notes</em> of a relation.</li>
<li>When creating a new column, a note is selected instead of a column name.</li>
<li>The column icon will match the target note.</li>
<li>Moving notes between columns will change its relation.</li>
<li>Renaming an existing column will change the target note of all the notes
in that column.</li>
</ul>
<p>Using relations instead of labels has some benefits:</p>
<ul>
<li>The status/grouping of the notes is visible outside the Kanban board,
for example on the&nbsp;<a class="reference-link" href="#root/_help_bdUJEHsAPYQR">Note Map</a>.</li>
<li>Columns can have icons.</li>
<li>Renaming columns is less intensive since it simply involves changing the
note title of the target note instead of having to do a bulk rename.</li>
</ul>
<p>To do so:</p>
<ol>
<li>
<p>First, create a Kanban board from scratch and not a template:</p>
</li>
<li>
<p>Assign <code>#viewType=board #hidePromotedAttributes</code> to emulate the
default template.</p>
</li>
<li>
<p>Set <code>#board:groupBy</code> to the name of a relation to group by, <strong>including the</strong> <code>**~**</code> <strong>prefix</strong> (e.g. <code>~status</code>).</p>
</li>
<li>
<p>Optionally, use&nbsp;<a class="reference-link" href="#root/_help_OFXdgB2nNk1F">Promoted Attributes</a>&nbsp;for
easy status change within the note:</p><pre><code class="language-text-x-trilium-auto">#relation:status(inheritable)="promoted,alias=Status,single"</code></pre>
</li>
</ol>
the value being the attribute to use (without <code>#</code> attribute prefix).</p>
<aside
class="admonition note">
<p>It's currently not possible to set a relation as the grouping criteria.
There are plans to add support for it.</p>
</aside>
<h2>Limitations</h2>
<ul>
<li>It is not possible yet to use group by a relation, only by label.</li>
</ul>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -135,7 +135,7 @@ docker run -d --name trilium -p 8080:8080 --user $(id -u):$(id -g) -v ~/trilium-
(default: <code>/home/node/trilium-data</code>)</li>
</ul>
<p>For a complete list of configuration environment variables (network settings,
authentication, sync, etc.), see&nbsp;<a class="reference-link" href="#root/_help_Gzjqa934BdH4">Configuration (config.ini or environment variables)</a>.</p>
authentication, sync, etc.), see <a class="reference-link" href="#root/_help_dmi3wz9muS2O">Configuration (config.ini or environment variables)</a>.</p>
<h3>Volume Permissions</h3>
<p>If you encounter permission issues with the data volume, ensure that:</p>
<ol>

View File

@@ -1,48 +0,0 @@
<p>Configure Traefik proxy and HTTPS. See <a href="https://github.com/TriliumNext/Trilium/issues/7768#issuecomment-3539165814">#7768</a> for
reference</p>
<h3>Build the docker-compose file</h3>
<p>Setting up Traefik as reverse proxy requires setting the following labels:</p><pre><code class="language-text-x-yaml"> labels:
- traefik.enable=true
- traefik.http.routers.trilium.entrypoints=https
- traefik.http.routers.trilium.rule=Host(`trilium.mydomain.tld`)
- traefik.http.routers.trilium.tls=true
- traefik.http.routers.trilium.service=trilium
- traefik.http.services.trilium.loadbalancer.server.port=8080
# scheme must be HTTP instead of the usual HTTPS because Trilium listens on HTTP internally
- traefik.http.services.trilium.loadbalancer.server.scheme=http
- traefik.docker.network=proxy
# forward HTTP to HTTPS
- traefik.http.routers.trilium.middlewares=trilium-headers@docker
- traefik.http.middlewares.trilium-headers.headers.customrequestheaders.X-Forwarded-Proto=https</code></pre>
<h3>Setup needed environment variables</h3>
<p>After setting up a reverse proxy, make sure to configure the&nbsp;<a class="reference-link"
href="Trusted%20proxy.md">[missing note]</a>.</p>
<h3>Example <code>docker-compose.yaml</code></h3><pre><code class="language-text-x-yaml">services:
trilium:
image: triliumnext/trilium
container_name: trilium
networks:
- traefik-proxy
environment:
- TRILIUM_NETWORK_TRUSTEDREVERSEPROXY=my-traefik-host-ip # e.g., 172.18.0.0/16
volumes:
- /path/to/data:/home/node/trilium-data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
labels:
- traefik.enable=true
- traefik.http.routers.trilium.entrypoints=https
- traefik.http.routers.trilium.rule=Host(`trilium.mydomain.tld`)
- traefik.http.routers.trilium.tls=true
- traefik.http.routers.trilium.service=trilium
- traefik.http.services.trilium.loadbalancer.server.port=8080
# scheme must be HTTP instead of the usual HTTPS because of how trilium works
- traefik.http.services.trilium.loadbalancer.server.scheme=http
- traefik.docker.network=traefik-proxy
# Tell Trilium the original request was HTTPS
- traefik.http.routers.trilium.middlewares=trilium-headers@docker
- traefik.http.middlewares.trilium-headers.headers.customrequestheaders.X-Forwarded-Proto=https
networks:
traefik-proxy:
external: true</code></pre>

View File

@@ -258,9 +258,7 @@
"jump-to-note-title": "跳转至...",
"llm-chat-title": "与笔记聊天",
"ai-llm-title": "AI/LLM",
"inbox-title": "收件箱",
"command-palette": "打开命令面板",
"zen-mode": "禅模式"
"inbox-title": "收件箱"
},
"notes": {
"new-note": "新建笔记",

View File

@@ -43,26 +43,6 @@
},
"hidden-subtree": {
"zen-mode": "젠 모드",
"open-today-journal-note-title": "오늘의 일지 기록 열기",
"quick-search-title": "빠른 검색",
"protected-session-title": "보호된 세션",
"sync-status-title": "동기화 상태",
"settings-title": "설정",
"llm-chat-title": "기록과 대화하기",
"options-title": "옵션",
"appearance-title": "모양",
"shortcuts-title": "바로가기",
"text-notes": "텍스트 노트",
"code-notes-title": "코드 노트",
"images-title": "그림",
"spellcheck-title": "맞춤법 검사",
"password-title": "암호",
"multi-factor-authentication-title": "다중 인증",
"etapi-title": "ETAPI",
"backup-title": "백업",
"sync-title": "동기화",
"ai-llm-title": "AI/LLM",
"other": "기타",
"advanced-title": "고급"
"open-today-journal-note-title": "오늘의 일지 기록 열기"
}
}

View File

@@ -256,9 +256,7 @@
"multi-factor-authentication-title": "Autentificare multi-factor",
"ai-llm-title": "AI/LLM",
"localization": "Limbă și regiune",
"inbox-title": "Inbox",
"command-palette": "Deschide paleta de comenzi",
"zen-mode": "Mod zen"
"inbox-title": "Inbox"
},
"notes": {
"new-note": "Notiță nouă",
@@ -276,8 +274,7 @@
"export_filter": "Document PDF (*.pdf)",
"unable-to-export-message": "Notița curentă nu a putut fi exportată ca PDF.",
"unable-to-export-title": "Nu s-a putut exporta ca PDF",
"unable-to-save-message": "Nu s-a putut scrie fișierul selectat. Încercați din nou sau selectați altă destinație.",
"unable-to-print": "Nu s-a putut imprima notița"
"unable-to-save-message": "Nu s-a putut scrie fișierul selectat. Încercați din nou sau selectați altă destinație."
},
"tray": {
"bookmarks": "Semne de carte",
@@ -430,8 +427,7 @@
"presentation": "Prezentare",
"presentation_slide": "Slide de prezentare",
"presentation_slide_first": "Primul slide",
"presentation_slide_second": "Al doilea slide",
"background": "Fundal"
"presentation_slide_second": "Al doilea slide"
},
"sql_init": {
"db_not_initialized_desktop": "Baza de date nu este inițializată, urmați instrucțiunile de pe ecran.",

View File

@@ -355,9 +355,7 @@
"visible-launchers-title": "可見啟動器",
"user-guide": "用戶說明",
"localization": "語言和區域",
"inbox-title": "收件匣",
"command-palette": "打開命令面板",
"zen-mode": "禪模式"
"inbox-title": "收件匣"
},
"notes": {
"new-note": "新增筆記",

View File

@@ -91,12 +91,9 @@ function validateUtcDateTime(str: string | undefined) {
}
export default {
LOCAL_DATETIME_FORMAT,
UTC_DATETIME_FORMAT,
utcNowDateTime,
localNowDateTime,
localNowDate,
utcDateStr,
utcDateTimeStr,
parseDateTime,

View File

@@ -1,10 +1,8 @@
import dayjs from "dayjs";
import sax from "sax";
import stream from "stream";
import { Throttle } from "stream-throttle";
import log from "../log.js";
import { md5, escapeHtml, fromBase64 } from "../utils.js";
import date_utils from "../date_utils.js";
import sql from "../sql.js";
import noteService from "../notes.js";
import imageService from "../image.js";
@@ -237,8 +235,6 @@ function importEnex(taskContext: TaskContext<"importNotes">, file: File, parentN
function updateDates(note: BNote, utcDateCreated?: string, utcDateModified?: string) {
// it's difficult to force custom dateCreated and dateModified to Note entity, so we do it post-creation with SQL
const dateCreated = formatDateTimeToLocalDbFormat(utcDateCreated, false);
const dateModified = formatDateTimeToLocalDbFormat(utcDateModified, false);
sql.execute(
`
UPDATE notes
@@ -247,7 +243,7 @@ function importEnex(taskContext: TaskContext<"importNotes">, file: File, parentN
dateModified = ?,
utcDateModified = ?
WHERE noteId = ?`,
[dateCreated, utcDateCreated, dateModified, utcDateModified, note.noteId]
[utcDateCreated, utcDateCreated, utcDateModified, utcDateModified, note.noteId]
);
sql.execute(
@@ -411,21 +407,4 @@ function importEnex(taskContext: TaskContext<"importNotes">, file: File, parentN
});
}
function formatDateTimeToLocalDbFormat(
utcDateFromEnex: Date | string | null | undefined,
keepUtc: boolean
): string | undefined {
if (!utcDateFromEnex) {
return undefined;
}
const parsedDate = dayjs(utcDateFromEnex);
if (!parsedDate.isValid()) {
return undefined;
}
return (keepUtc ? parsedDate.utc() : parsedDate).format(date_utils.LOCAL_DATETIME_FORMAT);
}
export default { importEnex };

View File

@@ -113,16 +113,7 @@ class NoteContentFulltextExp extends Expression {
const normalizedFlatText = normalizeSearchText(flatText);
// Check if =phrase appears in flatText (indicates attribute value match)
// For single words, use word-boundary matching to avoid substring matches
if (!normalizedPhrase.includes(' ')) {
// Single word: look for =word with word boundaries
// Split by = to get attribute values, then check each value for exact word match
const parts = normalizedFlatText.split('=');
matches = parts.slice(1).some(part => this.exactWordMatch(normalizedPhrase, part));
} else {
// Multi-word phrase: check for substring match
matches = normalizedFlatText.includes(`=${normalizedPhrase}`);
}
matches = normalizedFlatText.includes(`=${normalizedPhrase}`);
if ((this.operator === "=" && matches) || (this.operator === "!=" && !matches)) {
resultNoteSet.add(noteFromBecca);
@@ -133,17 +124,6 @@ class NoteContentFulltextExp extends Expression {
return resultNoteSet;
}
/**
* Helper method to check if a single word appears as an exact match in text
* @param wordToFind - The word to search for (should be normalized)
* @param text - The text to search in (should be normalized)
* @returns true if the word is found as an exact match (not substring)
*/
private exactWordMatch(wordToFind: string, text: string): boolean {
const words = text.split(/\s+/);
return words.some(word => word === wordToFind);
}
/**
* Checks if content contains the exact word (with word boundaries) or exact phrase
* This is case-insensitive since content and token are already normalized
@@ -159,8 +139,9 @@ class NoteContentFulltextExp extends Expression {
return normalizedContent.includes(normalizedToken);
}
// For single words, use exact word matching to avoid substring matches
return this.exactWordMatch(normalizedToken, normalizedContent);
// For single words, split content into words and check for exact match
const words = normalizedContent.split(/\s+/);
return words.some(word => word === normalizedToken);
}
/**
@@ -174,14 +155,7 @@ class NoteContentFulltextExp extends Expression {
// Join tokens with single space to form the phrase
const phrase = normalizedTokens.join(" ");
// For single-word phrases, use word-boundary matching to avoid substring matches
// e.g., "asd" should not match "asdfasdf"
if (!phrase.includes(' ')) {
// Single word: use exact word matching to avoid substring matches
return this.exactWordMatch(phrase, normalizedContent);
}
// For multi-word phrases, check if the phrase appears as consecutive words
// Check if the phrase appears as a substring (consecutive words)
if (normalizedContent.includes(phrase)) {
return true;
}

View File

@@ -5,7 +5,6 @@ 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";
describe("Tree", () => {
let rootNote!: NoteBuilder;
@@ -74,43 +73,4 @@ describe("Tree", () => {
expect(order).toStrictEqual(expectedOrder);
}
});
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": "" }
],
"#sorted": ""
});
cls.init(() => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
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": "" }
],
"#sorted": "",
"#sortDirection": "desc"
});
cls.init(() => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual([ "top", "5", "3", "2", "1", "bottom" ]);
});
});

View File

@@ -136,8 +136,8 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
const topBEl = fetchValue(b, "top");
if (topAEl !== topBEl) {
if (topAEl === null) return reverse ? -1 : 1;
if (topBEl === null) return reverse ? 1 : -1;
if (topAEl === null) return 1;
if (topBEl === null) return -1;
// since "top" should not be reversible, we'll reverse it once more to nullify this effect
return compare(topAEl, topBEl) * (reverse ? -1 : 1);
@@ -147,8 +147,8 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
const bottomBEl = fetchValue(b, "bottom");
if (bottomAEl !== bottomBEl) {
if (bottomAEl === null) return reverse ? 1 : -1;
if (bottomBEl === null) return reverse ? -1 : 1;
if (bottomAEl === null) return -1;
if (bottomBEl === null) return 1;
// since "bottom" should not be reversible, we'll reverse it once more to nullify this effect
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);

View File

@@ -342,11 +342,8 @@ async function registerGlobalShortcuts() {
return;
}
if (action.actionName === "toggleTray") {
targetWindow.focus();
} else {
showAndFocusWindow(targetWindow);
}
// window may be hidden / not in focus
showAndFocusWindow(targetWindow);
targetWindow.webContents.send("globalShortcut", action.actionName);
})

View File

@@ -14,7 +14,7 @@
"preact": "10.27.2",
"preact-iso": "2.11.0",
"preact-render-to-string": "6.6.3",
"react-i18next": "16.3.3"
"react-i18next": "16.2.4"
},
"devDependencies": {
"@preact/preset-vite": "2.10.2",

View File

@@ -1,20 +1,6 @@
{
"hero_section": {
"github": "깃허브",
"dockerhub": "도커 허브",
"get_started": "시작하기",
"title": "생각을 정리하고, 개인 지식 기반을 구축하세요.",
"subtitle": "Trilium은 개인 지식 베이스를 정리하고 노트를 작성하는 오픈소스 솔루션입니다. 데스크톱에서 로컬로 사용하거나, 자체 호스팅 서버와 동기화하여 어디에서나 노트를 보관할 수 있습니다.",
"screenshot_alt": "Trilium Notes 데스크톱 애플리케이션의 스크린샷"
},
"get-started": {
"title": "시작하기",
"desktop_title": "데스크탑 애플리케이션 내려받기 (v{{version}})",
"older_releases": "오래된 릴리즈 보기",
"architecture": "아키텍쳐:",
"server_title": "여러 기기에서 액세스할 수 있는 서버 설정"
},
"download_now": {
"text": "지금 내려받기 "
"dockerhub": "도커 허브"
}
}

View File

@@ -51,7 +51,7 @@
"mermaid_description": "Twórz diagramy, takie jak schematy blokowe, diagramy klas i sekwencyjne, wykresy Gantta i wiele innych, korzystając z składni Mermaid.",
"mindmap_title": "Mapy myśli",
"mindmap_description": "Organizuj wizualnie swoje myśli albo przeprowadź sesję burzy mózgów.",
"others_list": "I wiele innych: <0>mapa notatek</0>, <1>mapa powiązań</1>, <2>zapisane wyszukiwania</2>, <3>renderowane notatki</3> i <4>podgląd stron www</4>.",
"others_list": "I wiele innych: <0>mapa notatek</0>, <1>mapa powiązań</1>, <2>zapisane wyszukiwania</2>, <3>renderowane notatki</3>, and <4>podgląd stron www</4>.",
"title": "Wiele sposobów przedstawienia Twoich informacji"
},
"extensibility_benefits": {
@@ -132,7 +132,7 @@
"title": "Inne sposoby wsparcia",
"way_translate": "Przetłumacz aplikacja na swój natywny język przez <Link>Weblate</Link>.",
"way_community": "Dołącz do społeczności na <Discussions>GitHub Discussions</Discussions> lub na <Matrix>Matrix</Matrix>.",
"way_reports": "Zgłoś błędy przez <Link>GitHub issues</Link>.",
"way_reports": "Zgłoś błędy przez<Link>GitHub issues</Link>.",
"way_document": "Pomóż nam w doskonaleniu dokumentacji przez informowanie nas o lukach albo sam pomóż w tworzeniu treści (dokumentacja, FAQ, poradniki).",
"way_market": "Powiedz o nas swoim znajomym, na blogu albo na social mediach."
},

View File

@@ -51,8 +51,7 @@
"mermaid_description": "Creați diagrame precum flowchart-uri, diagrame de secvență sau de clase, Gantt și multe altele, folosind sintaxa Mermaid.",
"mindmap_title": "Hartă mentală",
"mindmap_description": "Organizați-vă gândurile vizual sau organizați o sesiune de brainstorming.",
"others_list": "și altele: <0>hartă a notițelor</0>, <1>hartă a relațiilor</1>, <2>căutări salvate</2>, <3>randare a notițelor</3>, și <4>vizualizări web</4>.",
"title": "Multiple modalități de a reprezenta informația"
"others_list": "și altele: <0>hartă a notițelor</0>, <1>hartă a relațiilor</1>, <2>căutări salvate</2>, <3>randare a notițelor</3>, și <4>vizualizări web</4>."
},
"extensibility_benefits": {
"title": "Partajare și extensibilitate",
@@ -73,10 +72,7 @@
"board_title": "Tabelă Kanban",
"board_description": "Organizați-vă sarcinile sau proiectele într-o tabelă Kanban cu o modalitate ușoară de a adăuga elemente și coloane noi și schimbarea stării acestora prin glisare cu mouse-ul.",
"geomap_title": "Hartă geografică",
"geomap_description": "Planificați-vă vacanțele sau marcați-vă punctele de interes direct pe o hartă geografică. Afișați traseele GPX înregistrate pentru a putea urmări itinerarii.",
"title": "Colecții",
"presentation_title": "Prezentare",
"presentation_description": "Organizați informația în diapozitive și prezentați-le pe tot ecranul, cu tranziții fine. Diapozitivele pot fi ulterior exportate ca PDF pentru o partajare ușoară."
"geomap_description": "Planificați-vă vacanțele sau marcați-vă punctele de interes direct pe o hartă geografică. Afișați traseele GPX înregistrate pentru a putea urmări itinerarii."
},
"faq": {
"title": "Întrebări frecvente",

Some files were not shown because too many files have changed in this diff Show More