Skip to content

Build your personal knowledge base with Trilium Notes

client/options/code notes: rewrite the "Available MIME types" section, allow custom ordering

Adorian Dorand4209e5e1950
diff --git a/apps/client/src/services/mime_types.spec.ts b/apps/client/src/services/mime_types.spec.ts
index 538ad3e4f4..156a8d70e4 100644
--- a/apps/client/src/services/mime_types.spec.ts
+++ b/apps/client/src/services/mime_types.spec.ts
@@ -1,4 +1,6 @@
-import { MIME_TYPE_AUTO, MIME_TYPES_DICT, normalizeMimeTypeForCKEditor } from "@triliumnext/commons";
+import {
+ MIME_TYPE_AUTO, MIME_TYPES_DICT, normalizeMimeTypeForCKEditor, resolveEnabledMimeTypes
+} from "@triliumnext/commons";
import { describe, expect, it, vi } from "vitest";
// Wrap the real `normalizeMimeTypeForCKEditor` in a spy so we can observe how many
@@ -16,7 +18,9 @@ vi.mock("@triliumnext/commons", async (importOriginal) => {
});
import options from "./options.js";
-import mimeTypesService, { getHighlightJsNameForMime } from "./mime_types.js";
+import mimeTypesService, {
+ getHighlightJsNameForMime, orderEnabledMimeTypes
+} from "./mime_types.js";
describe("mime_types service", () => {
it("getMimeTypes loads lazily, defaults to the dict's `default` set, and always enables text/plain", () => {
@@ -101,6 +105,19 @@ describe("mime_types service", () => {
expect(normalizeSpy).not.toHaveBeenCalled();
});
+ it("getEnabledMimeTypes follows the stored order unless sorting is on", () => {
+ options.getJson = vi.fn(() => [ "text/x-python", "text/css" ]) as typeof options.getJson;
+ mimeTypesService.loadMimeTypes();
+
+ options.is = vi.fn(() => false) as typeof options.is;
+ expect(mimeTypesService.getEnabledMimeTypes().map((mt) => mt.mime))
+ .toEqual([ "text/plain", "text/x-python", "text/css" ]);
+
+ options.is = vi.fn(() => true) as typeof options.is;
+ expect(mimeTypesService.getEnabledMimeTypes().map((mt) => mt.mime))
+ .toEqual([ "text/plain", "text/css", "text/x-python" ]);
+ });
+
it("re-exports MIME_TYPE_AUTO and the public helpers", () => {
expect(mimeTypesService.MIME_TYPE_AUTO).toBe(MIME_TYPE_AUTO);
expect(typeof mimeTypesService.getMimeTypes).toBe("function");
@@ -108,3 +125,33 @@ describe("mime_types service", () => {
expect(mimeTypesService.getHighlightJsNameForMime).toBe(getHighlightJsNameForMime);
});
});
+
+describe("orderEnabledMimeTypes", () => {
+ const ordered = (order: (string | null)[] | null, isSortedAlphabetically: boolean) =>
+ orderEnabledMimeTypes(resolveEnabledMimeTypes(order), order, isSortedAlphabetically)
+ .map((mt) => mt.mime);
+
+ it("sorts by title with plain text first, wherever the stored order places it", () => {
+ expect(ordered([ "text/x-python", "text/plain", "text/css", "text/x-csrc" ], true))
+ .toEqual([ "text/plain", "text/x-csrc", "text/css", "text/x-python" ]);
+ });
+
+ it("keeps the stored order, with plain text first unless it was placed elsewhere", () => {
+ expect(ordered([ "text/x-python", "text/css" ], false))
+ .toEqual([ "text/plain", "text/x-python", "text/css" ]);
+ expect(ordered([ "text/x-python", "text/plain", "text/css" ], false))
+ .toEqual([ "text/x-python", "text/plain", "text/css" ]);
+ });
+
+ it("leaves out unknown and repeated entries", () => {
+ expect(ordered([ "text/x-python", null, "text/x-unknown", "text/x-python" ], false))
+ .toEqual([ "text/plain", "text/x-python" ]);
+ });
+
+ it("sorts the default MIME types when nothing is stored", () => {
+ const mimes = ordered(null, false);
+ expect(mimes[0]).toBe("text/plain");
+ expect(mimes).toContain("text/x-python");
+ expect(mimes.slice(1)).toEqual(ordered(null, true).slice(1));
+ });
+});
diff --git a/apps/client/src/services/mime_types.ts b/apps/client/src/services/mime_types.ts
index 81afd6152c..0a49a94cff 100644
--- a/apps/client/src/services/mime_types.ts
+++ b/apps/client/src/services/mime_types.ts
@@ -6,6 +6,9 @@ import {
import { t } from "./i18n.js";
import options from "./options.js";
+/** The MIME type of plain text, which is always enabled. */
+export const PLAIN_TEXT_MIME = "text/plain";
+
// Titles that are descriptive names rather than language identifiers, so they get localized here
// (the shared MIME dict in commons has no access to the client's i18n).
const TRANSLATED_TITLES: Record<string, string> = {
@@ -33,6 +36,46 @@ function getMimeTypes(): MimeType[] {
return mimeTypes as MimeType[];
}
+/** The enabled MIME types, in the order the code language lists show them. */
+function getEnabledMimeTypes(): MimeType[] {
+ return orderEnabledMimeTypes(
+ getMimeTypes(),
+ options.getJson("codeNotesMimeTypes"),
+ options.is("codeNotesMimeTypesSortAlphabetically")
+ );
+}
+
+/**
+ * Returns the enabled entries of `mimeTypes` in display order. Plain text comes first, except in a
+ * stored order that places it elsewhere.
+ *
+ * @param order the `codeNotesMimeTypes` option. Without it, the entries are sorted.
+ * @param isSortedAlphabetically sorts the entries by title instead of following `order`.
+ */
+export function orderEnabledMimeTypes(
+ mimeTypes: readonly MimeType[],
+ order: readonly (string | null)[] | null | undefined,
+ isSortedAlphabetically: boolean
+): MimeType[] {
+ const enabled = mimeTypes.filter((mimeType) => mimeType.enabled);
+ const plainText = enabled.find((mimeType) => mimeType.mime === PLAIN_TEXT_MIME);
+
+ let ordered: MimeType[];
+ if (isSortedAlphabetically || !order) {
+ ordered = enabled
+ .filter((mimeType) => mimeType !== plainText)
+ .sort((a, b) => a.title.localeCompare(b.title));
+ } else {
+ const byMime = new Map(enabled.map((mimeType) => [ mimeType.mime, mimeType ]));
+ ordered = [ ...new Set(order) ].flatMap((mime) => (mime && byMime.get(mime)) || []);
+ }
+
+ if (plainText && !ordered.includes(plainText)) {
+ ordered.unshift(plainText);
+ }
+ return ordered;
+}
+
let mimeToHighlightJsMapping: Record<string, string> | null = null;
/**
@@ -62,6 +105,7 @@ export function getHighlightJsNameForMime(mimeType: string) {
export default {
MIME_TYPE_AUTO,
getMimeTypes,
+ getEnabledMimeTypes,
loadMimeTypes,
getHighlightJsNameForMime
};
diff --git a/apps/client/src/services/note_types.ts b/apps/client/src/services/note_types.ts
index 81715f278c..af6cf17a08 100644
--- a/apps/client/src/services/note_types.ts
+++ b/apps/client/src/services/note_types.ts
@@ -336,8 +336,8 @@ function getBlankNoteTypes(command?: TreeCommandNames): MenuCommandItem<TreeComm
*/
function getCodeLanguageItems(command?: TreeCommandNames): MenuItem<TreeCommandNames>[] {
mimeTypes.loadMimeTypes();
- const languages = mimeTypes.getMimeTypes()
- .filter((mimeType) => mimeType.enabled && mimeType.mime !== MARKDOWN_NOTE_TYPE_MIME)
+ const languages = mimeTypes.getEnabledMimeTypes()
+ .filter((mimeType) => mimeType.mime !== MARKDOWN_NOTE_TYPE_MIME)
.map<MenuItem<TreeCommandNames>>((mimeType) => ({
title: escapeHtml(mimeType.title),
uiIcon: getCodeLanguageIcon(mimeType),
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 25c7ee9ef5..23f89c0148 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1981,7 +1981,17 @@
"tooltip_syntax_highlighting": "Syntax highlighting",
"tooltip_code_block_syntax": "Code blocks in Text notes",
"tooltip_code_note_syntax": "Code notes",
- "trilium_log": "Trilium Log"
+ "trilium_log": "Trilium Log",
+ "description": "The languages offered when you choose the language of a code note or a code block.",
+ "sort_alphabetically": "Sort alphabetically",
+ "badge_code_blocks": "Code blocks",
+ "badge_code_notes": "Code notes",
+ "remove": "Remove from the list",
+ "badge_code_blocks_tooltip": "Syntax highlighting available for code blocks in text notes",
+ "badge_code_notes_tooltip": "Syntax highlighting available for code notes",
+ "add_title": "Add a language",
+ "add_another_one": "Add another language ({{count}} available)",
+ "add_another_other": "Add another language ({{count}} available)"
},
"vim_key_bindings": {
"use_vim_keybindings_in_code_notes": "Vim keybindings",
diff --git a/apps/client/src/widgets/dialogs/item_picker.spec.tsx b/apps/client/src/widgets/dialogs/item_picker.spec.tsx
index 8bd910fe44..601d5045e6 100644
--- a/apps/client/src/widgets/dialogs/item_picker.spec.tsx
+++ b/apps/client/src/widgets/dialogs/item_picker.spec.tsx
@@ -1,3 +1,4 @@
+import type { Tooltip } from "bootstrap";
import { render } from "preact";
import { act } from "preact/test-utils";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -6,11 +7,32 @@ import Component from "../../components/component";
import { ParentComponent } from "../react/react_utils";
import ItemPickerDialog, { type ItemPickerDialogOptions, type PickerItem } from "./item_picker";
+const mocks = vi.hoisted(() => ({
+ /** Every tooltip `useStaticTooltip` attached, so a test can ask one for its title. */
+ tooltips: [] as { element: Element, config: Partial<Tooltip.Options> }[]
+}));
+
// i18next is never initialised under test, so the built-in title and placeholder are undefined.
vi.mock("../../services/i18n", () => ({
t: (key: string) => key
}));
+// Attaches from an effect with the real hook's dependencies, so an element that is not rendered
+// yet when the effect runs gets no tooltip, as in the app.
+vi.mock("../react/hooks", async (importOriginal) => {
+ const { useEffect } = await import("preact/hooks");
+ return {
+ ...(await importOriginal<typeof import("../react/hooks")>()),
+ useStaticTooltip: (ref: { current: Element | null }, config?: Partial<Tooltip.Options>) => {
+ useEffect(() => {
+ if (ref.current && config) {
+ mocks.tooltips.push({ element: ref.current, config });
+ }
+ }, [ ref, config ]);
+ }
+ };
+});
+
const GROUPS = [
{
key: "fruit",
@@ -103,6 +125,25 @@ describe("ItemPickerDialog", () => {
expect(picked).toEqual([ GROUPS[1].items[1] ]);
});
+ it("shows the tooltip of an item that has one", async () => {
+ await open({ items: [
+ { key: "one", caption: "One", tooltip: "<strong>First</strong>" },
+ { key: "two", caption: "Two" }
+ ] });
+
+ const one = item("One");
+ const config = mocks.tooltips.find(({ element, config: candidate }) =>
+ one && element.contains(one)
+ && typeof candidate.selector === "string" && one.matches(candidate.selector))?.config;
+ expect(config).toBeDefined();
+ expect(item("Two")?.matches(String(config?.selector))).toBe(false);
+
+ const title = config?.title;
+ expect(typeof title === "function" && one ? title.call(one) : undefined)
+ .toBe("<strong>First</strong>");
+ expect(config?.html).toBe(true);
+ });
+
describe("searching", () => {
/** Folded rather than unmounted, so the list collapses over what was filtered out. */
it("folds away everything that does not match", async () => {
diff --git a/apps/client/src/widgets/dialogs/item_picker.tsx b/apps/client/src/widgets/dialogs/item_picker.tsx
index 250a515d81..7abd0c79fe 100644
--- a/apps/client/src/widgets/dialogs/item_picker.tsx
+++ b/apps/client/src/widgets/dialogs/item_picker.tsx
@@ -1,5 +1,6 @@
import "./item_picker.css";
+import type { Tooltip } from "bootstrap";
import clsx from "clsx";
import { useMemo, useRef, useState } from "preact/hooks";
@@ -8,7 +9,7 @@ import { t } from "../../services/i18n";
import { Card } from "../react/Card";
import { FilterProvider, filterRoleClass, useFilterMatch, useFilterState } from "../react/filter";
import SettingsSearch from "../type_widgets/options/components/SettingsSearch";
-import { useDebouncedValue, useTriliumEvent } from "../react/hooks";
+import { useDebouncedValue, useStaticTooltip, useTriliumEvent } from "../react/hooks";
import Icon from "../react/Icon";
import Modal from "../react/Modal";
import NoItems from "../react/NoItems";
@@ -19,6 +20,8 @@ export interface PickerItem {
caption: string;
/** An icon class, `bx` prefix included. */
icon?: string;
+ /** HTML shown in a tooltip while the item is hovered. */
+ tooltip?: string;
}
/** A set of items under a heading. */
@@ -44,6 +47,20 @@ export interface ItemPickerDialogOptions {
/** How long typing is debounced before the list is filtered. Matches the settings search. */
const DEBOUNCE_MS = 150;
+/** One delegated tooltip for every item with a `tooltip`. */
+const ITEM_TOOLTIP: Partial<Tooltip.Options> = {
+ selector: ".item-picker-item[data-tooltip]",
+ title() {
+ return this.dataset.tooltip ?? "";
+ },
+ html: true,
+ placement: "right",
+ fallbackPlacements: [ "left", "right" ],
+ customClass: "tooltip-top",
+ animation: false,
+ trigger: "hover"
+};
+
/**
* Picks one item out of many, grouped and searchable, and closes on the pick.
*
@@ -102,16 +119,7 @@ export default function ItemPickerDialog() {
<FilterProvider query={settled}>
{/* The empty state is laid over this, so it holds still as the list collapses. */}
<div className="item-picker-results">
- {/* Animated once with the dialog, not per item. */}
- <div className="item-picker-groups">
- {groups.map((group) => (
- <Card key={group.key} heading={group.groupHeader || undefined}>
- {group.items.map((item) => (
- <PickerRow key={item.key} item={item} onPick={pick} />
- ))}
- </Card>
- ))}
- </div>
+ <PickerGroups groups={groups} onPick={pick} />
<NoItems
className="item-picker-empty"
@@ -124,6 +132,33 @@ export default function ItemPickerDialog() {
);
}
+interface PickerGroupsProps {
+ groups: PickerItemGroup[];
+ onPick: (item: PickerItem) => void;
+}
+
+/**
+ * The groups of items. A component of its own so that the tooltip attaches when the dialog's body
+ * mounts.
+ */
+function PickerGroups({ groups, onPick }: PickerGroupsProps) {
+ const groupsRef = useRef<HTMLDivElement>(null);
+ useStaticTooltip(groupsRef, ITEM_TOOLTIP);
+
+ return (
+ // Animated once with the dialog, not per item.
+ <div className="item-picker-groups" ref={groupsRef}>
+ {groups.map((group) => (
+ <Card key={group.key} heading={group.groupHeader || undefined}>
+ {group.items.map((item) => (
+ <PickerRow key={item.key} item={item} onPick={onPick} />
+ ))}
+ </Card>
+ ))}
+ </div>
+ );
+}
+
/** One item. Rendered whether or not it matches, collapsing when it does not. */
function PickerRow({ item, onPick }: { item: PickerItem, onPick: (item: PickerItem) => void }) {
const matched = useFilterMatch(item.caption);
@@ -136,6 +171,7 @@ function PickerRow({ item, onPick }: { item: PickerItem, onPick: (item: PickerIt
{ "item-picker-folded": !matched })}
tabIndex={matched ? 0 : -1}
aria-hidden={!matched}
+ data-tooltip={item.tooltip}
onClick={() => onPick(item)}
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") {
diff --git a/apps/client/src/widgets/layout/NoteTypeSwitcher.tsx b/apps/client/src/widgets/layout/NoteTypeSwitcher.tsx
index ff14941395..b2c8b604d4 100644
--- a/apps/client/src/widgets/layout/NoteTypeSwitcher.tsx
+++ b/apps/client/src/widgets/layout/NoteTypeSwitcher.tsx
@@ -22,7 +22,7 @@ import {
} from "../react/hooks";
import { MenuItemRows } from "../react/Menu";
import Modal from "../react/Modal";
-import { CodeMimeTypesList } from "../type_widgets/options/code_mime_types_list";
+import { CodeMimeTypesCard } from "../type_widgets/options/code_mime_types_card";
import { onWheelHorizontalScroll } from "../widget_utils";
/** The note types offered as a pill of their own, each a single click away. */
@@ -264,14 +264,15 @@ export function codeLanguageItems({ currentMimeType, mimeTypes, changeNoteType,
export function useMimeTypes() {
const [ codeNotesMimeTypes ] = useTriliumOption("codeNotesMimeTypes");
+ const [ isSortedAlphabetically ] = useTriliumOption("codeNotesMimeTypesSortAlphabetically");
return useMemo(() => {
mime_types.loadMimeTypes();
- const allMimeTypes = mime_types.getMimeTypes();
return {
- enabledMimeTypes: allMimeTypes.filter(mimeType => mimeType?.enabled),
- allMimeTypes
+ enabledMimeTypes: mime_types.getEnabledMimeTypes(),
+ allMimeTypes: mime_types.getMimeTypes()
};
- }, [ codeNotesMimeTypes ]); // eslint-disable-line react-hooks/exhaustive-deps
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [ codeNotesMimeTypes, isSortedAlphabetically ]);
}
export function NoteTypeOptionsModal({ modalShown, setModalShown }: { modalShown: boolean, setModalShown: (shown: boolean) => void }) {
@@ -280,9 +281,9 @@ export function NoteTypeOptionsModal({ modalShown, setModalShown }: { modalShown
className="code-mime-types-modal"
title={t("code_mime_types.title")}
show={modalShown} onHidden={() => setModalShown(false)}
- size="xl" scrollable
+ size="md" scrollable
>
- <CodeMimeTypesList />
+ <CodeMimeTypesCard />
</Modal>
);
}
diff --git a/apps/client/src/widgets/layout/code_menus.spec.tsx b/apps/client/src/widgets/layout/code_menus.spec.tsx
index 97fba04954..4e865f78d5 100644
--- a/apps/client/src/widgets/layout/code_menus.spec.tsx
+++ b/apps/client/src/widgets/layout/code_menus.spec.tsx
@@ -24,6 +24,7 @@ beforeEach(() => {
options.set("codeNoteTabWidth", "4");
options.set("codeNoteIndentWithTabs", "false");
options.set("codeNotesMimeTypes", JSON.stringify([ "text/x-python" ]));
+ options.set("codeNotesMimeTypesSortAlphabetically", "true");
});
afterEach(() => {
@@ -173,6 +174,26 @@ describe("useCodeLanguageMenu", () => {
await act(async () => select(menu().items, "basic_properties.configure_code_notes"));
expect(document.querySelector(".code-mime-types-modal .modal-dialog")).not.toBeNull();
});
+
+ it("lists the languages in the stored order, or by name", () => {
+ options.set("codeNotesMimeTypes",
+ JSON.stringify([ "text/x-python", "text/plain", "text/css" ]));
+ const note = buildCodeNote();
+ const languages = (isSortedAlphabetically: boolean) => {
+ options.set("codeNotesMimeTypesSortAlphabetically", String(isSortedAlphabetically));
+ let items: MenuItem<unknown>[] = [];
+ function Harness() {
+ items = useCodeLanguageMenu(useNoteCodeSettings(note)).menu.items;
+ return null;
+ }
+ act(() => render(<Harness />, container));
+ act(() => render(null, container));
+ return describeItems(items).slice(0, 3);
+ };
+
+ expect(languages(false)).toEqual([ "Python ✓", "Plain text ☐", "CSS ☐" ]);
+ expect(languages(true)).toEqual([ "Plain text ☐", "CSS ☐", "Python ✓" ]);
+ });
});
describe("getWordWrapMenu and getLineNumbersMenu", () => {
diff --git a/apps/client/src/widgets/react/Card.tsx b/apps/client/src/widgets/react/Card.tsx
index b966f66dc9..bf2e28b2a7 100644
--- a/apps/client/src/widgets/react/Card.tsx
+++ b/apps/client/src/widgets/react/Card.tsx
@@ -79,7 +79,7 @@ export function Card(props: {children: ComponentChildren} & CardProps) {
{props.heading}
{props.actions && <span className="tn-card-heading-actions">{props.actions}</span>}
</h5>}
- {props.description && <p className="tn-card-description">{props.description}</p>}
+ {props.description && <div className="tn-card-description">{props.description}</div>}
<div className="tn-card-body">
<FilterPassthrough when={matched}>{props.children}</FilterPassthrough>
</div>
diff --git a/apps/client/src/widgets/react/SortableCard.spec.tsx b/apps/client/src/widgets/react/SortableCard.spec.tsx
index ffb9d4c59f..f54375c619 100644
--- a/apps/client/src/widgets/react/SortableCard.spec.tsx
+++ b/apps/client/src/widgets/react/SortableCard.spec.tsx
@@ -620,6 +620,37 @@ describe("SortableCard", () => {
});
});
+ /** For a caller that sorts the entries itself, such as by name. */
+ describe("with the order fixed", () => {
+ it("draws no grip", () => {
+ draw({ isReorderable: false });
+
+ expect(container.querySelector(".tn-sortable-grip")).toBeNull();
+ expect(captions()).toEqual([ "Alpha", "Beta", "Gamma" ]);
+ });
+
+ it("takes nothing up for a finger resting on a segment", () => {
+ draw({ isReorderable: false });
+
+ touch(segmentOf("a"), { onGrip: false });
+ rest();
+
+ expect(segmentOf("a")?.className).not.toContain("tn-sortable-dragging");
+ expect(captured).toEqual([]);
+ });
+
+ it("moves nothing with Control, but still steps between the entries", () => {
+ draw({ isReorderable: false });
+
+ press(segmentOf("a"), "ArrowDown", { ctrlKey: true });
+ expect(changed).toEqual([]);
+ expect(captions()).toEqual([ "Alpha", "Beta", "Gamma" ]);
+
+ press(segmentOf("a"), "ArrowDown");
+ expect(document.activeElement).toBe(segmentOf("b"));
+ });
+ });
+
it("carries the grip on the trailing edge of each segment, after what it reads", () => {
draw();
const [ first ] = segments();
diff --git a/apps/client/src/widgets/react/SortableCard.tsx b/apps/client/src/widgets/react/SortableCard.tsx
index 0529636295..7dd61a3ff8 100644
--- a/apps/client/src/widgets/react/SortableCard.tsx
+++ b/apps/client/src/widgets/react/SortableCard.tsx
@@ -95,6 +95,11 @@ export interface SortableCardProps<T extends SortableItem> extends CardProps {
* when the entries carry their own controls on the trailing side.
*/
gripPlacement?: "start" | "end";
+ /**
+ * Whether the reader can reorder the entries. Off, the card draws no grip and ignores drags
+ * and Ctrl+arrow keys, for a caller that sorts the entries itself. Defaults to true.
+ */
+ isReorderable?: boolean;
/**
* Called for a key the card does not answer itself, with the entry that had the focus. For a
* caller whose entries have commands of their own.
@@ -113,8 +118,8 @@ export interface SortableCardProps<T extends SortableItem> extends CardProps {
* back. Entries are not interpreted, so anything identified by a key can be sorted.
*/
export function SortableCard<T extends SortableItem>({
- items, onChange, renderItem, itemCreationButtons, gripPlacement = "end", onItemKeyDown,
- selectedKey, onSelect, className, ...card
+ items, onChange, renderItem, itemCreationButtons, gripPlacement = "end", isReorderable = true,
+ onItemKeyDown, selectedKey, onSelect, className, ...card
}: SortableCardProps<T>) {
if ((itemCreationButtons?.length ?? 0) > MAX_CREATION_BUTTONS) {
throw new Error("Up to three item creation buttons are supported");
@@ -302,7 +307,7 @@ export function SortableCard<T extends SortableItem>({
useEffect(() => () => cancelHold(), [ cancelHold ]);
const beginDrag = useCallback((event: PointerEvent, key: string) => {
- if (!listRef.current || !segmentOf(key)) {
+ if (!isReorderable || !listRef.current || !segmentOf(key)) {
return;
}
@@ -362,7 +367,7 @@ export function SortableCard<T extends SortableItem>({
}
}, TOUCH_HOLD_MS)
};
- }, [ cancelHold, segmentOf, startDrag ]);
+ }, [ cancelHold, isReorderable, segmentOf, startDrag ]);
const dragTo = useCallback((clientY: number) => {
const drag = dragRef.current;
@@ -475,13 +480,19 @@ export function SortableCard<T extends SortableItem>({
return;
}
+ if (control && !isReorderable) {
+ return;
+ }
+
event.preventDefault();
if (control) {
moveItem(index, to);
} else {
focusEntry(to);
}
- }, [ add, endDrag, focusEntry, itemCreationButtons, moveItem, onItemKeyDown, shown ]);
+ }, [
+ add, endDrag, focusEntry, isReorderable, itemCreationButtons, moveItem, onItemKeyDown, shown
+ ]);
const onAddKeyDown = useCallback((event: KeyboardEvent) => {
// Moves back into the entries. Home and End address the first and last entry, as they do
@@ -565,7 +576,7 @@ export function SortableCard<T extends SortableItem>({
onKeyDown={(event) => onSegmentKeyDown(event, index)}
onAnimationEnd={() => setAddedKey(undefined)}
>
- {gripPlacement === "start" && grip()}
+ {isReorderable && gripPlacement === "start" && grip()}
<span className="tn-sortable-content">
{renderItem
@@ -576,7 +587,7 @@ export function SortableCard<T extends SortableItem>({
</>}
</span>
- {gripPlacement === "end" && grip()}
+ {isReorderable && gripPlacement === "end" && grip()}
</section>
))}
diff --git a/apps/client/src/widgets/react/hooks.spec.tsx b/apps/client/src/widgets/react/hooks.spec.tsx
index f18f21ae5f..017e3e9870 100644
--- a/apps/client/src/widgets/react/hooks.spec.tsx
+++ b/apps/client/src/widgets/react/hooks.spec.tsx
@@ -389,6 +389,41 @@ describe("useStaticTooltip", () => {
expect(span && Tooltip.getInstance(span), "instance untouched by the observer").not.toBeNull();
});
+ it("hides a delegated tooltip once scrolling moves its child out of view", async () => {
+ const removeListener = vi.spyOn(document, "removeEventListener");
+ await act(async () => render(<DelegatedTooltipHarness generation={1} />, container));
+
+ const span = container.querySelector("span");
+ expect(span).not.toBeNull();
+ act(() => {
+ if (span) {
+ Tooltip.getOrCreateInstance(span, {
+ animation: false,
+ title() {
+ return this.getAttribute("title") || "";
+ }
+ }).show();
+ }
+ });
+ expect(document.querySelector(".tooltip"), "shown").not.toBeNull();
+
+ // The test container is the scroller, its view 100px tall; the span is 20px tall.
+ container.getBoundingClientRect = () => new DOMRect(0, 0, 300, 100);
+ const scrollSpanTo = (top: number) => act(() => {
+ if (span) span.getBoundingClientRect = () => new DOMRect(0, top, 50, 20);
+ container.dispatchEvent(new Event("scroll"));
+ });
+
+ scrollSpanTo(40);
+ expect(document.querySelector(".tooltip"), "kept while in view").not.toBeNull();
+
+ scrollSpanTo(90);
+ expect(document.querySelector(".tooltip"), "hidden once partly out of view").toBeNull();
+ expect(removeListener.mock.calls.some(([ type ]) => type === "scroll"),
+ "stops listening once nothing is shown").toBe(true);
+ removeListener.mockRestore();
+ });
+
it("leaves a shown delegated tooltip standing when the mutation removed something else", async () => {
await act(async () => render(<DelegatedTooltipHarness generation={1} />, container));
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index dd2b12ebe9..d9793cb61d 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -1424,26 +1424,47 @@ export function useStaticTooltip(
}
shownDelegates.delete(target);
}
- if (!shownDelegates.size) delegateObserver.disconnect();
+ if (!shownDelegates.size) stopWatching();
});
+ // Hides a shown delegate once a scroll moves it partly out of the view of the element
+ // that scrolled, so that its popup does not follow it outside that element.
+ const onScroll = (event: Event) => {
+ const scroller = event.target;
+ if (!(scroller instanceof Element)) return;
+ const view = scroller.getBoundingClientRect();
+ for (const target of shownDelegates) {
+ const box = target.getBoundingClientRect();
+ const isInView = box.top >= view.top && box.bottom <= view.bottom
+ && box.left >= view.left && box.right <= view.right;
+ if (!isInView && scroller.contains(target)) {
+ Tooltip.getInstance(target)?.hide();
+ }
+ }
+ };
+ const startWatching = () => {
+ delegateObserver.observe(element, { childList: true, subtree: true });
+ document.addEventListener("scroll", onScroll, { capture: true, passive: true });
+ };
+ const stopWatching = () => {
+ delegateObserver.disconnect();
+ document.removeEventListener("scroll", onScroll, { capture: true });
+ };
// Bootstrap's component events bubble from the delegate up to the container.
const onDelegateShown = (event: Event) => {
if (!(event.target instanceof Element) || event.target === element) return;
- if (!shownDelegates.size) {
- delegateObserver.observe(element, { childList: true, subtree: true });
- }
+ if (!shownDelegates.size) startWatching();
shownDelegates.add(event.target);
};
const onDelegateHidden = (event: Event) => {
if (!(event.target instanceof Element)) return;
shownDelegates.delete(event.target);
- if (!shownDelegates.size) delegateObserver.disconnect();
+ if (!shownDelegates.size) stopWatching();
};
element.addEventListener("inserted.bs.tooltip", onDelegateShown);
element.addEventListener("hidden.bs.tooltip", onDelegateHidden);
disposeDelegateTracking = () => {
- delegateObserver.disconnect();
+ stopWatching();
element.removeEventListener("inserted.bs.tooltip", onDelegateShown);
element.removeEventListener("hidden.bs.tooltip", onDelegateHidden);
};
diff --git a/apps/client/src/widgets/type_widgets/options/code_mime_types_card.css b/apps/client/src/widgets/type_widgets/options/code_mime_types_card.css
new file mode 100644
index 0000000000..25d283bb49
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/options/code_mime_types_card.css
@@ -0,0 +1,47 @@
+:where(:root) {
+ --code-mime-types-badge-color: var(--muted-text-color);
+ --code-mime-types-muted-color: var(--muted-text-color);
+ --code-mime-types-sort-label-color: var(--main-text-color);
+}
+
+.tn-card.code-mime-types-card {
+ .tn-card-description {
+ display: flex;
+ align-items: flex-start;
+ gap: 20px;
+ }
+
+ .code-mime-types-sort {
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ gap: 0.25em;
+ margin-inline-start: auto;
+ color: var(--code-mime-types-sort-label-color);
+
+ label {
+ margin-bottom: 0;
+ cursor: pointer;
+ }
+ }
+
+ .code-mime-types-title {
+ flex-grow: 1;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .code-mime-types-muted {
+ color: var(--code-mime-types-muted-color);
+ }
+
+ .code-mime-types-badge {
+ --color: var(--code-mime-types-badge-color);
+ flex-shrink: 0;
+ }
+
+ .code-mime-types-remove {
+ flex-shrink: 0;
+ }
+}
diff --git a/apps/client/src/widgets/type_widgets/options/code_mime_types_card.spec.tsx b/apps/client/src/widgets/type_widgets/options/code_mime_types_card.spec.tsx
new file mode 100644
index 0000000000..b7663ae6fb
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/options/code_mime_types_card.spec.tsx
@@ -0,0 +1,233 @@
+import { MIME_TYPES_DICT } from "@triliumnext/commons";
+import { Tooltip } from "bootstrap";
+import { act } from "preact/test-utils";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import dialog from "../../../services/dialog";
+import options from "../../../services/options";
+import { renderInto } from "../../../test/render";
+import type { PickerItem } from "../../dialogs/item_picker";
+import { CodeMimeTypesCard } from "./code_mime_types_card";
+
+vi.mock("../../../services/i18n", () => ({
+ t: (key: string, values?: Record<string, unknown>) =>
+ values ? `${key} ${Object.values(values).join(" ")}` : key
+}));
+
+const PLAIN = "text/plain";
+const C = "text/x-csrc";
+const JAVA = "text/x-java";
+const FRONTEND = "application/javascript;env=frontend";
+const PYTHON = "text/x-python";
+
+// The languages each highlighter supports, which decide the badges and the picker's tooltip.
+vi.mock("@triliumnext/highlightjs/src/syntax_highlighting", () => ({
+ byMimeType: { "text/plain": {}, "application/javascript;env=frontend": {} }
+}));
+
+vi.mock("@triliumnext/codemirror/src/syntax_highlighting", () => ({
+ default: {
+ "application/javascript;env=frontend": {}, "text/x-java": {}, "text/x-python": {}
+ }
+}));
+
+describe("CodeMimeTypesCard", () => {
+ let originalOrder: string;
+ let originalSorting: string;
+
+ beforeEach(() => {
+ originalOrder = options.get("codeNotesMimeTypes");
+ originalSorting = options.get("codeNotesMimeTypesSortAlphabetically");
+ options.set("codeNotesMimeTypes", JSON.stringify([ JAVA, FRONTEND, C ]));
+ options.set("codeNotesMimeTypesSortAlphabetically", "true");
+ });
+
+ afterEach(() => {
+ options.set("codeNotesMimeTypes", originalOrder);
+ options.set("codeNotesMimeTypesSortAlphabetically", originalSorting);
+ vi.restoreAllMocks();
+ for (const popup of document.querySelectorAll(".tooltip")) {
+ popup.remove();
+ }
+ });
+
+ it("lists the languages by name after plain text, with where each is highlighted", () => {
+ const container = draw();
+
+ expect(captions(container))
+ .toEqual([ "Plain text", "C", "Java", "JavaScript (Trilium frontend)" ]);
+ expect(badges(container, "JavaScript (Trilium frontend)"))
+ .toEqual([ "code_mime_types.badge_code_blocks", "code_mime_types.badge_code_notes" ]);
+ expect(badges(container, "Java")).toEqual([ "code_mime_types.badge_code_notes" ]);
+ expect(badges(container, "C")).toEqual([]);
+ // Plain text is highlighted nowhere, cannot be removed, and is muted.
+ expect(badges(container, "Plain text")).toEqual([]);
+ expect(mutedCaptions(container)).toEqual([ "Plain text" ]);
+ expect(removeButton(container, "Plain text")).toBeNull();
+ expect(removeButton(container, "C")).not.toBeNull();
+ // A sorted list cannot be reordered by hand.
+ expect(container.querySelector(".tn-sortable-grip")).toBeNull();
+ });
+
+ it("explains each badge in a tooltip", () => {
+ const container = draw();
+ const [ blocks, notes ] = segment(container, "JavaScript (Trilium frontend)")
+ ?.querySelectorAll(".code-mime-types-badge") ?? [];
+
+ expect(tooltipOf(blocks)).toBe("code_mime_types.badge_code_blocks_tooltip");
+ expect(tooltipOf(notes)).toBe("code_mime_types.badge_code_notes_tooltip");
+ });
+
+ it("follows the stored order once sorting is off, and stores a new one", () => {
+ options.set("codeNotesMimeTypesSortAlphabetically", "false");
+ const container = draw();
+
+ expect(captions(container))
+ .toEqual([ "Plain text", "Java", "JavaScript (Trilium frontend)", "C" ]);
+ expect(container.querySelector(".tn-sortable-grip")).not.toBeNull();
+
+ press(segment(container, "Java"), "ArrowDown", { ctrlKey: true });
+
+ expect(stored()).toEqual([ PLAIN, FRONTEND, JAVA, C ]);
+ expect(captions(container))
+ .toEqual([ "Plain text", "JavaScript (Trilium frontend)", "Java", "C" ]);
+ });
+
+ it("switches sorting after the description, leaving the stored order alone", () => {
+ const container = draw();
+ const toggle = container.querySelector<HTMLInputElement>(
+ ".tn-card-description .switch-toggle");
+ expect(container.querySelector(`label[for="${toggle?.id}"]`)?.textContent)
+ .toBe("code_mime_types.sort_alphabetically");
+
+ act(() => { toggle?.dispatchEvent(new Event("input", { bubbles: true })); });
+
+ expect(options.get("codeNotesMimeTypesSortAlphabetically")).toBe("false");
+ expect(stored()).toEqual([ JAVA, FRONTEND, C ]);
+ expect(captions(container))
+ .toEqual([ "Plain text", "Java", "JavaScript (Trilium frontend)", "C" ]);
+ });
+
+ describe("adding a language", () => {
+ it("offers the languages not enabled yet, by name, with the highlighting tooltip",
+ async () => {
+ const picking = vi.spyOn(dialog, "pickSingleItem").mockResolvedValue(null);
+ const container = draw();
+
+ await click(container.querySelector(".tn-sortable-adder"));
+
+ const items = picking.mock.calls.at(-1)?.[0].items as PickerItem[];
+ const keys = items.map((item) => item.key);
+ expect(keys).toContain(PYTHON);
+ expect(keys).not.toContain(JAVA);
+ expect(keys).not.toContain(PLAIN);
+ const titles = items.map((item) => item.caption);
+ expect(titles).toEqual([ ...titles ].sort((a, b) => a.localeCompare(b)));
+ expect(items.find((item) => item.key === PYTHON)?.tooltip).toBe([
+ "<strong>code_mime_types.tooltip_syntax_highlighting</strong>",
+ "❌ code_mime_types.tooltip_code_block_syntax",
+ "✅ code_mime_types.tooltip_code_note_syntax"
+ ].join("\n"));
+ // Backed out of, so nothing is stored.
+ expect(stored()).toEqual([ JAVA, FRONTEND, C ]);
+ });
+
+ it("adds what was picked at the end of the stored order, while sorted", async () => {
+ vi.spyOn(dialog, "pickSingleItem")
+ .mockResolvedValue({ key: PYTHON, caption: "Python" });
+ const container = draw();
+
+ await click(container.querySelector(".tn-sortable-adder"));
+
+ expect(stored()).toEqual([ PLAIN, JAVA, FRONTEND, C, PYTHON ]);
+ expect(captions(container))
+ .toEqual([ "Plain text", "C", "Java", "JavaScript (Trilium frontend)", "Python" ]);
+ expect(container.querySelector(".tn-sortable-adder")?.textContent?.trim())
+ .toBe(`code_mime_types.add_another ${MIME_TYPES_DICT.length - 5}`);
+ });
+
+ it("says how many languages are left to add", () => {
+ const container = draw();
+
+ expect(container.querySelector(".tn-sortable-adder")?.textContent?.trim())
+ .toBe(`code_mime_types.add_another ${MIME_TYPES_DICT.length - 4}`);
+ });
+ });
+
+ it("removes a language with its button or Delete, but never plain text", async () => {
+ const container = draw();
+
+ await click(removeButton(container, "Java"));
+ expect(stored()).toEqual([ PLAIN, FRONTEND, C ]);
+
+ press(segment(container, "C"), "Delete");
+ expect(stored()).toEqual([ PLAIN, FRONTEND ]);
+
+ press(segment(container, "Plain text"), "Delete");
+ expect(stored()).toEqual([ PLAIN, FRONTEND ]);
+ expect(captions(container)).toEqual([ "Plain text", "JavaScript (Trilium frontend)" ]);
+ });
+});
+
+function draw() {
+ let container: HTMLElement | undefined;
+ act(() => { container = renderInto(<CodeMimeTypesCard heading="Languages" />); });
+ if (!container) throw new Error("The card did not render");
+ return container;
+}
+
+function stored() {
+ return JSON.parse(options.get("codeNotesMimeTypes"));
+}
+
+function segments(container: HTMLElement) {
+ return [ ...container.querySelectorAll<HTMLElement>(".tn-sortable-segment") ];
+}
+
+function captions(container: HTMLElement) {
+ return segments(container)
+ .map((element) => element.querySelector(".code-mime-types-title")?.textContent);
+}
+
+function segment(container: HTMLElement, caption: string) {
+ return segments(container).find((element) =>
+ element.querySelector(".code-mime-types-title")?.textContent === caption) ?? null;
+}
+
+function mutedCaptions(container: HTMLElement) {
+ return [ ...container.querySelectorAll(".code-mime-types-title.code-mime-types-muted") ]
+ .map((element) => element.textContent);
+}
+
+function removeButton(container: HTMLElement, caption: string) {
+ return segment(container, caption)?.querySelector(".code-mime-types-remove") ?? null;
+}
+
+function badges(container: HTMLElement, caption: string) {
+ return [ ...segment(container, caption)?.querySelectorAll(".code-mime-types-badge") ?? [] ]
+ .map((badge) => badge.textContent);
+}
+
+/** Shows the tooltip of `element` and returns its text. */
+function tooltipOf(element: Element | undefined) {
+ const instance = element && Tooltip.getInstance(element);
+ act(() => instance?.show());
+ const text = document.querySelector(".tooltip-inner")?.textContent;
+ act(() => instance?.hide());
+ return text;
+}
+
+function press(target: Element | null, key: string, init: KeyboardEventInit = {}) {
+ act(() => {
+ target?.dispatchEvent(
+ new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true, ...init }));
+ });
+}
+
+/** Clicks and waits for what the click awaits, such as the picker. */
+async function click(target: Element | null) {
+ await act(async () => {
+ target?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+ await act(async () => {});
+}
diff --git a/apps/client/src/widgets/type_widgets/options/code_mime_types_card.tsx b/apps/client/src/widgets/type_widgets/options/code_mime_types_card.tsx
new file mode 100644
index 0000000000..67335f9bb1
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/options/code_mime_types_card.tsx
@@ -0,0 +1,195 @@
+import "./code_mime_types_card.css";
+
+import { default as codeNoteMimeTypes } from "@triliumnext/codemirror/src/syntax_highlighting";
+import { getCodeLanguageIcon } from "@triliumnext/commons";
+import { byMimeType as codeBlockMimeTypes } from "@triliumnext/highlightjs/src/syntax_highlighting";
+import clsx from "clsx";
+import { useCallback, useMemo } from "preact/hooks";
+
+import dialog from "../../../services/dialog";
+import { t } from "../../../services/i18n";
+import mime_types, { orderEnabledMimeTypes, PLAIN_TEXT_MIME } from "../../../services/mime_types";
+import options from "../../../services/options";
+import ActionButton from "../../react/ActionButton";
+import { Badge } from "../../react/Badge";
+import FormToggle from "../../react/FormToggle";
+import { useTriliumOption, useTriliumOptionBool, useUniqueName } from "../../react/hooks";
+import Icon from "../../react/Icon";
+import { type SortableItem, SortableCard } from "../../react/SortableCard";
+
+interface CodeMimeTypesCardProps {
+ /** Left out in a dialog whose title already names the card. */
+ heading?: string;
+}
+
+/**
+ * The code languages offered by the language lists, in the order the lists show them.
+ *
+ * In its own module because the always-loaded note type switcher also renders it, while
+ * `code_notes.tsx` loads all of CodeMirror. Only the syntax highlighting tables are imported here.
+ */
+export function CodeMimeTypesCard({ heading }: CodeMimeTypesCardProps) {
+ const [ storedOrder, setStoredOrder ] = useTriliumOption("codeNotesMimeTypes");
+ const [ isSortedAlphabetically, setIsSortedAlphabetically ] =
+ useTriliumOptionBool("codeNotesMimeTypesSortAlphabetically");
+ const toggleId = useUniqueName("sort-alphabetically");
+
+ const { mimeTypes, shown, manualOrder } = useMemo(() => {
+ mime_types.loadMimeTypes();
+ const mimeTypes = mime_types.getMimeTypes();
+ const stored = options.getJson("codeNotesMimeTypes");
+ return {
+ mimeTypes,
+ shown: orderEnabledMimeTypes(mimeTypes, stored, isSortedAlphabetically),
+ manualOrder: orderEnabledMimeTypes(mimeTypes, stored, false)
+ .map((mimeType) => mimeType.mime)
+ };
+ }, [ storedOrder, isSortedAlphabetically ]); // eslint-disable-line react-hooks/exhaustive-deps
+
+ const items = useMemo(() => shown.map((mimeType) => ({
+ key: mimeType.mime,
+ caption: mimeType.title,
+ icon: getCodeLanguageIcon(mimeType)
+ })), [ shown ]);
+ const availableCount = mimeTypes.filter((mimeType) => !mimeType.enabled).length;
+
+ const save = useCallback(
+ (mimes: string[]) => setStoredOrder(JSON.stringify(mimes)), [ setStoredOrder ]);
+
+ // A sorted card reports additions only: they go at the end of the manual order.
+ const store = useCallback((order: SortableItem[]) => {
+ const mimes = order.map((item) => item.key);
+ if (isSortedAlphabetically) {
+ save([ ...manualOrder, ...mimes.filter((mime) => !manualOrder.includes(mime)) ]);
+ } else {
+ save(mimes);
+ }
+ }, [ isSortedAlphabetically, manualOrder, save ]);
+
+ const remove = useCallback((mime: string) => {
+ save(manualOrder.filter((candidate) => candidate !== mime));
+ }, [ manualOrder, save ]);
+
+ /** Opens the item picker on the languages that are not enabled yet. */
+ const pick = useCallback(async () => {
+ const picked = await dialog.pickSingleItem({
+ title: t("code_mime_types.add_title"),
+ items: mimeTypes
+ .filter((mimeType) => !mimeType.enabled)
+ .sort((a, b) => a.title.localeCompare(b.title))
+ .map((mimeType) => ({
+ key: mimeType.mime,
+ caption: mimeType.title,
+ icon: getCodeLanguageIcon(mimeType),
+ tooltip: highlightingTooltip(mimeType.mime)
+ }))
+ });
+
+ return picked
+ ? { key: picked.key, caption: picked.caption, icon: picked.icon }
+ : undefined;
+ }, [ mimeTypes ]);
+
+ return (
+ <SortableCard
+ className="code-mime-types-card"
+ heading={heading}
+ description={<>
+ <span>{t("code_mime_types.description")}</span>
+ <span className="code-mime-types-sort">
+ <label for={toggleId}>{t("code_mime_types.sort_alphabetically")}</label>
+ <FormToggle
+ id={toggleId}
+ currentValue={isSortedAlphabetically}
+ onChange={setIsSortedAlphabetically}
+ />
+ </span>
+ </>}
+ items={items}
+ onChange={store}
+ isReorderable={!isSortedAlphabetically}
+ // The grip leads, leaving the trailing edge to the badges and the remove button.
+ gripPlacement="start"
+ onItemKeyDown={(item, event) => {
+ if (event.key === "Delete" && item.key !== PLAIN_TEXT_MIME) {
+ event.preventDefault();
+ remove(item.key);
+ }
+ }}
+ renderItem={(item) => {
+ const isPlainText = item.key === PLAIN_TEXT_MIME;
+ return <>
+ {item.icon && (
+ <Icon
+ className={clsx({ "code-mime-types-muted": isPlainText })}
+ icon={item.icon}
+ />
+ )}
+ <span
+ className={clsx("code-mime-types-title",
+ { "code-mime-types-muted": isPlainText })}
+ >
+ {item.caption}
+ </span>
+ <HighlightingBadges mime={item.key} />
+
+ {!isPlainText && (
+ <ActionButton
+ className="code-mime-types-remove"
+ icon="bx bx-x"
+ text={t("code_mime_types.remove")}
+ onClick={(event) => {
+ event.stopPropagation();
+ remove(item.key);
+ }}
+ />
+ )}
+ </>;
+ }}
+ itemCreationButtons={[ {
+ label: t("code_mime_types.add_another", { count: availableCount }),
+ icon: "bx bx-plus",
+ disabled: !availableCount,
+ onCreateItem: pick
+ } ]}
+ />
+ );
+}
+
+/** Where a language is syntax highlighted. Plain text is highlighted nowhere. */
+function HighlightingBadges({ mime }: { mime: string }) {
+ if (mime === PLAIN_TEXT_MIME) {
+ return null;
+ }
+
+ return (
+ <>
+ {!!codeBlockMimeTypes[mime] && (
+ <Badge
+ className="code-mime-types-badge"
+ text={t("code_mime_types.badge_code_blocks")}
+ tooltip={t("code_mime_types.badge_code_blocks_tooltip")}
+ outline
+ />
+ )}
+ {!!codeNoteMimeTypes[mime] && (
+ <Badge
+ className="code-mime-types-badge"
+ text={t("code_mime_types.badge_code_notes")}
+ tooltip={t("code_mime_types.badge_code_notes_tooltip")}
+ outline
+ />
+ )}
+ </>
+ );
+}
+
+/** The picker's tooltip for a language: whether each highlighter supports it. */
+function highlightingTooltip(mime: string) {
+ const mark = (isSupported: boolean) => (isSupported ? "✅" : "❌");
+ return [
+ `<strong>${t("code_mime_types.tooltip_syntax_highlighting")}</strong>`,
+ `${mark(!!codeBlockMimeTypes[mime])} ${t("code_mime_types.tooltip_code_block_syntax")}`,
+ `${mark(!!codeNoteMimeTypes[mime])} ${t("code_mime_types.tooltip_code_note_syntax")}`
+ ].join("\n");
+}
diff --git a/apps/client/src/widgets/type_widgets/options/code_mime_types_list.css b/apps/client/src/widgets/type_widgets/options/code_mime_types_list.css
deleted file mode 100644
index 2df32b10cd..0000000000
--- a/apps/client/src/widgets/type_widgets/options/code_mime_types_list.css
+++ /dev/null
@@ -1,23 +0,0 @@
-.options-mime-types {
- list-style-type: none;
- column-width: 250px;
- padding-inline-start: 0;
-
- & > section {
- margin-bottom: 1em;
- break-inside: avoid-column;
- }
-
- /* The initial the group is filed under, marked the way a card marks its heading. */
- h5 {
- margin-bottom: 0.25em;
- font-size: .75rem;
- font-weight: bold;
- letter-spacing: .4pt;
- text-transform: uppercase;
- }
-
- ul {
- padding-inline-start: 0;
- }
-}
diff --git a/apps/client/src/widgets/type_widgets/options/code_mime_types_list.spec.tsx b/apps/client/src/widgets/type_widgets/options/code_mime_types_list.spec.tsx
deleted file mode 100644
index e15430e7bd..0000000000
--- a/apps/client/src/widgets/type_widgets/options/code_mime_types_list.spec.tsx
+++ /dev/null
@@ -1,134 +0,0 @@
-import type { Tooltip } from "bootstrap";
-import { describe, expect, it, vi } from "vitest";
-
-import { renderInto } from "../../../test/render";
-
-const mocks = vi.hoisted(() => ({
- stored: [] as string[],
- saved: [] as string[][],
- /** The tooltip config the list hands the hook, so its title callback can be asked directly. */
- tooltipConfig: undefined as Partial<Tooltip.Options> | undefined
-}));
-
-vi.mock("../../../services/i18n", () => ({ t: (key: string) => key }));
-
-vi.mock("../../../services/mime_types", () => ({
- default: {
- loadMimeTypes: () => {},
- getMimeTypes: () => [
- { mime: "text/plain", title: "Plain text", enabled: true },
- { mime: "application/javascript;env=frontend", title: "JavaScript", enabled: true },
- { mime: "text/x-csrc", title: "C", enabled: false },
- { mime: "text/x-java", title: "Java", enabled: false }
- ]
- }
-}));
-
-// Which languages each highlighter knows: what the tooltip reports per row.
-vi.mock("@triliumnext/highlightjs/src/syntax_highlighting", () => ({
- byMimeType: { "application/javascript;env=frontend": {} }
-}));
-
-vi.mock("@triliumnext/codemirror/src/syntax_highlighting", () => ({
- default: { "application/javascript;env=frontend": {}, "text/x-java": {} }
-}));
-
-// Captured rather than stubbed away: the callback it holds is what these cases read.
-vi.mock("../../react/hooks", async (importOriginal) => ({
- ...(await importOriginal<typeof import("../../react/hooks")>()),
- useStaticTooltip: (_ref: unknown, config: Partial<Tooltip.Options>) => {
- mocks.tooltipConfig = config;
- },
- useTriliumOptionJson: () => [ mocks.stored, (value: string[]) => void mocks.saved.push(value) ]
-}));
-
-import { CodeMimeTypesList } from "./code_mime_types_list";
-
-/** Asks the tooltip what it would say over the row holding the given MIME type. */
-function tooltipFor(container: HTMLElement, mime: string) {
- const label = [ ...container.querySelectorAll<HTMLElement>("label") ]
- .find((candidate) => candidate.querySelector("input")?.value === mime);
- const title = mocks.tooltipConfig?.title;
-
- return typeof title === "function" && label ? title.call(label) : undefined;
-}
-
-describe("the code MIME type list", () => {
- it("files each language under its initial, with plain text kept apart", () => {
- const container = renderInto(<CodeMimeTypesList />);
-
- // The first group carries no heading: plain text is not filed under a letter.
- const headings = [ ...container.querySelectorAll("h5") ].map((heading) => heading.textContent);
- expect(headings).toEqual([ "C", "J" ]);
- });
-
- it("shows plain text as on and out of reach, whatever the stored set holds", () => {
- // `mime_types` applies it regardless, so a box reading empty would say the opposite of
- // what happens — and one that cannot be cleared has no business reading empty either.
- for (const stored of [ [], [ "text/plain" ] ]) {
- mocks.stored = stored;
- const plainText = [ ...renderInto(<CodeMimeTypesList />).querySelectorAll<HTMLInputElement>("input") ]
- .find((box) => box.value === "text/plain");
-
- expect(plainText?.checked).toBe(true);
- expect(plainText?.disabled).toBe(true);
- }
- });
-
- it("leaves the stored set alone when another language is ticked", () => {
- mocks.stored = [];
- mocks.saved = [];
- const container = renderInto(<CodeMimeTypesList />);
-
- const java = [ ...container.querySelectorAll<HTMLInputElement>("input") ].find((box) => box.value === "text/x-java");
- java?.dispatchEvent(new Event("change", { bubbles: true }));
-
- // Plain text is on because the app applies it, not because it was chosen — so choosing
- // something else must not quietly write it into the user's option.
- expect(mocks.saved.at(-1)).toEqual([ "text/x-java" ]);
- });
-
- it("sorts the languages by name rather than leaving them in the order they arrived", () => {
- const container = renderInto(<CodeMimeTypesList />);
- const titles = [ ...container.querySelectorAll("label") ]
- .map((label) => label.textContent?.trim())
- .filter((title) => title !== "Plain text");
-
- expect(titles).toEqual([ ...titles ].sort((a, b) => (a ?? "").localeCompare(b ?? "")));
- });
-
- it("takes back what was ticked, keeping what was already there", () => {
- mocks.stored = [ "text/x-java" ];
- mocks.saved = [];
- const container = renderInto(<CodeMimeTypesList />);
-
- const c = [ ...container.querySelectorAll<HTMLInputElement>("input") ].find((box) => box.value === "text/x-csrc");
- c?.dispatchEvent(new Event("change", { bubbles: true }));
-
- expect(mocks.saved.at(-1)).toEqual([ "text/x-java", "text/x-csrc" ]);
- });
-});
-
-describe("what the tooltip says about a language", () => {
- it("reports each highlighter separately, since a language may be known to only one", () => {
- const container = renderInto(<CodeMimeTypesList />);
-
- // Known to both.
- expect(tooltipFor(container, "application/javascript;env=frontend")).toContain("✅");
- expect(tooltipFor(container, "application/javascript;env=frontend")).not.toContain("❌");
-
- // Known to the code editor but not to the code-block highlighter.
- const java = tooltipFor(container, "text/x-java");
- expect(java).toContain("✅");
- expect(java).toContain("❌");
-
- // Known to neither.
- expect(tooltipFor(container, "text/x-csrc")).not.toContain("✅");
- });
-
- it("says nothing at all over plain text, which is not highlighted by anything", () => {
- const container = renderInto(<CodeMimeTypesList />);
-
- expect(tooltipFor(container, "text/plain")).toBe("");
- });
-});
diff --git a/apps/client/src/widgets/type_widgets/options/code_mime_types_list.tsx b/apps/client/src/widgets/type_widgets/options/code_mime_types_list.tsx
deleted file mode 100644
index f5ecabf32d..0000000000
--- a/apps/client/src/widgets/type_widgets/options/code_mime_types_list.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-import "./code_mime_types_list.css";
-
-import { default as codeNoteMimeTypes } from "@triliumnext/codemirror/src/syntax_highlighting";
-import { MimeType } from "@triliumnext/commons";
-import { byMimeType as codeBlockMimeTypes } from "@triliumnext/highlightjs/src/syntax_highlighting";
-import type { Tooltip } from "bootstrap";
-import { useMemo, useRef } from "preact/hooks";
-
-import { t } from "../../../services/i18n";
-import mime_types from "../../../services/mime_types";
-import { useStaticTooltip, useTriliumOptionJson } from "../../react/hooks";
-import CheckboxList from "./components/CheckboxList";
-
-/**
- * Plain text is applied whatever the option holds (see `mime_types`, which ORs it in), so its entry
- * carries both halves of that: it cannot be cleared, and it reads as on regardless.
- */
-type MimeTypeWithState = MimeType & { disabled?: boolean; alwaysOn?: boolean };
-
-/**
- * Lives in its own module (rather than in `code_notes.tsx`) because it is also rendered by the
- * always-loaded basic properties tab, while the rest of the code note options pull in the full
- * CodeMirror bundle. Only the lightweight syntax highlighting tables are imported here.
- */
-export function CodeMimeTypesList() {
- const containerRef = useRef<HTMLUListElement>(null);
- // The config must keep a stable reference: `useStaticTooltip` re-runs (tearing down and
- // recreating the delegated tooltip) whenever the config identity changes. Toggling a checkbox
- // re-renders this component, so an inline config would recreate the tooltip on every toggle and
- // leave a stale, disposed delegated instance on the label that was just clicked — that label
- // then loses its tooltip until the page is reopened. The callback only reads static syntax
- // tables, so the memo has no dependencies.
- const tooltipConfig = useMemo<Partial<Tooltip.Options>>(() => ({
- title() {
- const mime = this.querySelector("input")?.value;
- if (!mime || mime === "text/plain") return "";
-
- const hasCodeBlockSyntax = !!codeBlockMimeTypes[mime];
- const hasCodeNoteSyntax = !!codeNoteMimeTypes[mime];
-
- return `
- <strong>${t("code_mime_types.tooltip_syntax_highlighting")}</strong>
- ${hasCodeBlockSyntax ? "✅" : "❌"} ${t("code_mime_types.tooltip_code_block_syntax")}
- ${hasCodeNoteSyntax ? "✅" : "❌"} ${t("code_mime_types.tooltip_code_note_syntax")}
- `;
- },
- selector: "label",
- customClass: "tooltip-top",
- placement: "left",
- fallbackPlacements: [ "left", "right" ],
- animation: false,
- html: true,
- // Hover only: clicking a label focuses the wrapped checkbox, and the default "hover focus"
- // trigger would keep the tooltip pinned via that focus after the mouse leaves, causing it to
- // overlap the next hovered label's tooltip.
- trigger: "hover"
- }), []);
- useStaticTooltip(containerRef, tooltipConfig);
- const [ codeNotesMimeTypes, setCodeNotesMimeTypes ] = useTriliumOptionJson<string[]>("codeNotesMimeTypes");
- const groupedMimeTypes: Record<string, MimeType[]> = useMemo(() => {
- mime_types.loadMimeTypes();
-
- const ungroupedMimeTypes = Array.from(mime_types.getMimeTypes()) as MimeTypeWithState[];
- const plainTextMimeType = ungroupedMimeTypes.shift();
- const result: Record<string, MimeType[]> = {};
- ungroupedMimeTypes.sort((a, b) => a.title.localeCompare(b.title));
-
- if (plainTextMimeType) {
- result[""] = [ plainTextMimeType ];
- plainTextMimeType.disabled = true;
- plainTextMimeType.alwaysOn = true;
- }
-
- for (const mimeType of ungroupedMimeTypes) {
- const initial = mimeType.title.charAt(0).toUpperCase();
- if (!result[initial]) {
- result[initial] = [];
- }
- result[initial].push(mimeType);
- }
- return result;
- // The available mime types are static; the memo does not read the user's selection
- // (`codeNotesMimeTypes`), so it must not re-group on every checkbox toggle.
- }, []);
-
- return (
- <ul class="options-mime-types" ref={containerRef}>
- {Object.entries(groupedMimeTypes).map(([ initial, mimeTypes ]) => (
- <section>
- { initial && <h5>{initial}</h5> }
- <CheckboxList
- values={mimeTypes as MimeTypeWithState[]}
- keyProperty="mime" titleProperty="title"
- disabledProperty="disabled" alwaysOnProperty="alwaysOn"
- currentValue={codeNotesMimeTypes} onChange={setCodeNotesMimeTypes}
- columnWidth="inherit"
- />
- </section>
- ))}
- </ul>
- );
-}
diff --git a/apps/client/src/widgets/type_widgets/options/code_notes.tsx b/apps/client/src/widgets/type_widgets/options/code_notes.tsx
index 15f8689a95..32f7ff1585 100644
--- a/apps/client/src/widgets/type_widgets/options/code_notes.tsx
+++ b/apps/client/src/widgets/type_widgets/options/code_notes.tsx
@@ -10,7 +10,7 @@ import { FormTextBoxWithUnit } from "../../react/FormTextBox";
import FormToggle from "../../react/FormToggle";
import { useColorScheme, useTriliumOption, useTriliumOptionBool } from "../../react/hooks";
import { CODE_THEME_DEFAULT_PREFIX as DEFAULT_PREFIX } from "../constants";
-import { CodeMimeTypesList } from "./code_mime_types_list";
+import { CodeMimeTypesCard } from "./code_mime_types_card";
import OptionsPageHeader from "./components/OptionsPageHeader";
import ThemeModeSelector from "./components/ThemeModeSelector";
import codeNoteSample from "./samples/code_note.txt?raw";
@@ -34,7 +34,7 @@ export default function CodeNoteSettings() {
wordWrapping={codeLineWrapEnabled} lineNumbers={codeLineNumbersEnabled}
indentSize={parseInt(codeNoteTabWidth) || 4}
/>
- <CodeMimeTypes />
+ <CodeMimeTypesCard heading={t("code_mime_types.title")} />
</>
);
}
@@ -243,13 +243,3 @@ function reindentSample(sample: string, indentSize: number): string {
});
}
-function CodeMimeTypes() {
- return (
- <Card heading={t("code_mime_types.title")}>
- <CardSection>
- <CodeMimeTypesList />
- </CardSection>
- </Card>
- );
-}
-
diff --git a/apps/client/src/widgets/type_widgets/options/components/CheckboxList.tsx b/apps/client/src/widgets/type_widgets/options/components/CheckboxList.tsx
index 7615b92164..ccf1a818d4 100644
--- a/apps/client/src/widgets/type_widgets/options/components/CheckboxList.tsx
+++ b/apps/client/src/widgets/type_widgets/options/components/CheckboxList.tsx
@@ -5,18 +5,12 @@ interface CheckboxListProps<T> {
keyProperty: keyof T;
titleProperty?: keyof T;
disabledProperty?: keyof T;
- /**
- * Marks an entry as ticked whatever the stored set holds, for one the app applies regardless of
- * what was chosen. Pair it with {@link CheckboxListProps.disabledProperty}: a box that cannot be
- * cleared but reads as empty says the opposite of what happens.
- */
- alwaysOnProperty?: keyof T;
currentValue: string[];
onChange: (newValues: string[]) => void;
columnWidth?: string;
}
-export default function CheckboxList<T>({ values, keyProperty, titleProperty, disabledProperty, alwaysOnProperty, currentValue, onChange, columnWidth }: CheckboxListProps<T>) {
+export default function CheckboxList<T>({ values, keyProperty, titleProperty, disabledProperty, currentValue, onChange, columnWidth }: CheckboxListProps<T>) {
function toggleValue(value: string) {
if (currentValue.includes(value)) {
// Already there, needs removing.
@@ -40,8 +34,7 @@ export default function CheckboxList<T>({ values, keyProperty, titleProperty, di
type="checkbox"
className="form-check-input"
value={String(value[keyProperty])}
- checked={currentValue.includes(String(value[keyProperty]))
- || !!(alwaysOnProperty && value[alwaysOnProperty])}
+ checked={currentValue.includes(String(value[keyProperty]))}
disabled={!!(disabledProperty && value[disabledProperty])}
onChange={e => toggleValue((e.target as HTMLInputElement).value)}
/>
diff --git a/apps/client/src/widgets/type_widgets/text/config.ts b/apps/client/src/widgets/type_widgets/text/config.ts
index 4d42ef7ef8..3aca1e9605 100644
--- a/apps/client/src/widgets/type_widgets/text/config.ts
+++ b/apps/client/src/widgets/type_widgets/text/config.ts
@@ -399,8 +399,7 @@ function getEnglishEditorMessages(): Record<string, string> {
function buildListOfLanguages() {
const userLanguages = mimeTypesService
- .getMimeTypes()
- .filter((mt) => mt.enabled)
+ .getEnabledMimeTypes()
// The `env=frontend`/`env=backend` JavaScript variants are Trilium script environments,
// which are meaningless inside a (display-only) code block. Plain `text/javascript`
// already provides JavaScript highlighting, so omit the script-specific variants here.
diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.json
index 886273acbf..7a8fdb0e1f 100644
--- a/apps/server/src/assets/help/help_content.json
+++ b/apps/server/src/assets/help/help_content.json
@@ -124,7 +124,7 @@
"_help_EK2ckIZ74tbT": "<p>Content tabs group several titled panels of content into one block that shows a single panel at a time. They suit content that comes in variants (such as installation steps for each operating system or the same snippet in several programming languages).</p><p>A tabs block consists of:</p><ul><li><strong>A single row of tab titles</strong>, above the panel or, when the tabs are aligned at the bottom, below it. The title of the panel that is showing is highlighted.</li><li><strong>The panel of the active tab.</strong> A panel can hold any kind of content (including nested tabs blocks).</li></ul><h2>Inserting a tabs block</h2><ul><li>In the formatting bar, go to <em>Insert</em> → <em>Tabs</em>.</li><li>Alternatively, type <code>/tabs</code> and press <kbd>Enter</kbd>, as described in&nbsp;<a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>.</li></ul><p>A new block contains two tabs, named “Tab 1” and “Tab 2”. Any content that was selected prior to inserting the tabs will be moved into the first tab. The title of the first tab is selected, so typing replaces it.</p><h2>Scrolling through the titles</h2><p>When the titles of a block do not fit on their row, a <span class=\"tn-icon bx bx-chevron-left\"></span> button and a <span class=\"tn-icon bx bx-chevron-right\"></span> button appear at its ends:</p><ul><li>To scroll the titles, click one of the buttons. Holding a button down scrolls the titles continuously until it is released.</li><li>On a touch screen, the titles can also be swiped sideways.</li></ul><p>Whenever another tab is shown (for example by clicking its title, by moving the cursor into it or by following a link to it), the row scrolls so that its whole title is visible. This works the same while editing, in read-only notes and on shared pages.</p><h2>Editing tabs</h2><ul><li>To show a tab, click its title or move the cursor into it.</li><li>To move from a title into its panel, press <kbd>Enter</kbd>.</li><li>The label of a tab can be formatted just like normal text, including support for&nbsp;<a class=\"reference-link\" href=\"#root/_help_hD8GawVuazff\">Icons</a>.</li></ul><p>While the cursor is inside a tabs block, a toolbar appears above it with the following buttons:</p><ul><li><span class=\"tn-icon cke cke-plus\"></span>&nbsp;<em>(Add tab)</em> inserts a tab after the current one and selects its title.</li><li><span class=\"tn-icon cke cke-remove\"></span>&nbsp;<em>(Remove tab)</em> removes the current tab. Removing the last tab removes the whole block.</li><li><span class=\"tn-icon cke cke-chevron-right bx-flip-horizontal\"></span>&nbsp;<em>(Move tab left)</em> and&nbsp;<span class=\"tn-icon cke cke-chevron-right\"></span> (<em>Move tab right)</em> change the order of the tabs.</li><li><span class=\"tn-icon cke cke-link\"></span>&nbsp;<em>(Copy link to tab)</em> copies a link to the current tab, as described below.</li><li><span class=\"tn-icon cke cke-trilium-tabs\"></span>&nbsp;<em>(Tab alignment)</em> places the tab titles above the panel (<em>Align tabs at top</em>, the default) or below it (<em>Align tabs at bottom</em>).</li></ul><p>The tab that is showing is not saved with the note: every tabs block opens on its first tab.</p><h3>Adding tabs</h3><p>While the cursor is in a tab, either in its title or in its panel, you can use these key combinations:</p><ul><li><kbd>Ctrl</kbd> + <kbd>Enter</kbd>: Add a tab after the current one.</li><li><kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Enter</kbd>: Add a tab before the current one.</li></ul><p>The new tab is shown and its title is selected, so typing replaces it.</p><p><kbd>Ctrl</kbd> + <kbd>Enter</kbd> keeps its usual function on a link, in a to-do item and in the title of a collapsible block, and <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Enter</kbd> in a to-do item.</p><h3>Reordering tabs</h3><p>While the cursor is in a tab, either in its title or in its panel, you can use these key combinations:</p><ul><li><kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Right</kbd>: Move the tab to the right.</li><li><kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Left</kbd>: Move the tab to the left.</li><li><kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Home</kbd>: Make it the first tab.</li><li><kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>End</kbd>: Make it the last tab.</li></ul><h2>Moving content between tabs</h2><p>To move content to another tab, select it in the panel, and then use these key combinations:</p><ul><li><kbd>Ctrl</kbd> + <kbd>Right</kbd>: Move to the tab on the right.</li><li><kbd>Ctrl</kbd> + <kbd>Left</kbd>: Move to the tab on the left.</li><li><kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>End</kbd>: Move to the last tab.</li><li><kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Home</kbd>: Move to the first tab.</li></ul><p>The tab that receives the content is shown, with the content still selected, so pressing the key again moves it on to the next tab. Paragraphs, list items, tables and other blocks move whole, even when only part of them is selected. Content moved to a tab on the left goes to the end of that tab, and content moved to a tab on the right goes to its start, so it keeps its place in the reading order.</p><p>Without a selection, or with a selection in a tab title, these keys keep their usual function: moving the cursor by word, or selecting up to the start or end of the tab.</p><p>When a tabs block and a <a class=\"reference-link\" href=\"#root/_help_wYDzQ1fBFgfT\">Multicolumn layout</a> are nested in one another, the key combinations act on the one closest to the cursor.</p><h2>Reading tabs</h2><p>In&nbsp;<a class=\"reference-link\" href=\"#root/_help_CoFPLs3dRlXc\">Read-Only Notes</a>&nbsp;and on&nbsp;<a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a>, tabs blocks work as tabs as well:</p><ul><li>To show a tab, click its title, or focus it and press <kbd>Enter</kbd> or <kbd>Space</kbd>.</li><li>To move between the titles of a block, use the arrow keys, <kbd>Home</kbd> and <kbd>End</kbd>.</li></ul><p>A tab without a title shows “Tab title” in place of one.</p><p>In read-only notes, a title too long for its tab fades out where it is cut off. To read the rest of it, swipe it sideways or drag it with the mouse.</p><h2>Linking to a tab</h2><p>A link can point to a single tab, much like a link to a block (see&nbsp;<a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>):</p><ol><li>Place the cursor in the tab, either in its title or in its panel.</li><li>Press <em>Copy link to tab</em> (<span class=\"tn-icon cke cke-link\"></span>) in the toolbar of the tabs block. Alternatively, right-click the text and select <em>Copy</em> → <em>Copy link to this tab</em>. The tab flashes briefly.</li><li>Go to the note where to insert the link and press <kbd>Ctrl</kbd>+<kbd>V</kbd>.</li></ol><p>The link shows the title of the note, followed by the title of the tab. Clicking it opens the note, shows the tab and flashes it. As with any block reference, the link can be turned into an&nbsp;<a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>&nbsp;that shows only that tab.</p><p>Links to a tab can be copied only from a note being edited. On a <a href=\"#root/_help_R9pX4DGra2Vt\">shared page</a>, such a link opens the whole note.</p><h2>Content in hidden tabs</h2><p>Content inside a tab that is not showing is still reachable (both while editing and while reading). The tab that holds it is shown when:</p><ul><li>searching the note with <kbd>Ctrl</kbd>+<kbd>F</kbd> highlights a match inside it;</li><li>a link points to an anchor or a block inside it (see&nbsp;<a class=\"reference-link\" href=\"#root/_help_oSuaNgyyKnhu\">Anchors</a>&nbsp;and&nbsp;<a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>);</li><li>an entry of the&nbsp;<a class=\"reference-link\" href=\"#root/_help_BFvAtE74rbP6\">Table of contents</a>&nbsp;or the&nbsp;<a class=\"reference-link\" href=\"#root/_help_AxshuNRegLAv\">Highlights list</a>&nbsp;points inside it;</li><li>on a shared page, the address of the page points to a heading or an anchor inside it.</li></ul><p>Tab titles are not headings, so they do not appear in the table of contents; headings inside a panel do.</p><h2>Printing and exporting</h2><ul><li>When printing or <a href=\"#root/_help_NRnIZmSMc5sj\">exporting to PDF</a>, every tab is printed, one after another, each with its title above its panel, whatever the tab alignment.</li><li>Markdown export and import write tabs blocks in the content tabs syntax of Material for MkDocs, described in&nbsp;<a class=\"reference-link\" href=\"#root/_help_rJ9grSgoExl9\">Supported syntax</a>.&nbsp;<a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a>&nbsp;notes use the same syntax, show the blocks as tabs in their preview and insert them with <code>/tabs</code>. That syntax has no tab alignment, so tabs aligned at the bottom are exported as regular tabs.</li><li>Anywhere the tabs cannot work as tabs (such as an HTML export opened elsewhere), a tabs block reads as a sequence of titled sections.</li></ul>",
"_help_2x0ZAX9ePtzV": "<figure class=\"image image_resized image-style-align-right\" style=\"width:64.63%;\"><img style=\"aspect-ratio:812/585;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Cut%20to%20subnote_cut-to-subnote.gif\" width=\"812\" height=\"585\"></figure><p>When editing a document that becomes too large, you can split it into sub-notes:</p><ol><li>Select the desired text and cut it to the clipboard.</li><li>Create a new sub-note and name it.</li><li>Paste the content from the clipboard into the sub-note.</li></ol><p>Trilium can automate this process. Select some text within the note, and in the selection toolbar, click the scissors icon for the \"cut &amp; pasted selection to sub-note\" action. The heading is automatically detected and the new sub-note is named accordingly. You can also assign a keyboard shortcut for this action. This functionality is available through the block toolbar icon. On a phone, the scissors are at the end of the text formatting row, which shows as you select text.</p>",
"_help_UYuUB1ZekNQU": "<h3>Inline code</h3><p>Inline code formats text using a monospace font to indicate technical content in a sentence such as code, paths, etc.</p><p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Developer-specific%20formatting_image.png\"></p><p>Example of inline code being used to illustrate file system paths as well as shell commands (<code>git</code> in this case).</p><p>To insert an inline code:</p><ul><li>Via the&nbsp;<a href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>, look for the&nbsp;<span class=\"tn-icon cke cke-code\"></span> button.</li><li>Type `code` where <code>code</code> is the desired text to be automatically formatted as inline code.</li><li>Paste a single line copied from Visual Studio Code. See <a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a> for pasting several lines.</li></ul><h3>Code blocks</h3><p>Code blocks display a snippet of code as a dedicated block:</p><p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Developer-specific%20formatting_image.jpg\"></p><p>A code block with JavaScript syntax highlight enabled.</p><p>Note that these are not meant for very large portions of code. Use the dedicated&nbsp;<a href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;note type instead.</p><p>See the dedicated documentation for more information:&nbsp;<a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a></p><h3>Keyboard shortcuts</h3><p>This allows marking a portion of text as a shortcut key.</p><p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Developer-specific%20formatting_image.jpg\"></p><p>To apply this style, press the&nbsp;<span class=\"tn-icon cke cke-trilium-kbd\"></span> button in&nbsp;<span class=\"tn-icon bx bx-text\"></span> group from the&nbsp;<a href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>. On the floating toolbar, the buttons appear when selecting a text.</p><p>Alternatively, press the <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>K</kbd> combination to apply keyboard shortcut formatting to the current text selection.</p><p>The formatting can be removed by pressing again the button (from the UI or from the keyboard), or by using the&nbsp;<span class=\"tn-icon cke cke-remove-format\"></span> <em>Remove formatting</em> button.</p>",
- "_help_QxEyIjRBizuC": "<p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Developer-specific%20formatting/Code%20blocks_image.jpg\"></p><p>The code blocks feature allows entering pieces of code in text notes.</p><p>Note that this feature is meant for generally small snippets of code. For larger files such as an entire log, see the&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;note type instead.</p><h2>Inserting a code block</h2><ul><li>Via the&nbsp;<a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>, look for the&nbsp;<span class=\"tn-icon cke cke-code-block\"></span> button.<ul><li>Pressing directly on the icon will insert a code block with the language that was selected most recently. If this is the first time a code block is inserted, the language will be “Auto-detected” by default.</li><li>Pressing the arrow next to the icon, which will show a popup with the available languages.</li></ul></li><li>Type <code>```</code> (as in Markdown).<ul><li>Note that it's not possible to specify the language, as it will default to the last selected language.</li></ul></li><li>Paste several lines of code copied from Visual Studio Code.<ul><li>The code block uses the language of the file in Visual Studio Code.</li><li>If that language is not in the list of languages, the code block uses <em>Auto-detected</em>.</li><li>The colors of the Visual Studio Code theme are removed.</li><li>A single line becomes inline code instead of a code block.</li><li>In Firefox, the code block always uses <em>Auto-detected</em>. Firefox can't read the language from Visual Studio Code.</li></ul></li></ul><h2>Exiting out of the code block</h2><ul><li>To exit out of a code block and enter a normal paragraph, move the cursor at the end of the code block and press Enter twice.</li><li>Similarly, to insert a paragraph above the note block, move the cursor at the beginning of the code block and press Enter twice.</li></ul><aside class=\"admonition note\"><p>If you've pasted a code block with a more complex HTML structure, exiting out of the code block by pressing Enter multiple times might not work. In that case the best approach is to delete the code block entirely and use Ctrl+Shift+V (paste as plain text).</p></aside><h2>Syntax highlighting &amp; color schemes</h2><p>Since TriliumNext v0.90.12, Trilium will try to offer syntax highlighting to the code block. Note that the syntax highlighting mechanism is slightly different than the one in&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;notes as different technologies are involved.</p><p>Interaction:</p><ul><li>When the language is set to <em>Auto-detected</em> (by default), Trilium will try to identify the programming language (or similar) that corresponds to the given snippet of text and highlight it. Only the languages enabled in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> → <em>Available MIME types in the dropdown</em> are considered. If this is problematic, consider changing the language of the code block manually.</li><li>When the language is set to <em>Plain text</em>, there will be no syntax highlighting.</li></ul><p>Note that when editing a text note, syntax highlighting is automatically disabled if the code block is too big (somewhere around 500 lines). In&nbsp;<a class=\"reference-link\" href=\"#root/_help_CoFPLs3dRlXc\">Read-Only Notes</a>, in print and on a <a href=\"#root/_help_R9pX4DGra2Vt\">shared page</a>, a code block of more than 500 lines or 50,000 characters is shown without syntax highlighting. These limits are not configurable.</p><p>In order to configure this new feature, a section has been added in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Appearance</em> to control the syntax highlighting. There the color scheme can be chosen, from a builtin selection of themes from Highlight.js. <em>VS Code (Light)</em> and <em>VS Code (Dark)</em> use the same colors as the default themes of <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes, so a code block and a code note color the same code alike.</p><ul><li>It is possible to disable the syntax highlighting for all the notes by selecting “No syntax highlighting” in the “Color scheme” option.</li><li>Word wrapping is disabled by default, but can be configured from the same section.</li><li>The tab width can also be adjusted from Options.</li></ul><aside class=\"admonition note\"><p><strong>Context regarding syntax highlighting</strong></p><p>In order to achieve the syntax highlight, the Highlight.js library is being used. Do note that support for syntax highlighting in code blocks is not a supported feature of the text editor we are using CKEditor), but rather a hack which makes use of the highlights API (used for highlighting search results for example). Nevertheless, we haven't noticed any major issues during the development of the feature, but feel free to report any issues you might have.</p><p>Most of the work to achieve the syntax highlight itself was already done by <a href=\"https://github.com/antoniotejada\">antoniotejada</a> in <a href=\"https://github.com/antoniotejada/Trilium-SyntaxHighlightWidget\">https://github.com/antoniotejada/Trilium-SyntaxHighlightWidget</a>. On our side we added customization but also additional functionality.</p></aside><h3>Migrating from existing syntax highlight plugins</h3><p>If you are already using a syntax highlighting plugin such as the <a href=\"https://github.com/antoniotejada/Trilium-SyntaxHighlightWidget\">Trilium-SyntaxHighlightWidget</a> we are basing off of, it is important to disable that plugin before upgrading in order for it not to conflict with our implementation.</p><p>Should you encounter any issues after the migration, try running Trilium in safe mode.</p><h2>Changing the language of a code block</h2><p>Simply click anywhere inside the code block and press again the code block button in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>:<br><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Developer-specific%20formatting/Code%20blocks_image.png\"></p><h2>Adjusting the list of languages</h2><p>The code blocks feature shares the list of languages with the&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;note type.</p><p>The supported languages can be adjusted by going to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>, then <em>Code Notes</em> and looking for the <em>Available MIME types in the dropdown</em> section. Simply check any of the items to add them to the list, or uncheck them to remove them from the list.</p><p>Note that the list of languages is not immediately refreshed, you'd have to manually <a href=\"#root/_help_s8alTXmpFR61\">refresh the application</a>.</p><h2>Text replacements and ligatures</h2><p><a class=\"reference-link\" href=\"#root/_help_oI7GoyilXXAr\">Automatic replacements</a>&nbsp;are a feature of text notes which converts some character sequences into another and some of them interfere with programming text, such as the conversion of quotes. While in a code block, the automatic replacements <strong>are not effect</strong>. The only way the automatic replacements can interfere is if the text is typed/pasted before being put in a code block.</p><p>A different feature is <em>programming ligatures</em>, which is simply a display affordance which turns <code>!=</code> into <code>≠</code> or <code>-&gt;</code> as <code>→</code> . These come from the <a href=\"#root/_help_w4rMEhJsALlA\">font</a>. The underlying text is not actually changed, and copying it out gives you back <code>!=</code> and <code>-&gt;</code>.</p><p>Ligatures can be disabled in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a><em>→ Appearance → Fonts → Programming ligatures.</em></p>",
+ "_help_QxEyIjRBizuC": "<p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Developer-specific%20formatting/Code%20blocks_image.jpg\"></p><p>The code blocks feature allows entering pieces of code in text notes.</p><p>Note that this feature is meant for generally small snippets of code. For larger files such as an entire log, see the&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;note type instead.</p><h2>Inserting a code block</h2><ul><li>Via the&nbsp;<a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>, look for the&nbsp;<span class=\"tn-icon cke cke-code-block\"></span> button.<ul><li>Pressing directly on the icon will insert a code block with the language that was selected most recently. If this is the first time a code block is inserted, the language will be “Auto-detected” by default.</li><li>Pressing the arrow next to the icon, which will show a popup with the available languages.</li></ul></li><li>Type <code>```</code> (as in Markdown).<ul><li>Note that it's not possible to specify the language, as it will default to the last selected language.</li></ul></li><li>Paste several lines of code copied from Visual Studio Code.<ul><li>The code block uses the language of the file in Visual Studio Code.</li><li>If that language is not in the list of languages, the code block uses <em>Auto-detected</em>.</li><li>The colors of the Visual Studio Code theme are removed.</li><li>A single line becomes inline code instead of a code block.</li><li>In Firefox, the code block always uses <em>Auto-detected</em>. Firefox can't read the language from Visual Studio Code.</li></ul></li></ul><h2>Exiting out of the code block</h2><ul><li>To exit out of a code block and enter a normal paragraph, move the cursor at the end of the code block and press Enter twice.</li><li>Similarly, to insert a paragraph above the note block, move the cursor at the beginning of the code block and press Enter twice.</li></ul><aside class=\"admonition note\"><p>If you've pasted a code block with a more complex HTML structure, exiting out of the code block by pressing Enter multiple times might not work. In that case the best approach is to delete the code block entirely and use Ctrl+Shift+V (paste as plain text).</p></aside><h2>Syntax highlighting &amp; color schemes</h2><p>Since TriliumNext v0.90.12, Trilium will try to offer syntax highlighting to the code block. Note that the syntax highlighting mechanism is slightly different than the one in&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;notes as different technologies are involved.</p><p>Interaction:</p><ul><li>When the language is set to <em>Auto-detected</em> (by default), Trilium will try to identify the programming language (or similar) that corresponds to the given snippet of text and highlight it. Only the languages enabled in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> → <em>Available MIME types in the dropdown</em> are considered. If this is problematic, consider changing the language of the code block manually.</li><li>When the language is set to <em>Plain text</em>, there will be no syntax highlighting.</li></ul><p>Note that when editing a text note, syntax highlighting is automatically disabled if the code block is too big (somewhere around 500 lines). In&nbsp;<a class=\"reference-link\" href=\"#root/_help_CoFPLs3dRlXc\">Read-Only Notes</a>, in print and on a <a href=\"#root/_help_R9pX4DGra2Vt\">shared page</a>, a code block of more than 500 lines or 50,000 characters is shown without syntax highlighting. These limits are not configurable.</p><p>In order to configure this new feature, a section has been added in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Appearance</em> to control the syntax highlighting. There the color scheme can be chosen, from a builtin selection of themes from Highlight.js. <em>VS Code (Light)</em> and <em>VS Code (Dark)</em> use the same colors as the default themes of <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes, so a code block and a code note color the same code alike.</p><ul><li>It is possible to disable the syntax highlighting for all the notes by selecting “No syntax highlighting” in the “Color scheme” option.</li><li>Word wrapping is disabled by default, but can be configured from the same section.</li><li>The tab width can also be adjusted from Options.</li></ul><aside class=\"admonition note\"><p><strong>Context regarding syntax highlighting</strong></p><p>In order to achieve the syntax highlight, the Highlight.js library is being used. Do note that support for syntax highlighting in code blocks is not a supported feature of the text editor we are using CKEditor), but rather a hack which makes use of the highlights API (used for highlighting search results for example). Nevertheless, we haven't noticed any major issues during the development of the feature, but feel free to report any issues you might have.</p><p>Most of the work to achieve the syntax highlight itself was already done by <a href=\"https://github.com/antoniotejada\">antoniotejada</a> in <a href=\"https://github.com/antoniotejada/Trilium-SyntaxHighlightWidget\">https://github.com/antoniotejada/Trilium-SyntaxHighlightWidget</a>. On our side we added customization but also additional functionality.</p></aside><h3>Migrating from existing syntax highlight plugins</h3><p>If you are already using a syntax highlighting plugin such as the <a href=\"https://github.com/antoniotejada/Trilium-SyntaxHighlightWidget\">Trilium-SyntaxHighlightWidget</a> we are basing off of, it is important to disable that plugin before upgrading in order for it not to conflict with our implementation.</p><p>Should you encounter any issues after the migration, try running Trilium in safe mode.</p><h2>Changing the language of a code block</h2><p>Simply click anywhere inside the code block and press again the code block button in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>:<br><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Developer-specific%20formatting/Code%20blocks_image.png\"></p><h2>Adjusting the list of languages</h2><p>The code blocks feature shares the list of languages with the&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;note type.</p><p>The supported languages, and the order in which they are listed, can be adjusted by going to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> → <em>Available MIME types in the dropdown</em>. See <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> for how to add, remove and reorder them.</p><p>Note that the list of languages is not immediately refreshed, you'd have to manually <a href=\"#root/_help_s8alTXmpFR61\">refresh the application</a>.</p><h2>Text replacements and ligatures</h2><p><a class=\"reference-link\" href=\"#root/_help_oI7GoyilXXAr\">Automatic replacements</a>&nbsp;are a feature of text notes which converts some character sequences into another and some of them interfere with programming text, such as the conversion of quotes. While in a code block, the automatic replacements <strong>are not effect</strong>. The only way the automatic replacements can interfere is if the text is typed/pasted before being put in a code block.</p><p>A different feature is <em>programming ligatures</em>, which is simply a display affordance which turns <code>!=</code> into <code>≠</code> or <code>-&gt;</code> as <code>→</code> . These come from the <a href=\"#root/_help_w4rMEhJsALlA\">font</a>. The underlying text is not actually changed, and copying it out gives you back <code>!=</code> and <code>-&gt;</code>.</p><p>Ligatures can be disabled in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a><em>→ Appearance → Fonts → Programming ligatures.</em></p>",
"_help_AgjCISero73a": "<figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:199/187;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Footnotes_image.png\" width=\"199\" height=\"187\"></figure><p>Footnotes are a good place to insert references to a paragraph or details that are displayed at the bottom of the note.</p><h2>Interaction</h2><ul><li>To insert a new footnote, press&nbsp;<span class=\"tn-icon cke cke-trilium-insert-footnote\"></span> (or press the right arrow and select <em>New footnote</em>).</li><li>To insert a reference to an existing footnote, press the right arrow and select <em>Insert footnote</em>, followed by the number of the footnote to insert.</li><li>Hovering over a reference (e.g. <code>[1]</code>) will display the content of the footnote in a tooltip for easy reference.</li><li>Clicking on a reference in the text (e.g. <code>[1]</code>) will navigate to the corresponding footnote.</li><li>Similarly, clicking on the <code>^</code> button of a footnote will navigate to the corresponding reference in the text.</li></ul>",
"_help_5wZallV2Qo1t": "<figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:220/76;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Format%20Painter_image.png\" width=\"220\" height=\"76\"></figure><p>The Format Painter is a feature in text notes that allows users to copy the formatting of text (such as <strong>bold</strong>, <em>italic</em>, <del>Strikethrough</del>, etc.) and apply it to other parts of the document. It helps maintain consistent formatting and accelerates the creation of rich content.</p><h2>Usage Instructions</h2><p>Click the text that you want to copy the formatting from and use the <em>Copy formatting</em> toolbar button (<span class=\"tn-icon cke cke-paint-roller\"></span>) to copy the style. Then select the target text with your mouse, or click a word, to apply the formatting.</p><ul><li><strong>To copy the formatting</strong>: Place the cursor inside text with some formatting and click the <em>Copy formatting</em> toolbar button. The mouse cursor changes to indicate the painter is armed.</li><li><strong>To paint with the copied formatting</strong>: Select the target text with your mouse. The formatting is applied when you release the button, and the painter disarms — the cursor returns to normal. Clicking or tapping a word applies it to the whole word.</li><li><strong>To paint a selection made otherwise</strong>, such as with the keyboard or the selection handles of a touch screen: select the target text, then use the toolbar button again, which reads <em>Apply formatting</em> once the selection has moved. On a phone, the formatting row stays open while the painter is armed, so the button stays in reach.</li><li><strong>To cancel without painting</strong>: Click the toolbar button again before selecting other text, or press <kbd>Escape</kbd>.</li></ul><h2>Limitations</h2><ol><li>Painting with block-level formatting (like headings or image styles) is not supported yet. This is because, in&nbsp;<a class=\"reference-link\" href=\"#root/_help_MI26XDLSAlCD\">CKEditor</a>, they are considered a part of the content rather than text formatting.</li><li>A click outside a word, such as between two spaces or at the end of a line, only primes the caret, so text you type there takes the copied formatting.</li><li>The painter is one-shot; each paint requires copying the formatting again.</li></ol>",
"_help_nRhnJkTT8cPs": "<p>Trilium allows two different editing experiences for text notes, based on your preference.</p><p>The type of formatting toolbar can be changed by going to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;and then looking for the&nbsp;<a class=\"reference-link\" href=\"#root/_hidden/_options/_optionsTextNotes\">Text Notes</a>&nbsp;section. In it, look for the <em>Formatting toolbar</em> category.</p><h2>Floating</h2><p>The floating bar is a more minimalist option, in which the formatting is hidden behind two different popups.</p><h3>Block-level popup</h3><p>The first popup is the block-level popup. This will appear to the left of the current paragraph you are currently editing, as a sequence of dots:<br><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Formatting%20toolbar_image.jpg\"></p><p>Clicking this popup will reveal the formatting options that are specific to the entire paragraph, such as setting a heading, lists, tables, etc.</p><p>The dots are also a drag handle: drag them to move the paragraph, all the selected paragraphs, or a selected element such as an image, a table or an included note to another place in the note. Right-clicking them copies a reference to the paragraph or to the selected paragraphs, see&nbsp;<a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>.</p><figure class=\"image\"><img style=\"aspect-ratio:1404/156;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_Formatting%20toolbar_image.png\" width=\"1404\" height=\"156\"></figure><h3>Inline popup</h3><p>The inline popup appears automatically when selecting a text:</p><figure class=\"image\"><img style=\"aspect-ratio:1008/154;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Formatting%20toolbar_image.png\" width=\"1008\" height=\"154\"></figure><p>All the options here apply only to the selected portion of text, such as changing the font size, or making the text bold.</p><h2>Fixed</h2><p>The fixed formatting offers a more traditional editing paradigm, usually useful if a lot of formatting is needed.</p><p>All the options are combined into a single toolbar that will appear at the above the note. When using&nbsp;<a class=\"reference-link\" href=\"#root/_help_luNhaphA37EO\">Split View</a>, a single toolbar will be available to save space and it acts on the active note.</p><p>The sequence of dots to the left of the current paragraph is still shown, but only as a drag handle: drag it to move the paragraph, all the selected paragraphs, or a selected element such as an image, a table or an included note to another place in the note. Clicking it does not open a popup, and right-clicking it copies a reference to the block, see&nbsp;<a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>. The drag handle is not shown in the mobile layout.</p><figure class=\"image\"><img style=\"aspect-ratio:1440/60;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Formatting%20toolbar_image.png\" width=\"1440\" height=\"60\"></figure><p>By default, if the toolbar does not fit on the screen, the rest of the options will be grouped into a single option at the end. It is possible to display items on multiple lines by checking the corresponding option in the <em>Formatting toolbar</em> section.</p>",
@@ -155,7 +155,7 @@
"_help_NdowYOC1GFKS": "<p>Tables are a powerful feature for&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes, since editing them is generally easy.</p><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:176/204;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_Tables_image.png\" width=\"176\" height=\"204\"></figure><p>To create a table, simply press the table button and select with the mouse the desired amount of columns and rows, as indicated in the adjacent figure.</p><p>Since v0.107.0, the same menu starts with an <em>Insert table…</em> item, for a table larger than the grid or to type its size instead:</p><ol><li>Click the <span class=\"tn-icon cke cke-table\"></span>button and select <em>Insert table…</em>. A small form opens at the cursor.</li><li>Enter the number of <em>Columns</em> (up to 100) and <em>Rows</em> (up to 1000). The table can have at most 5000 cells in total, for example 1000 rows of 5 columns.</li><li>Press <em>Insert</em> or <kbd>Enter</kbd>.</li></ol><p>To close the form without inserting a table, press <kbd>Esc</kbd> or click outside it. From the keyboard, <kbd>Tab</kbd> moves between <em>Insert table…</em> and the grid while the menu is open.</p><p>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the table is inserted from the <span class=\"tn-icon cke cke-plus\"></span> button of the formatting toolbar: its <em>Insert table</em> tile lists common sizes, from 2 × 2 to 3 × 4 (rows × columns). Tap one to insert a table of that size; to make it larger, insert rows and columns afterwards.</p><h2>Formatting toolbar</h2><p>When a table is selected, a special formatting toolbar will appear:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/3_Tables_image.png\" width=\"384\" height=\"100\"><p>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the toolbar does not float over the table. Instead, press the <span class=\"tn-icon cke cke-table\"></span> button after <em>Undo</em> and <em>Redo</em> in the formatting toolbar at the bottom of the screen to show the table's toolbar there.</p><h2>Context menu</h2><p>Since v0.106.0, right-clicking anywhere inside a table opens a context menu with the most common table operations:</p><ul><li><em>Insert row above</em> and <em>Insert row below</em> insert a blank row next to the row of the current cell. When the selection spans multiple rows, the same number of rows is inserted.</li><li><em>Insert column to the left</em> and <em>Insert column to the right</em> work the same way for columns.</li><li>Since v0.107.0, <em>Set as header</em> or <em>Set header up to this row</em>, depending on the selection, turns rows into header rows, which always start at the top of the table:<ul><li><em>Set as header</em> shows when the selection starts at the first row, and makes every selected row a header row.</li><li><em>Set header up to this row</em> shows when the selection is in a single row below the first, and makes that row and every row above it header rows.</li><li>Neither shows when the selection spans several rows below the first.</li><li>A check mark shows that the rows are already header rows. Choosing the item again turns them, and every header row below them, back into regular rows. For example, in a table with five header rows, choosing <em>Set header up to this row</em> on the third row leaves only the first two as header rows.</li></ul></li><li><em>Merge cells</em> merges the selected cells into one. The selected cells must form a rectangle.</li><li><em>Split cell</em> splits each selected cell in two, either <em>Vertically</em> or <em>Horizontally</em>. <em>Unmerge cells</em>, in the same submenu, turns each merged cell in the selection back into the single cells it covers, keeping its content in the top-left one; cells that are not merged stay as they are.</li><li><em>Distribute columns evenly</em> splits the combined width of the columns the selection touches equally between them. The other columns and the width of the table stay as they are. It needs a selection spanning at least two columns; a merged cell counts for every column it covers.</li><li><em>Cut</em>, <em>Copy</em> and <em>Copy as Markdown</em> act on the selected cells. Since v0.107.0, <em>Copy</em> and <em>Paste</em> open submenus with their variants, such as <em>Copy as Markdown</em> and <em>Paste as plain text</em>; clicking <em>Copy</em> or <em>Paste</em> itself still copies or pastes:<ul><li>Cutting or copying produces a smaller table holding just the selected cells. Pasting it over a cell selection replaces those cells; pasting elsewhere inserts it as a table of its own. Cutting clears the cells without removing rows or columns.</li><li><em>Copy as Markdown</em> converts the selected cells to a Markdown table. A selected header row becomes the Markdown header; without one, an empty header row is emitted, since Markdown tables require one.</li></ul></li><li>Since v0.107.0, <em>Paste rows above</em> and <em>Paste rows below</em>, in the <em>Paste</em> submenu, paste the clipboard as new rows next to the row of the current cell, instead of over the cells from the cursor on. They show only when the selection is in a single row, and, like <em>Paste</em>, only where the clipboard can be read:<ul><li>A copied table becomes one new row for each of its rows, filled from the first column. When it has more columns than the table, the table gains columns, as with a regular paste. Other content goes in the first cell of a single new row.</li><li>The new rows are selected afterwards.</li><li>When merged cells join the row to others, the new rows go above or below that whole block of rows.</li></ul></li><li><em>Sort</em>, below the clipboard section, sorts the rows by the column of the current cell, in <em>Ascending</em> or <em>Descending</em> order. See <a href=\"#sorting-rows\">Sorting rows</a>.</li><li><em>Delete row</em> and <em>Delete column</em>, below <em>Sort</em>, remove every row or column the selection touches, even when only some of their cells are selected.</li><li><em>Delete table</em> removes the whole table and leaves an empty paragraph in its place. In a table nested inside another, only the inner table is removed.</li><li>Since v0.107.0, <em>Select</em>, below <em>Delete table</em>, selects the cells of every row (<em>Row</em>) or column (<em>Column</em>) the selection touches, or every cell of the table (<em>Table</em>). Unlike the <span class=\"tn-icon cke cke-drag-handle\"></span>button, which selects the table as a whole, <em>Table</em> selects its cells, so cell operations such as <em>Merge cells</em> apply to all of them. In a table nested inside another, <em>Table</em> selects only the cells of the inner table.</li></ul><p>Right-clicking a cell that is not part of the current selection moves the cursor there first, so the menu always applies to the cell under the pointer.</p><aside class=\"admonition note\"><p>In the browser, Trilium's menu replaces the browser's own context menu inside tables. To reach the browser's menu (for example for its spell checking suggestions), hold <kbd>Shift</kbd> while right-clicking. The desktop application is unaffected, since its menu already includes the spelling suggestions. In the browser, the menu also offers <em>Paste</em> only when the page can read the clipboard, which requires a secure (HTTPS) context and your permission; otherwise, paste with <kbd>Ctrl</kbd>+<kbd>V</kbd>.</p></aside><h2>Navigating a table</h2><ul><li>Using the mouse:<ul><li>Click on a cell to focus it.</li><li>Click the&nbsp;<span class=\"tn-icon cke cke-return-arrow\"></span> button at the top or the bottom of a table to insert an empty paragraph near it.</li><li>Click the&nbsp;<span style=\"--tn-color:hsl(0,0%,60%);color:hsl(0,0%,60%);\"><span class=\"tn-icon cke cke-drag-handle\"></span></span> button at the top-left of the table to select it entirely (for easy copy-pasting or cutting) or drag and drop it to relocate the table.</li></ul></li><li>Using the keyboard:<ul><li>Use the arrow keys on the keyboard to easily navigate between cells.</li><li>It's also possible to use <kbd>Tab</kbd> to go to the next cell and Shift+Tab to go to the previous cell.</li><li>Unlike arrow keys, pressing <kbd>Tab</kbd> at the end of the table (last row, last column) will create a new row automatically.</li><li>To select multiple cells, hold <kbd>Shift</kbd> while using the arrow keys.</li></ul></li><li>Using touch:<ul><li>Since v0.107.0, touching a table outlines the cell with the cursor, or the selected cells, and shows a handle at each corner of the outline.</li><li>To select multiple cells, drag one of the handles across the table. The cell at the opposite corner stays selected, so the selection grows or shrinks as the finger moves. The note and wide tables scroll when the handle reaches the edge of the screen.</li></ul></li></ul><h2>Resizing cells</h2><ul><li>Columns can be resized by hovering the mouse over the border of two adjacent cells and dragging it.</li><li>To give several columns the same width, select cells across them and choose <em>Distribute columns evenly</em> from the <span class=\"tn-icon cke cke-table-column\"></span>button of the formatting toolbar or from the <a href=\"#context-menu\">context menu</a>.</li><li>By default, the row height is not adjustable using the mouse, but it can be configured from the cell settings (see below).</li><li>To adjust exactly the width (in pixels or percentages) of a cell, select the&nbsp;<span class=\"tn-icon cke cke-table-cell-properties\"></span> button.</li></ul><h3>Resizing with touch</h3><p>Since v0.107.0, touching a table shows a bar at the bottom of the note, above the formatting toolbar on mobile. The bar has a segment for each column of the table, with a divider at the end of each column. Only the divider of the column with the cursor is a handle that resizes; the other dividers only mark where the columns meet, so a swipe across them scrolls instead. When several cells are selected, each column they cover has a handle.</p><ul><li>To resize a column, place the cursor in one of its cells or tap its segment, then drag its handle. The table grows or shrinks with the column, and scrolls when the handle reaches the edge of the screen. The column snaps to its starting width and to the widths of the columns beside it.</li><li>To cancel a resize, drag the handle back to where it started, or touch the screen with a second finger.</li><li>To give a column and the next one the same width, double-tap the handle between them.</li><li>To select a column, tap its segment. To open the column menu, touch and hold the segment.</li><li>To scroll a wide table sideways, swipe along the bar.</li></ul><p>A wide table scrolls a little past its end, so the handle of its last column stays away from the edge of the screen, where a swipe navigates back.</p><h2>Wide tables</h2><p>Since v0.107.0, a table can be wider than the&nbsp;<a class=\"reference-link\" href=\"#root/_help_t596jLvPrqkS\">Content width</a>. Such a table scrolls sideways, while the rest of the note keeps its width.</p><ul><li>A new table is as wide as the content. To make it wider, drag the right border of its last column past the edge of the content. The border snaps to the edge and holds there briefly, so the table is easy to bring back to the width of the content.</li><li>To set an exact width, enter a percentage above <code>100%</code> or a width in pixels in the&nbsp;<span class=\"tn-icon cke cke-table-properties\"></span> <a href=\"#table-properties\">table properties</a>.</li><li>A table whose content needs more room than the note, such as a pasted table with many columns, also scrolls instead of stretching the note.</li><li>Wide tables scroll the same way in read-only notes and on shared pages.</li><li>When printing or exporting to PDF, a wide table is shrunk to fit the page.</li></ul><p>Tables inside other blocks, such as block quotes, admonitions, collapsible blocks, columns or tabs, are limited to the width of their block and do not scroll.</p><h3>Mobile support</h3><p>On the&nbsp;<a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, a table keeps the width it has on a desktop and scrolls sideways, instead of squeezing its columns into the width of the screen. The full width of a table is the <em>Max content width</em> set in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Appearance</em> → <em>Content Width</em> on the mobile device, 1200 pixels by default. For example, a table set to <code>50%</code> is 600 pixels wide.</p><p>To resize columns on mobile, use the bar described in <a href=\"#resizing-with-touch\">Resizing with touch</a>.</p><h2>Long tables</h2><p>Since v0.107.0, the header rows of a table stay visible at the top of the note while you scroll through the rest of the table, and leave with the end of the table. This also works in read-only notes, on shared pages and in wide tables.</p><p>To turn rows into header rows, use <em>Set as header</em> in the <a href=\"#context-menu\">context menu</a>, or <em>Header row</em> in the <span class=\"tn-icon cke cke-table-row\"></span> button of the formatting toolbar.</p><p>To let header rows scroll away with the rest of the table, turn off <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Text Notes</em> → <em>Features</em> → <em>Use sticky header rows for tables</em>. The setting applies to the current device only, and shared pages keep their sticky header rows.</p><h2>Inserting new rows and new columns</h2><ul><li>To insert a new column, click on a desired location, then press the&nbsp;<span class=\"tn-icon cke cke-table-column\"></span> button from the formatting toolbar and select <em>Insert column left or right.</em></li><li>To insert a new row, click on a desired location, then press the&nbsp;<span class=\"tn-icon cke cke-table-row\"></span> button and select <em>Insert row above</em> or <em>below</em>.<ul><li>A quicker alternative to creating a new row while at the end of the table is to press the <kbd>Tab</kbd> key.</li></ul></li><li>Both operations are also available in the <a href=\"#context-menu\">context menu</a>, which inserts as many rows or columns as the selection spans.</li></ul><h2>Moving rows and columns</h2><p>Since v0.106.0, rows and columns can be reordered with the keyboard:</p><ul><li><kbd>Alt</kbd>+<kbd>Up</kbd> and <kbd>Alt</kbd>+<kbd>Down</kbd> move the rows touched by the selection up or down.</li><li><kbd>Alt</kbd>+<kbd>Left</kbd> and <kbd>Alt</kbd>+<kbd>Right</kbd> move the columns touched by the selection left or right.</li></ul><p>Merged cells are never split by a move. The rows or columns held together by a merged cell travel as one block, and moving toward such a block jumps over it entirely.</p><p>When the table has a header row, a header row moved below the header area becomes a regular row, and a regular row moved into the header area becomes a header row. Header columns behave the same way.</p><p>Outside of tables, <kbd>Alt</kbd>+<kbd>Left</kbd> and <kbd>Alt</kbd>+<kbd>Right</kbd> keep navigating the note history, and <kbd>Alt</kbd>+<kbd>Up</kbd> and <kbd>Alt</kbd>+<kbd>Down</kbd> keep moving the current paragraph.</p><h2>Sorting rows</h2><p>Since v0.107.0, the rows of a table can be sorted by the values of one column:</p><ul><li>To sort all the rows, place the cursor in any cell of the column to sort by, then select <em>Sort</em> → <em>Ascending</em> or <em>Descending</em> from the <a href=\"#context-menu\">context menu</a>. The same items are in the <span class=\"tn-icon bx bx-sort-alt-2\"></span>button of the formatting toolbar.</li><li>To sort only some of the rows, select their cells in the column to sort by, then sort the same way. Sorting is not available while the selection spans more than one column.</li></ul><p>Header rows always stay at the top of the table and are never sorted. A sort can be undone with <kbd>Ctrl</kbd>+<kbd>Z</kbd>.</p><h3>How values are compared</h3><p>Each cell is read as plain text, so formatting does not affect the order. Trilium then detects what kind of value the cell holds:</p><figure class=\"table\"><table><thead><tr><th>Kind</th><th>Examples</th><th>Compared by</th></tr></thead><tbody><tr><td>Time</td><td><code>15:02</code>, <code>15:02:38</code>, <code>3:02 PM</code></td><td>The time of day.</td></tr><tr><td>Date</td><td><code>2026-09-30</code>, <code>2026-09-30 15:02</code>, <code>30 September 2026</code>, <code>Wednesday, 30 September 2026</code>, <code>2026-09-30T15:02:38+03:00</code></td><td>The date and time.</td></tr><tr><td>Number</td><td><code>12</code>, <code>-3.5</code>, <code>1,234.56</code>, <code>$ 12.04</code>, <code>21 RON</code>, <code>24.5m</code></td><td>The numeric value.</td></tr><tr><td>Text</td><td>Anything else.</td><td>Alphabetically, ignoring case, with numbers inside the text in numeric order (<code>Item 9</code> before <code>Item 10</code>). Accents count, so <code>a</code> and <code>á</code> differ.</td></tr><tr><td>Empty</td><td>An empty cell, or one holding only spaces.</td><td>Not compared. Empty cells always go last.</td></tr></tbody></table></figure><p>Ascending order puts times first, then dates, numbers and text. Descending order reverses it. Empty cells go last in both directions.</p><p>Numbers, dates and times with the same value are ordered by their text, so <code>5 apples</code> comes before <code>5 pears</code>. Rows whose cells hold the same text, ignoring case, keep their relative order.</p><ul><li>Dates are also recognized in the formats of the note's language, such as <code>30.09.2026</code> or <code>30. September 2026</code> for German, and in the format chosen in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Text Notes</em> → <em>Editor</em> → <em>Date/time format</em> for <a href=\"#root/_help_CohkqWQC1iBv\">inserting the date and time</a>.</li><li>A number can start with a currency symbol, such as <code>$</code>, <code>€</code> or <code>£</code>. Whatever follows the number, such as a unit, is ignored, so units are not converted: <code>1 km</code> sorts before <code>500 m</code>. A cell that starts with letters, such as <code>RON 21</code>, is text.</li><li>The decimal separator follows the language of the note: <code>1.500</code> is one and a half in English, but one thousand five hundred in German. A comma or period that is not followed by exactly three digits is always read as a decimal separator, so <code>1,5</code> is one and a half in either language.</li><li>The language of the note set in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>&nbsp;via the&nbsp;<span class=\"tn-icon bx bx-globe\"></span> icon, or else the default content language. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_veGu4faJErEM\">Content language &amp; Right-to-left support</a>.</li></ul><h3>Merged cells</h3><p>Rows joined by a merged cell are kept together and move as one block. The block is sorted by the value in its first row. When the block has more than one cell in the sorted column, the other cells do not affect the order, and a message says so: <em>Some rows were sorted together because merged cells tie them to each other</em>.</p><p>When the selection covers only part of such a block, the whole block is sorted.</p><h2>Merging cells</h2><p>To merge two or more cells together, simply select them via drag &amp; drop and press the&nbsp;<span class=\"tn-icon cke cke-table-merge-cell\"></span> button from the formatting toolbar.</p><p>More options are available by pressing the arrow next to it:</p><ul><li>Click on a single cell and select Merge cell up/down/right/left to merge with an adjacent cell.</li><li>Select <em>Merge selected cells</em> to merge the selected cells, the same as pressing the button itself.</li><li>Select <em>Split cell vertically</em> or <em>horizontally</em>, to split a cell into multiple cells (can also be used to undo a merge).</li><li>Select <em>Unmerge cells</em> to turn each merged cell in the selection back into the single cells it covers, keeping its content in the top-left one.</li></ul><p><em>Merge selected cells</em> and <em>Unmerge cells</em> are available since v0.107.0. Merging and splitting are also available by right-clicking the selected cells, via the <a href=\"#context-menu\">context menu</a>, where <em>Unmerge cells</em> is in the <em>Split cell</em> submenu.</p><h2>Table properties</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:312/311;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Tables_image.png\" width=\"312\" height=\"311\"></figure><p>The table properties can be accessed via the&nbsp;<span class=\"tn-icon cke cke-table-properties\"></span> button and allows for the following adjustments:</p><ul><li>Border (not the border of the cells, but the outer rim of the table), which includes the style (single, double), color and width.</li><li>The background color, with none set by default.</li><li>The width and height of the table in percentage (must end with <code>%</code>) or pixels (must end with <code>px</code>).</li><li>The alignment of the table.<ul><li>Left or right-aligned, case in which the text will flow next to it.</li><li>Centered, case in which text will avoid the table, regardless of the table width.</li></ul></li></ul><p>The table will immediately update to reflect the changes, but the <em>Save</em> button must be pressed for the changes to persist.</p><h2>Cell properties</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:320/386;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Tables_image.png\" width=\"320\" height=\"386\"></figure><p>Similarly to table properties, the&nbsp;<span class=\"tn-icon cke cke-table-cell-properties\"></span> button opens a popup which adjusts the styling of one or more cells (based on the user's selection).</p><p>The following options can be adjusted:</p><ul><li>The border style, color and width (same as table properties), but applying to the current cell only.</li><li>The background color, with none set by default.</li><li>The width and height of the cell in percentage (must end with <code>%</code>) or pixels (must end with <code>px</code>).</li><li>The padding (the distance of the text compared to the cell's borders).</li><li>The alignment of the text, both horizontally (left, centered, right, justified) and vertically (top, middle or bottom).</li></ul><p>The cell will immediately update to reflect the changes, but the <em>Save</em> button must be pressed for the changes to persist.</p><h2>Border and background colors</h2><p>The border and background colors of tables and cells adapt to the <a href=\"#root/_help_Wy267RK4M69c\">theme</a>, the same way as <a href=\"#root/_help_Gr6xFaF6ioJ5\">text colors</a> do. A color picked from the palette, chosen with the color picker or typed in is shown in a lighter or darker shade that suits the current theme, so borders stay visible and text stays readable on the background. The hue stays the same, and the table keeps the color as it was picked.</p><p>Colors applied with older versions of Trilium are shown exactly as they were picked, until the note is next edited.</p><p>Older browsers that can't adapt colors show them exactly as they were picked.</p><h2>Caption</h2><p>Press the&nbsp;<span class=\"tn-icon cke cke-caption\"></span> button to insert a caption or a text description of the table, which is going to be displayed above the table.</p><h2>Table borders</h2><p>By default, tables will come with a predefined gray border.</p><p>To adjust the borders, follow these steps:</p><ol><li>Select the table.</li><li>In the floating panel, select the <em>Table properties</em> option (<span class=\"tn-icon cke cke-table-properties\"></span>).<ol><li>Look for the <em>Border</em> section at the top of the newly opened panel.</li><li>This will control the outer borders of the table.</li><li>Select a style for the border. Generally <em>Single</em> is the desirable option.</li><li>Select a color for the border.</li><li>Select a width for the border, expressed in pixels.</li></ol></li><li>Select all the cells of the table and then press the <em>Cell properties</em> option (<span class=\"tn-icon cke cke-table-cell-properties\"></span>).<ol><li>This will control the inner borders of the table, at cell level.</li><li>Note that it's possible to change the borders individually by selecting one or more cells, case in which it will only change the borders that intersect these cells.</li><li>Repeat the same steps as from step (2).</li></ol></li></ol><h3>Tables with invisible borders</h3><p>Tables can be set to have invisible borders in order to allow for basic layouts (columns, grids) of text or <a href=\"#root/_help_mT0HEkOsz6i1\">images</a> without the distraction of their border:</p><ol><li>First insert a table with the desired number of columns and rows.</li><li>Select the entire table.</li><li>In <em>Table properties</em>, set:<ol><li><em>Style</em> to <em>Single</em></li><li><em>Color</em> to <code>transparent</code></li><li>Width to <code>1px</code>.</li></ol></li><li>In Cell Properties, set the same as on the previous step.</li></ol><h2>Table indentation</h2><p>Since v0.104.1, tables can be indented as a block (the whole table moves, rather than just the content of a cell).</p><ol><li>Click the&nbsp;<span style=\"--tn-color:hsl(0,0%,60%);color:hsl(0,0%,60%);\"><span class=\"tn-icon cke cke-drag-handle\"></span></span> button to select the entire table. Otherwise, the indentation applies only to the current cell's content.</li><li>Press <kbd>Tab</kbd> to increase the indent, or <kbd>Shift</kbd>+<kbd>Tab</kbd> to decrease it. Alternatively, use the indentation buttons in the formatting toolbar.</li></ol><p>Markdown does not support indented tables, so the indentation is lost when converting to Markdown.</p><h2>Markdown import/export</h2><p>Simple tables are exported in GitHub-flavored Markdown format (e.g. a series of <code>|</code> items). If the table is found to be more complex (it contains HTML elements, has custom sizes or images), the table is converted to a HTML one instead.</p><p>Generally formatting loss should be minimal when exported to Markdown due to the fallback to HTML formatting.</p>",
"_help_pwc194wlRzcH": "<figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:265/108;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Text%20Snippets_image.png\" width=\"265\" height=\"108\"></figure><p>Text Snippets are closely related to&nbsp;<a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>, but instead of defining the content of an entire note, text snippets are pieces of formatted text that can easily be inserted in a text note.</p><h2>Creating a text snippet</h2><p>In the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>: </p><ol><li>Right click a note where to place the text snippet.</li><li>Select <em>Insert child note</em>.</li><li>Select <em>More</em> → <em>Text snippet</em>.</li></ol><p>Afterwards, simply type in the content of the note the desired text. The text can be formatted in the same manner as a normal text note.</p><p>The title of the note will become the title of the template. Optionally, a description can be added in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a>&nbsp;section.</p><h2>Inserting a snippet</h2><p>Once a snippet is created, there are two options to insert it:</p><ol><li>From the&nbsp;<a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>, by looking for the&nbsp;<span class=\"tn-icon cke cke-trilium-template\"></span> button.</li><li>Using&nbsp;<a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>: <ol><li>To look for a specific template, start typing the name of the template (its title).</li><li>To look for all the templates, type <code>template</code>.</li></ol></li></ol><aside class=\"admonition tip\"><p>A newly created snippet doesn't appear? Generally it takes up to a few seconds to refresh the list of templates once you make a change.</p><p>If this doesn't happen, <a href=\"#root/_help_s8alTXmpFR61\">reload the application</a> and <a href=\"#root/_help_wy8So3yZZlH9\">report the issue</a>to us.&nbsp;</p></aside><h2>Limitations</h2><ul><li>Whenever a snippet is created, deleted or its title/description are modified, all the open text notes will need to be refreshed. This causes a slight flash for usually under a second, but it can cause some discomfort.</li><li>Unlike&nbsp;<a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>, the snippets cannot be limited to a particular <a href=\"#root/_help_9sRHySam5fXb\">workspace</a>.</li></ul>",
"_help_fASfBrYnquKU": "<h2>Extended task states</h2><figure class=\"image image-style-align-left\"><img style=\"aspect-ratio:303/264;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/To-do%20Lists_image.png\" width=\"303\" height=\"264\"></figure><p>In Trilium, to-do items aren't limited to a simple \"done\" or \"not done.\" Tasks can also be marked as <em>in progress</em> (\"doing\"), <em>under consideration</em> (\"maybe\"), or <em>cancelled</em> (\"won't do\"), thus giving a more accurate picture of where things actually stand.</p><p>Right-click the checkbox and select the desired state. Alternatively, press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Enter </kbd> to cycle through the task states. Tapping or left-clicking the checkbox will always toggle between \"None\" and \"Done\". On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the states are buttons in the row of the <em>List ›</em> button, which shows while the cursor is in the list.</p><p>Task states are fully preserved when converting between&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;and&nbsp;<a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a>&nbsp;notes, in both directions.</p><h3>Customizing the extended task states</h3><p>Task states are customizable: you can reorder them, create new ones with different colors and symbols, or delete the ones you don't need. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_i16PM6A7GXdU\">Customizing to-do task states</a>&nbsp;for more details.</p><h2>Keyboard shortcuts</h2><p>When at the beginning on an empty paragraph, type the following to insert a to-do list:</p><ul><li><code>[ ]</code> for an unchecked item</li><li><code>[x]</code> for a checked item</li></ul><p>Extended task states are supported as well, using its corresponding <em>Markdown symbol</em>. These are the defaults but they can be changed if needed (see&nbsp;<a class=\"reference-link\" href=\"#root/_help_i16PM6A7GXdU\">Customizing to-do task states</a>):</p><ul><li><code>[/]</code> for “Doing”.</li><li><code>[?]</code> for “Maybe”.</li><li><code>[-]</code> for “Cancelled”.</li></ul><p>To reorder the item under the cursor, press <kbd>Alt</kbd>+<kbd>Up</kbd> or <kbd>Alt</kbd>+<kbd>Down</kbd>. To reorder multiple items, select them first.</p><h2>See also</h2><ul><li>To-do lists are meant for small task lists. For more complicated, day-to-day task tracking consider using a&nbsp;<a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a>&nbsp;collection instead.</li></ul>",
- "_help_6f9hih2hXXZk": "<p>Trilium supports creating \"code\" notes, i.e. notes which contain some sort of formal code - be it programming language (C++, JavaScript), structured data (JSON, XML) or other types of codes (CSS etc.).</p><p>This can be useful for a few things:</p><ul><li>computer programmers can store code snippets as notes with syntax highlighting</li><li>JavaScript code notes can be executed inside Trilium for some extra functionality<ul><li>we call such JavaScript code notes \"scripts\" – see&nbsp;<a class=\"reference-link\" href=\"#root/_help_CdNpE2pqjmI6\">Scripting</a></li></ul></li><li>JSON, XML etc. can be used as storage for structured data (typically used in conjunction with scripting)</li></ul><p>For shorter snippets of code that can be embedded in&nbsp;<a href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes, see&nbsp;<a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a>.</p><p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Code_image.jpg\"></p><h2>Creating a code note</h2><p>In the <a href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, right-click a note and select <em>Insert child note</em> or <em>Insert note after</em>, then:</p><ul><li>To create a plain text code note, select <em>Code</em>.</li><li>To create a code note in a given language, hover <em>Code</em> and select the language. The list shows the languages enabled in the options (see below), and ends with <em>Configure code notes...</em>, which opens them.</li></ul><h2>Adjusting the language of a code note</h2><p>To change the language of a code note, look for the&nbsp;<span class=\"tn-icon bx bx-code\"></span> icon in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>. When clicked it will reveal the list of available languages (which can be customized according to the section below). The menu also features a search bar to quickly filter, and icons to visually distinguish some of the programming languages.</p><p>On the&nbsp;<a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the same list is available in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>&nbsp;→ <em>Note settings</em> → <em>Change language mode</em>.</p><h2>Adjusting the list of languages</h2><p>Trilium supports syntax highlighting for many languages, but by default displays only some of them. The supported languages can be adjusted by going to&nbsp;<a href=\"#root/_help_4TIF1oA4VQRO\">Options</a>, then <em>Code Notes</em> and looking for the <em>Available MIME types in the dropdown</em> section. Simply check any of the items to add them to the list, or un-check them to remove them from the list.</p><p>Note that the list of languages is not immediately refreshed, you'd have to manually <a href=\"#root/_help_s8alTXmpFR61\">refresh the application</a>.</p><p>The list of languages is also shared with the&nbsp;<a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a>&nbsp;feature of&nbsp;<a href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes.</p><h2>Word wrap</h2><p>Long lines can be displayed on multiple lines:</p><ul><li>Globally for all code notes, from&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Code Notes.</em></li><li>For a particular note, by going to the menu in&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>&nbsp;and selecting <em>Word wrap</em> and selecting the appropriate option:<ul><li><em>Auto</em>, to respect the global word wrap for code notes.</li><li><em>On</em> or <em>Off</em>, to change the state of the word wrap for this note regardless of the global option.</li></ul></li></ul><aside class=\"admonition note\"><p>Word wrapping can also be adjusted at note level through the <code>#wrapLines</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a>, which can also be inherited.</p></aside><h2>Line numbers</h2><p>The numbers at the start of each line can be hidden from <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> → <em>Editor</em> → <em>Line numbers</em>. The setting applies to every code editor, such as the source of a <a href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> note, and to code shown without its editor (see <em>Color schemes</em> below).</p><p>An included code note or an embedded code file can show or hide them on its own through the <em>Line numbers</em> submenu of its <em>More actions</em> menu, see <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>. Its <em>Auto</em> entry follows the setting.</p><h2>Adjusting options using the status bar</h2><p>The status bar at the bottom of the editor shows the position of the cursor, the current indentation settings and language.</p><p>The cursor position is shown as <em>Ln</em> (the line) and <em>Col</em> (the column), both counted from 1. A tab counts as many columns as the display width of tabs, so the column matches where the cursor appears on screen. While text is selected, <em>Selected</em> shows the number of selected characters, counting each line break as one.</p><p>Clicking on the indentation indicator opens a menu with three sections:</p><ol><li><em>Indent Using</em> — switch between Spaces and Tabs (<code>#indentWithTabs</code>). If a per-note override is active, a \"Reset to default\" option appears.</li><li><em>Display Width</em> — choose from preset widths (1, 2, 3, 4, 6, 8). Changes are saved as a per-note <code>#tabWidth</code> label.</li><li><em>Re-indent Content To</em> — convert existing indentation to a different style. For example, re-indent a file from 4 spaces to 2 spaces, or from spaces to tabs. This rewrites the leading whitespace on every line while preserving alignment remainders.</li></ol><p>Clicking the language indicator lets you change the note's MIME type. As in the <em>Note type</em> selector, typing narrows the list of languages.</p><p>The same two menus are in the toolbar of a code note or a code file included in a text note, see&nbsp;<a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>.</p><h3>Re-indentation</h3><p>When you re-indent content, the editor:</p><ul><li>Measures the visual column width of each line's leading whitespace using the current style</li><li>Calculates indent levels and any alignment remainder</li><li>Rebuilds the leading whitespace in the target style</li><li>Preserves non-leading whitespace, blank lines, and content without indentation</li></ul><h2>Transforming text</h2><p>To change the selected lines or text, right-click the selection and open <em>Transform</em>. Its commands come in three groups:</p><ul><li><em>Sort ascending</em>, <em>Sort descending</em>, <em>Shuffle lines</em>, <em>Reverse line order</em> and <em>Deduplicate lines</em>, which keeps the first copy of each line.</li><li><em>Trim leading</em>, <em>Trim trailing</em> and <em>Trim both</em> remove the whitespace at the start, at the end or at both ends of each line. <em>Remove blank lines</em> also removes the lines that hold only whitespace.</li><li><em>To uppercase</em>, <em>To lowercase</em>, <em>To sentence case</em>, <em>To title case</em> and <em>Remove diacritics</em>.</li></ul><p>The commands of the first two groups change every line that the selection touches, even partly. Those of the third group change only the selected text. Each change is undone in one step with <kbd>Ctrl</kbd>+<kbd>Z</kbd>.</p><ul><li>Sorting reads numbers, dates and times by their value, as sorting a table does (see <a class=\"reference-link\" href=\"#root/_help_NdowYOC1GFKS\">Tables</a>), and ignores the case of letters and the indentation. Blank lines go last.</li><li><em>To sentence case</em> lowercases the text and capitalizes the first word of each sentence and of each line. <em>To title case</em> capitalizes every word except minor words such as \"of\" and \"the\", which stay lowercase unless they start or end a sentence.</li><li><em>Remove diacritics</em> turns letters such as <code>é</code>, <code>ș</code> and <code>ł</code> into <code>e</code>, <code>s</code> and <code>l</code>, and removes the vowel points of Hebrew and Arabic. Letters such as <code>ß</code> and <code>æ</code> stay as they are.</li><li>Sorting and the case changes follow the language set in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Language &amp; Region</em> → <em>Default content language</em>. In Turkish, for example, an uppercase <code>i</code> is <code>İ</code>.</li></ul><h2>Color schemes</h2><p>Since Trilium 0.94.0 the colors of code notes can be customized by going&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ Code Notes and looking for the <em>Appearance</em> section.</p><p>A code note or a code file shown without its editor, such as in an&nbsp;<a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>, on the cards of&nbsp;<a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> or in a tooltip, uses the same colors and line numbers as the editor does. A printout uses the <em>Light theme</em>. A <a href=\"#root/_help_R9pX4DGra2Vt\">shared page</a> uses the VS Code light or dark theme, following the mode of the page.</p><aside class=\"admonition note\"><p><strong>Why are there only a few themes whereas the code block themes for text notes have a lot?</strong><br>The reason is that Code notes use a different technology than the one used in Text notes, and as such there is a more limited selection of themes. If you find a CodeMirror 6 (not 5) theme that you would like to use, let us know and we might consider adding it to the set of default themes. There is no possibility of adding new themes (at least for now), since the themes are defined in JavaScript and not at CSS level.</p></aside><h2>Programming ligatures</h2><p>If you see <code>!=</code> displayed as <code>≠</code> or <code>-&gt;</code> as <code>→</code> inside a code note, those are <em>font ligature</em>: the default monospace font draws certain character pairs as a single symbol. The underlying text is not changed by Trilium (unlike text notes which have&nbsp;<a class=\"reference-link\" href=\"#root/_help_oI7GoyilXXAr\">Automatic replacements</a>), and copying it out gives you back <code>!=</code> and <code>-&gt;</code>.</p><p>This can be turned off with&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a><em>→ Appearance → Fonts → Programming ligatures</em>.</p><h2>Virtual keyboard behavior</h2><p>When using a virtual keyboard, keyboard suggestions and corrections are controlled as follows:</p><ul><li>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a>&nbsp;and plain text code notes, the autocorrect is <strong>on</strong>, as well as automatic capitalization.</li><li>For all the other code notes, the autocorrect is off in order to avoid issues when typing code.</li></ul><aside class=\"admonition note\"><p>Not all browsers and platforms respect this value, so the keyboard suggestions might appear without autocorrecting or the browser might disregard this and autocorrect anyway.</p></aside>",
+ "_help_6f9hih2hXXZk": "<p>Trilium supports creating \"code\" notes, i.e. notes which contain some sort of formal code - be it programming language (C++, JavaScript), structured data (JSON, XML) or other types of codes (CSS etc.).</p><p>This can be useful for a few things:</p><ul><li>computer programmers can store code snippets as notes with syntax highlighting</li><li>JavaScript code notes can be executed inside Trilium for some extra functionality<ul><li>we call such JavaScript code notes \"scripts\" – see&nbsp;<a class=\"reference-link\" href=\"#root/_help_CdNpE2pqjmI6\">Scripting</a></li></ul></li><li>JSON, XML etc. can be used as storage for structured data (typically used in conjunction with scripting)</li></ul><p>For shorter snippets of code that can be embedded in&nbsp;<a href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes, see&nbsp;<a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a>.</p><p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Code_image.jpg\"></p><h2>Creating a code note</h2><p>In the <a href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, right-click a note and select <em>Insert child note</em> or <em>Insert note after</em>, then:</p><ul><li>To create a plain text code note, select <em>Code</em>.</li><li>To create a code note in a given language, hover <em>Code</em> and select the language. The list shows the languages enabled in the options (see below), and ends with <em>Configure code notes...</em>, which opens them.</li></ul><h2>Adjusting the language of a code note</h2><p>To change the language of a code note, look for the&nbsp;<span class=\"tn-icon bx bx-code\"></span> icon in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>. When clicked it will reveal the list of available languages (which can be customized according to the section below). The menu also features a search bar to quickly filter, and icons to visually distinguish some of the programming languages.</p><p>On the&nbsp;<a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the same list is available in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>&nbsp;→ <em>Note settings</em> → <em>Change language mode</em>.</p><h2>Adjusting the list of languages</h2><p>Trilium supports syntax highlighting for many languages, but by default displays only some of them. To change which languages are offered, go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> and find <em>Available MIME types in the dropdown</em>. Here you can:</p><ul><li>Add a language by pressing the <span class=\"tn-icon bx bx-plus\"></span> <em>Add another language</em> button, which also shows how many languages are left, and then selecting it. While picking, hover a language to see where it is syntax highlighted.</li><li>Press the <span class=\"tn-icon bx bx-x\"></span> button beside a language, or select it and press <kbd>Delete</kbd>, to remove it from the list. <em>Plain text</em> cannot be removed.</li><li>See where each language is syntax highlighted: the <em>Code blocks</em> badge stands for code blocks in text notes, the <em>Code notes</em> badge for code notes.</li></ul><p>The languages are listed in the same order wherever you choose one: the language menu in the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>, the <em>Code</em> submenu when creating a note, and the language of a code block. By default, the list is sorted alphabetically, with <em>Plain text</em> first. To use an order of your own:</p><ol><li>Turn off the <em>Sort alphabetically</em> switch at the top of the section.</li><li>Hold the <strong>=</strong> handle shown beside a language, and then drag it up or down. Alternatively, select a language and press <kbd>Ctrl</kbd>+<kbd>↑</kbd> or <kbd>Ctrl</kbd>+<kbd>↓</kbd>.</li></ol><p>Turning <em>Sort alphabetically</em> back on does not discard your order: it is used again the next time the switch is turned off.</p><p>Note that the list of languages is not immediately refreshed, you'd have to manually <a href=\"#root/_help_s8alTXmpFR61\">refresh the application</a>.</p><p>The list of languages is also shared with the&nbsp;<a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a>&nbsp;feature of&nbsp;<a href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes.</p><h2>Word wrap</h2><p>Long lines can be displayed on multiple lines:</p><ul><li>Globally for all code notes, from&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Code Notes.</em></li><li>For a particular note, by going to the menu in&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>&nbsp;and selecting <em>Word wrap</em> and selecting the appropriate option:<ul><li><em>Auto</em>, to respect the global word wrap for code notes.</li><li><em>On</em> or <em>Off</em>, to change the state of the word wrap for this note regardless of the global option.</li></ul></li></ul><aside class=\"admonition note\"><p>Word wrapping can also be adjusted at note level through the <code>#wrapLines</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a>, which can also be inherited.</p></aside><h2>Line numbers</h2><p>The numbers at the start of each line can be hidden from <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> → <em>Editor</em> → <em>Line numbers</em>. The setting applies to every code editor, such as the source of a <a href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> note, and to code shown without its editor (see <em>Color schemes</em> below).</p><p>An included code note or an embedded code file can show or hide them on its own through the <em>Line numbers</em> submenu of its <em>More actions</em> menu, see <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>. Its <em>Auto</em> entry follows the setting.</p><h2>Adjusting options using the status bar</h2><p>The status bar at the bottom of the editor shows the position of the cursor, the current indentation settings and language.</p><p>The cursor position is shown as <em>Ln</em> (the line) and <em>Col</em> (the column), both counted from 1. A tab counts as many columns as the display width of tabs, so the column matches where the cursor appears on screen. While text is selected, <em>Selected</em> shows the number of selected characters, counting each line break as one.</p><p>Clicking on the indentation indicator opens a menu with three sections:</p><ol><li><em>Indent Using</em> — switch between Spaces and Tabs (<code>#indentWithTabs</code>). If a per-note override is active, a \"Reset to default\" option appears.</li><li><em>Display Width</em> — choose from preset widths (1, 2, 3, 4, 6, 8). Changes are saved as a per-note <code>#tabWidth</code> label.</li><li><em>Re-indent Content To</em> — convert existing indentation to a different style. For example, re-indent a file from 4 spaces to 2 spaces, or from spaces to tabs. This rewrites the leading whitespace on every line while preserving alignment remainders.</li></ol><p>Clicking the language indicator lets you change the note's MIME type. As in the <em>Note type</em> selector, typing narrows the list of languages.</p><p>The same two menus are in the toolbar of a code note or a code file included in a text note, see&nbsp;<a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>.</p><h3>Re-indentation</h3><p>When you re-indent content, the editor:</p><ul><li>Measures the visual column width of each line's leading whitespace using the current style</li><li>Calculates indent levels and any alignment remainder</li><li>Rebuilds the leading whitespace in the target style</li><li>Preserves non-leading whitespace, blank lines, and content without indentation</li></ul><h2>Transforming text</h2><p>To change the selected lines or text, right-click the selection and open <em>Transform</em>. Its commands come in three groups:</p><ul><li><em>Sort ascending</em>, <em>Sort descending</em>, <em>Shuffle lines</em>, <em>Reverse line order</em> and <em>Deduplicate lines</em>, which keeps the first copy of each line.</li><li><em>Trim leading</em>, <em>Trim trailing</em> and <em>Trim both</em> remove the whitespace at the start, at the end or at both ends of each line. <em>Remove blank lines</em> also removes the lines that hold only whitespace.</li><li><em>To uppercase</em>, <em>To lowercase</em>, <em>To sentence case</em>, <em>To title case</em> and <em>Remove diacritics</em>.</li></ul><p>The commands of the first two groups change every line that the selection touches, even partly. Those of the third group change only the selected text. Each change is undone in one step with <kbd>Ctrl</kbd>+<kbd>Z</kbd>.</p><ul><li>Sorting reads numbers, dates and times by their value, as sorting a table does (see <a class=\"reference-link\" href=\"#root/_help_NdowYOC1GFKS\">Tables</a>), and ignores the case of letters and the indentation. Blank lines go last.</li><li><em>To sentence case</em> lowercases the text and capitalizes the first word of each sentence and of each line. <em>To title case</em> capitalizes every word except minor words such as \"of\" and \"the\", which stay lowercase unless they start or end a sentence.</li><li><em>Remove diacritics</em> turns letters such as <code>é</code>, <code>ș</code> and <code>ł</code> into <code>e</code>, <code>s</code> and <code>l</code>, and removes the vowel points of Hebrew and Arabic. Letters such as <code>ß</code> and <code>æ</code> stay as they are.</li><li>Sorting and the case changes follow the language set in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Language &amp; Region</em> → <em>Default content language</em>. In Turkish, for example, an uppercase <code>i</code> is <code>İ</code>.</li></ul><h2>Color schemes</h2><p>Since Trilium 0.94.0 the colors of code notes can be customized by going&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ Code Notes and looking for the <em>Appearance</em> section.</p><p>A code note or a code file shown without its editor, such as in an&nbsp;<a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>, on the cards of&nbsp;<a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> or in a tooltip, uses the same colors and line numbers as the editor does. A printout uses the <em>Light theme</em>. A <a href=\"#root/_help_R9pX4DGra2Vt\">shared page</a> uses the VS Code light or dark theme, following the mode of the page.</p><aside class=\"admonition note\"><p><strong>Why are there only a few themes whereas the code block themes for text notes have a lot?</strong><br>The reason is that Code notes use a different technology than the one used in Text notes, and as such there is a more limited selection of themes. If you find a CodeMirror 6 (not 5) theme that you would like to use, let us know and we might consider adding it to the set of default themes. There is no possibility of adding new themes (at least for now), since the themes are defined in JavaScript and not at CSS level.</p></aside><h2>Programming ligatures</h2><p>If you see <code>!=</code> displayed as <code>≠</code> or <code>-&gt;</code> as <code>→</code> inside a code note, those are <em>font ligature</em>: the default monospace font draws certain character pairs as a single symbol. The underlying text is not changed by Trilium (unlike text notes which have&nbsp;<a class=\"reference-link\" href=\"#root/_help_oI7GoyilXXAr\">Automatic replacements</a>), and copying it out gives you back <code>!=</code> and <code>-&gt;</code>.</p><p>This can be turned off with&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a><em>→ Appearance → Fonts → Programming ligatures</em>.</p><h2>Virtual keyboard behavior</h2><p>When using a virtual keyboard, keyboard suggestions and corrections are controlled as follows:</p><ul><li>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a>&nbsp;and plain text code notes, the autocorrect is <strong>on</strong>, as well as automatic capitalization.</li><li>For all the other code notes, the autocorrect is off in order to avoid issues when typing code.</li></ul><aside class=\"admonition note\"><p>Not all browsers and platforms respect this value, so the keyboard suggestions might appear without autocorrecting or the browser might disregard this and autocorrect anyway.</p></aside>",
"_help_m523cpzocqaD": "<p>Trilium allows you to save common searches as notes within the note tree. The search results will appear as sub-notes under these \"saved search\" notes. Here is an example of how it works:</p><figure class=\"image image-style-align-center image_resized\" style=\"width:50%;\"><img style=\"aspect-ratio:812/585;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Saved%20Search_saved-search.gif\" width=\"812\" height=\"585\"></figure><p>A saved search runs when you open it, and when you expand it in the note tree. A saved search in a tab that is not shown, such as a background tab restored at startup, runs when you switch to that tab. Its results stay until you run the search again with the <em>Search</em> button of the search parameters. If the query has an error, it appears as a notification.</p><p>In&nbsp;<a class=\"reference-link\" href=\"#root/_help_64ZTlUPgEPtW\">Safe mode</a>, and when the request fails, the search does not run on its own. Press <em>Search now</em> to run it.</p><p>Once a search is saved, the <em>Search parameters</em> is still available underneath the&nbsp;<a class=\"reference-link\" href=\"#root/_help_l7pigIGu01K2\">Title</a>&nbsp;in order to be able to change the settings later on but it will appear collapsed by default.</p><h2>Location</h2><p>By default, saved searches are stored in the day note. However, you can designate a different note to store saved searches by marking it with the <code>#searchHome</code> label. Additionally, for <a href=\"#root/_help_9sRHySam5fXb\">workspaces</a>, you can use the <code>#workspaceSearchHome</code> label to specify a storage location for saved searches within that workspace.</p>",
"_help_iRwzGnHPzonm": "<p>Relation map is a type of&nbsp;note&nbsp;which visualizes notes and their <a href=\"#root/_help_zEY4DaJG4YT5\">relations</a>.</p><h2>Interaction</h2><ul><li>To create a new note and add it to the map, press the <span class=\"tn-icon bx bx-note\"></span> <em>Add note</em> button at the bottom of the map, then click anywhere on the map to place it there.<ul><li>While the map waits for the click, a translucent box follows the mouse to show where the note will go. To cancel, press the button again (now labeled <em>Cancel</em>) or press <kbd>Esc</kbd>.</li><li>The note is created as a child of the map, with the default title of a new note. It opens in the note panel (see below) with its title selected, so you can type its name straight away.</li></ul></li><li>An existing note can also be dragged from the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>. It will be placed at the position it's dragged on.<ul><li>Multiple notes can also be dragged via&nbsp;<a class=\"reference-link\" href=\"#root/_help_yTjUdsOi4CIE\">Multiple selection</a>. The notes will be positioned near the dragged position without overlapping.</li><li>The dragged note can be a sub-child of the map, or it can be at any arbitrary position.</li></ul></li><li>Notes can also be pasted onto the map. Copy or cut them in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, then click the map and press <kbd>Ctrl</kbd>+<kbd>V</kbd>, or right click an empty part of the map and select <em>Paste note(s)</em>.<ul><li>With <kbd>Ctrl</kbd>+<kbd>V</kbd>, the notes are placed under the mouse, or in the middle of the map if the mouse is not over it. From the right click menu, they are placed where the menu was opened.</li><li>Copied notes stay where they are in the tree. Cut notes are moved under the map, as if they had been pasted into it in the tree.</li><li>Links to notes, such as an <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> copied from a text note, can be pasted the same way. If the clipboard holds no link to a note, the notes last copied or cut in the tree are pasted.</li><li>The right click menu of an empty part of the map also has <em>Add note</em>, which creates a new note where the menu was opened.</li></ul></li><li>To create a relationship, hold the mouse on the dot on the right of a note and then:<ul><li>Drag it over another note to create a relationship pointing from the first note to the second one.</li><li>Drag over the same note to create a self-referencing relationship (represented as a loop).</li><li>Once dragged, a popover next to the relationship asks for its name. Type a new name and press <kbd>Enter</kbd>, or pick a relation name already in use from the suggestions. To cancel, press <kbd>Esc</kbd>, close the popover or click elsewhere on the map.</li></ul></li><li>Each note is shown as a card with its icon and title, colored in the note's color the same way as the cards of a <a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a>.</li><li>Hovering a note highlights its relationships, in the note's color if it has one, and fades the other relationships.</li><li>To view or edit a note, click it on the map. This opens the note panel (see below).<ul><li>To open the note in a new tab instead, <kbd>Ctrl</kbd>+click it or click it with the middle mouse button. <kbd>Shift</kbd>+click opens it in a new window. The right click menu offers the same options.</li></ul></li><li>To edit the title of a note, change its color or delete it (either from the map, or delete it completely), right click the note.</li><li>To rename or delete a relationship, right click it and select the corresponding option.</li><li>On a <a href=\"#root/_help_CoFPLs3dRlXc\">read-only</a> map, notes cannot be moved and relationships cannot be drawn, renamed or deleted. The right click menu of a note only offers to open it, and a relationship has no right click menu.</li><li>To move around the map, drag an empty part of it, and zoom with the mouse wheel or the <span class=\"tn-icon bx bx-minus-circle\"></span> and <span class=\"tn-icon bx bx-plus-circle\"></span> buttons at the bottom-right corner. Clicking the zoom percentage goes back to 100%, and <span class=\"tn-icon bx bx-scan\"></span> <em>Fit to view</em> zooms and pans so that all the notes are visible.<ul><li>Once the map has been clicked, the arrow keys or <kbd>W</kbd> <kbd>A</kbd> <kbd>S</kbd> <kbd>D</kbd> pan it, and <kbd>+</kbd> and <kbd>-</kbd> zoom it. The <kbd>?</kbd> button at the top-right corner of the map lists all its keyboard shortcuts.</li></ul></li></ul><h2>Note panel</h2><p>When a note on the map is clicked, a panel opens to the right of the map and the note is highlighted. If the panel would cover the note, or the note is partly off-screen, the map pans to bring it into view. The panel contains:</p><ul><li>The title and icon of the note, both editable.</li><li>A <span class=\"tn-icon bx bx-expand-alt\"></span> button to expand the panel over the whole map, and to restore it afterwards.</li><li>Buttons to interact with the note:<ul><li><span class=\"tn-icon bx bx-log-in\"></span> Open the note in the current tab, or, through the <span class=\"tn-icon bx bx-dots-horizontal-rounded\"></span> menu, in a new tab, split, window or the quick edit popup.</li><li>A <span class=\"tn-icon bx bx-palette\"></span> color picker to change the color of the note.</li><li>A <span class=\"tn-icon bx bx-trash\"></span> button to remove the note from the map, which can optionally delete the note as well.</li></ul></li><li>The <a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a> of the note, if any.</li><li>The note's content, which can be edited directly from the panel.</li></ul><p>The color picker and the remove button are not shown if the map is read-only.</p><p>Clicking another note on the map switches the panel to it. Similarly, clicking an <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> inside the panel switches the panel to that note, as long as it is on the map.</p><p>To close the panel, press the <span class=\"tn-icon bx bx-x\"></span> button at its top-right, click an empty part of the map, or press <kbd>Esc</kbd>.</p><p>On mobile, the note opens as a dialog over the whole screen instead of a panel.</p><h2>Development process demo</h2><p>This is a basic example how you can create simple diagram using relation maps:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Relation%20Map_relation-map-dev-process.png\" width=\"934\" height=\"667\"><p>And this is how you can create it:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Relation%20Map_relation-map-dev-process-demo.gif\" width=\"812\" height=\"585\"><p>We start completely from scratch by first creating new note called \"Development process\" and changing its type to \"Relation map\". After that we create new notes one by one and place them by clicking into the map. We also drag <a href=\"#root/_help_zEY4DaJG4YT5\">relations</a>between notes and name them. That's all!</p><p>Items on the map - \"Specification\", \"Development\", \"Testing\" and \"Demo\" are actually notes which have been created under \"Development process\" note - you can click on them and write some content. Connections between notes are called \"<a href=\"#root/_help_zEY4DaJG4YT5\">relations</a>\".</p><h2>Family demo</h2><p>This is more complicated demo using some advanced concepts. Resulting diagram is here:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Relation%20Map_relation-map-family.png\" width=\"941\" height=\"758\"><p>This is how you get to it:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Relation%20Map_relation-map-family-demo.gif\" width=\"812\" height=\"585\"><p>There are several steps here:</p><ul><li>we start with empty relation map and two existing notes representing Prince Philip and Queen Elizabeth II. These two notes already have <code>isPartnerOf</code> <a href=\"#root/_help_zEY4DaJG4YT5\">relations</a>defined.<ul><li>There are actually two \"inverse\" relations (one from Philip to Elizabeth and one from Elizabeth to Philip)</li></ul></li><li>we drag both notes to relation map and place to suitable position. Notice how the existing <code>isPartnerOf</code> relations are displayed.</li><li>now we create new note - we name it \"Prince Charles\" and place it on the relation map by clicking on the desired position. The note is by default created under the relation map note (visible in the note tree on the left).</li><li>we create two new relations <code>isChildOf</code> targeting both Philip and Elizabeth<ul><li>now there's something unexpected - we can also see the relation to display another <code>hasChild</code> relation. This is because there's a <a href=\"#root/_help_OFXdgB2nNk1F\">relation definition</a> which puts <code>isChildOf</code> as an \"<a href=\"#root/_help_OFXdgB2nNk1F\">inverse</a>\" relation of <code>hasChildOf</code> (and vice versa) and thus it is created automatically.</li></ul></li><li>we create another note for Princess Diana and create <code>isPartnerOf</code> relation from Charles. Again notice how the relation has arrows both ways - this is because <code>isPartnerOf</code> definition specifies its inverse relation as again \"isPartnerOf\" so the opposite relation is created automatically.</li><li>as the last step we pan &amp; zoom the map to fit better to window dimensions.</li></ul><p>Relation definitions mentioned above come from \"Person template\" note which is assigned to any child of \"My Family Tree\" relation note. You can play with the whole thing in the <a href=\"#root/_help_wX4HbRucYSDD\">demo notes</a>.</p><h2>Details</h2><p>You can specify which relations should be displayed with comma delimited names of relations in <code>displayRelations</code> label.</p><p>Alternatively, you can specify comma delimited list of relation names in <code>hideRelations</code> which will display all relations, except for the ones defined in the label.</p><h2>See also</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_bdUJEHsAPYQR\">Note Map</a>&nbsp;is a similar concept.</li></ul>",
"_help_bdUJEHsAPYQR": "<figure class=\"image image_resized\" style=\"width:72.68%;\"><img style=\"aspect-ratio:1311/1271;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Note%20Map_image.png\" width=\"1311\" height=\"1271\"></figure><p>A Note map is a note type which displays a standalone version of the feature of the same name:&nbsp;<a class=\"reference-link\" href=\"#root/_help_BCkXAVs63Ttv\">Note Map (Link map, Tree map)</a>. Consult that page for more information on how the note map works and what it displays.</p><p>Once created, the note map will display the relations between notes. Only the notes that are part of the parent of the note map will be displayed (including their children).</p><h2>Root note</h2><p>The root note defines the starting point of the graph, from which the relations and the hierarchy are derived from.</p><p>There are three possible root notes:</p><ul><li>The default root note is the parent note of the note map.</li><li>To use the currently <a href=\"#root/_help_OR8WJ7Iz9K4U\">hoisted note</a> instead, set the <code>mapRootNoteId</code> label to <code>hoisted</code>.</li><li>To use a specific note instead, set <code>mapRootNoteId</code> to the&nbsp;<a class=\"reference-link\" href=\"#root/_help_m1lbrzyKDaRB\">Note ID</a>&nbsp;of the desired note.</li></ul><h2>Customization</h2><p>The note map can be customized using the following&nbsp;<a class=\"reference-link\" href=\"#root/_help_HI6GBBIduIgv\">Labels</a>:</p><figure class=\"table\"><table><thead><tr><th>Label</th><th>Description</th></tr></thead><tbody><tr><td><code>#mapIncludeRelation</code></td><td>Comma-delimited relation names to include from the note map.</td></tr><tr><td><code>#mapExcludeRelation</code></td><td>Comma-delimited relation names to exclude from the note map.</td></tr><tr><td><code>#mapRootNoteId</code></td><td>The ID of the note the map roots from, or <code>hoisted</code>. See the root note section above for more information.</td></tr></tbody></table></figure>",
diff --git a/docs/User Guide/User Guide/Note Types/Code.md b/docs/User Guide/User Guide/Note Types/Code.md
index 43ac553db3..25e515595d 100644
--- a/docs/User Guide/User Guide/Note Types/Code.md
+++ b/docs/User Guide/User Guide/Note Types/Code.md
@@ -27,7 +27,18 @@ On the <a class="reference-link" href="../Installation%20%26%20Setup/Mobile%20F
## Adjusting the list of languages
-Trilium supports syntax highlighting for many languages, but by default displays only some of them. The supported languages can be adjusted by going to [Options](../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md), then _Code Notes_ and looking for the _Available MIME types in the dropdown_ section. Simply check any of the items to add them to the list, or un-check them to remove them from the list.
+Trilium supports syntax highlighting for many languages, but by default displays only some of them. To change which languages are offered, go to <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a> → _Code Notes_ and find _Available MIME types in the dropdown_. Here you can:
+
+* Add a language by pressing the <span class="tn-icon bx bx-plus"></span> _Add another language_ button, which also shows how many languages are left, and then selecting it. While picking, hover a language to see where it is syntax highlighted.
+* Press the <span class="tn-icon bx bx-x"></span> button beside a language, or select it and press <kbd>Delete</kbd>, to remove it from the list. _Plain text_ cannot be removed.
+* See where each language is syntax highlighted: the _Code blocks_ badge stands for code blocks in text notes, the _Code notes_ badge for code notes.
+
+The languages are listed in the same order wherever you choose one: the language menu in the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Status%20bar.md">Status bar</a>, the _Code_ submenu when creating a note, and the language of a code block. By default, the list is sorted alphabetically, with _Plain text_ first. To use an order of your own:
+
+1. Turn off the _Sort alphabetically_ switch at the top of the section.
+2. Hold the **\=** handle shown beside a language, and then drag it up or down. Alternatively, select a language and press <kbd>Ctrl</kbd>+<kbd>↑</kbd> or <kbd>Ctrl</kbd>+<kbd>↓</kbd>.
+
+Turning _Sort alphabetically_ back on does not discard your order: it is used again the next time the switch is turned off.
Note that the list of languages is not immediately refreshed, you'd have to manually [refresh the application](../Troubleshooting/Refreshing%20the%20application.md).
diff --git a/docs/User Guide/User Guide/Note Types/Text/Developer-specific formatting/Code blocks.md b/docs/User Guide/User Guide/Note Types/Text/Developer-specific formatting/Code blocks.md
index 03b55774b6..9ac2f435ac 100644
--- a/docs/User Guide/User Guide/Note Types/Text/Developer-specific formatting/Code blocks.md
+++ b/docs/User Guide/User Guide/Note Types/Text/Developer-specific formatting/Code blocks.md
@@ -66,7 +66,7 @@ Simply click anywhere inside the code block and press again the code block butto
The code blocks feature shares the list of languages with the <a class="reference-link" href="../../Code.md">Code</a> note type.
-The supported languages can be adjusted by going to <a class="reference-link" href="../../../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a>, then _Code Notes_ and looking for the _Available MIME types in the dropdown_ section. Simply check any of the items to add them to the list, or uncheck them to remove them from the list.
+The supported languages, and the order in which they are listed, can be adjusted by going to <a class="reference-link" href="../../../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a> → _Code Notes_ → _Available MIME types in the dropdown_. See <a class="reference-link" href="../../Code.md">Code</a> for how to add, remove and reorder them.
Note that the list of languages is not immediately refreshed, you'd have to manually [refresh the application](../../../Troubleshooting/Refreshing%20the%20application.md).
diff --git a/packages/commons/src/lib/options_interface.ts b/packages/commons/src/lib/options_interface.ts
index 968c1dafff..df506d3a13 100644
--- a/packages/commons/src/lib/options_interface.ts
+++ b/packages/commons/src/lib/options_interface.ts
@@ -265,6 +265,11 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi
codeBlockTabWidth: number;
codeNoteTabWidth: number;
codeNoteIndentWithTabs: boolean;
+ /**
+ * Whether the code language lists are sorted by name. Off, they follow the order of
+ * {@link codeNotesMimeTypes}, which sorting leaves unchanged.
+ */
+ codeNotesMimeTypesSortAlphabetically: boolean;
textNoteEditorMultilineToolbar: boolean;
/**
* Which marks a typed `"…"` becomes: `auto` to follow the note's content language, `off` to
diff --git a/packages/commons/src/lib/script_api.ts b/packages/commons/src/lib/script_api.ts
index e3819dd726..7c6d4f6311 100644
--- a/packages/commons/src/lib/script_api.ts
+++ b/packages/commons/src/lib/script_api.ts
@@ -23,6 +23,8 @@ export interface PickerItem {
caption: string;
/** An icon class, `bx` prefix included. */
icon?: string;
+ /** HTML shown in a tooltip while the item is hovered. */
+ tooltip?: string;
}
/** A run of picker items under a heading of their own. */
diff --git a/packages/commons/src/lib/script_api_preact.ts b/packages/commons/src/lib/script_api_preact.ts
index ad6c33f012..a9143c7104 100644
--- a/packages/commons/src/lib/script_api_preact.ts
+++ b/packages/commons/src/lib/script_api_preact.ts
@@ -443,6 +443,8 @@ interface SortableCardProps<T extends SortableItem> {
itemCreationButtons?: ItemCreationButton<T>[];
/** Which edge of a segment the grip stands on. The trailing one by default. */
gripPlacement?: "start" | "end";
+ /** Whether the reader can reorder the entries. Off, the card has no grip. True by default. */
+ isReorderable?: boolean;
/** Called with the focused entry for a key the card does not handle itself. */
onItemKeyDown?: (item: T, event: KeyboardEvent) => void;
selectedKey?: string;
diff --git a/packages/trilium-core/src/routes/api/options.ts b/packages/trilium-core/src/routes/api/options.ts
index ce964363f7..b85cf9b55a 100644
--- a/packages/trilium-core/src/routes/api/options.ts
+++ b/packages/trilium-core/src/routes/api/options.ts
@@ -70,6 +70,7 @@ const ALLOWED_OPTIONS = new Set<OptionNames>([
"transcriptionSpeakersEnabled",
"transcriptionKeepRecordings",
"codeNotesMimeTypes",
+ "codeNotesMimeTypesSortAlphabetically",
"contentManagerSortOrder",
"contentManagerViewMode",
"spellCheckEnabled",
diff --git a/packages/trilium-core/src/services/options_init.ts b/packages/trilium-core/src/services/options_init.ts
index 48f599758b..c23cb9c483 100644
--- a/packages/trilium-core/src/services/options_init.ts
+++ b/packages/trilium-core/src/services/options_init.ts
@@ -196,6 +196,7 @@ const defaultOptions: DefaultOption[] = [
value: '["text/x-csrc","text/x-c++src","text/x-csharp","text/css","text/x-elixir","text/x-go","text/x-groovy","text/x-haskell","text/html","message/http","text/x-java","text/javascript","application/javascript;env=frontend","application/javascript;env=backend","application/json","text/x-kotlin","text/x-markdown","text/x-perl","text/x-php","text/x-python","text/x-ruby",null,"text/x-sql","text/x-sqlite;schema=trilium","text/x-swift","text/xml","text/x-yaml","text/x-sh","application/typescript"]',
isSynced: true
},
+ { name: "codeNotesMimeTypesSortAlphabetically", value: "true", isSynced: true },
{ name: "contentManagerSortOrder", value: "title", isSynced: true },
{ name: "contentManagerViewMode", value: "category", isSynced: true },
{ name: "leftPaneWidth", value: "25", isSynced: false },