Skip to content

Build your personal knowledge base with Trilium Notes

client/code notes: display the selection length in the status bar

Adorian Doranc40680f461c6
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index b6a3e73452..bf8f3439a7 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -4003,6 +4003,7 @@
"code_note_switcher": "Change language mode",
"cursor_line": "Ln: <Value />",
"cursor_column": "Col: <Value />",
+ "cursor_selection": "Selected: <Value />",
"tab_width": "Tab Width: {{width}}",
"tab_width_title": "Change tab width",
"tab_width_spaces_one": "{{count}} space",
diff --git a/apps/client/src/widgets/layout/StatusBar.spec.tsx b/apps/client/src/widgets/layout/StatusBar.spec.tsx
index 11a32caad8..d84b504c14 100644
--- a/apps/client/src/widgets/layout/StatusBar.spec.tsx
+++ b/apps/client/src/widgets/layout/StatusBar.spec.tsx
@@ -145,24 +145,36 @@ describe("StatusBar panels", () => {
contextData.set("codeEditor", {
addCursorPositionListener(listener: (position: CursorPosition) => void) {
report = listener;
- listener({ line: 12, column: 32 });
+ listener({ line: 12, column: 32, selectionLength: 0 });
return unsubscribe;
}
});
- const getValues = () => [ ...container.querySelectorAll(".cursor-position .value") ]
- .map((value) => value.textContent);
+ // Each part is an element of its own, so the gap of the row falls between the parts.
+ const getParts = () => {
+ const parts = container.querySelectorAll(".cursor-position > * > [data-i18n-key]");
+ return [ ...parts ].map((part) => [
+ part.getAttribute("data-i18n-key"),
+ part.querySelector(".value")?.textContent
+ ]);
+ };
renderBar(true, "code");
const position = container.querySelector(".actions-row > .cursor-position");
expect(position).not.toBeNull();
expect(position?.previousElementSibling).toBeNull();
- const i18nKeys = [ ...position?.querySelectorAll(":scope > * > [data-i18n-key]") ?? [] ]
- .map((part) => part.getAttribute("data-i18n-key"));
- expect(i18nKeys).toEqual([ "status_bar.cursor_line", "status_bar.cursor_column" ]);
- expect(getValues()).toEqual([ "12", "32" ]);
-
- act(() => report?.({ line: 3, column: 1 }));
- expect(getValues()).toEqual([ "3", "1" ]);
+ expect(getParts()).toEqual([
+ [ "status_bar.cursor_line", "12" ],
+ [ "status_bar.cursor_column", "32" ]
+ ]);
+
+ act(() => report?.({ line: 3, column: 1, selectionLength: 120 }));
+ expect(getParts()).toEqual([
+ [ "status_bar.cursor_line", "3" ],
+ [ "status_bar.cursor_column", "1" ],
+ [ "status_bar.cursor_selection", "120" ]
+ ]);
+ act(() => report?.({ line: 3, column: 1, selectionLength: 0 }));
+ expect(getParts().map(([ key ]) => key)).not.toContain("status_bar.cursor_selection");
act(() => render(null, container));
expect(unsubscribe).toHaveBeenCalled();
diff --git a/apps/client/src/widgets/layout/StatusBar.tsx b/apps/client/src/widgets/layout/StatusBar.tsx
index c0b5efd175..d6ab8396e1 100644
--- a/apps/client/src/widgets/layout/StatusBar.tsx
+++ b/apps/client/src/widgets/layout/StatusBar.tsx
@@ -568,6 +568,10 @@ function CodeCursorPosition({ note, noteContext }: StatusBarContext) {
<span className="cursor-position">
<CursorPositionPart i18nKey="status_bar.cursor_line" value={position.line} />
<CursorPositionPart i18nKey="status_bar.cursor_column" value={position.column} />
+ {position.selectionLength > 0 && <CursorPositionPart
+ i18nKey="status_bar.cursor_selection"
+ value={position.selectionLength}
+ />}
</span>
);
}
diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.json
index a956f406b7..d6aa1d2746 100644
--- a/apps/server/src/assets/help/help_content.json
+++ b/apps/server/src/assets/help/help_content.json
@@ -59,7 +59,7 @@
"_help_SL5f1Auq7sVN": "<p>Split view is a feature of&nbsp;<a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a>&nbsp;and&nbsp;<a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a>&nbsp;notes which displays both the source code on one side and the preview of the content on the other.</p><p><a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a>&nbsp;also allow changing between a horizontal or a vertical split, to accommodate for the various sizes of diagrams.</p><h2>Display modes and interaction</h2><p>The split comes with three different display modes which can be toggled from the&nbsp;<a class=\"reference-link\" href=\"#root/_help_1P8QXI5edXNd\">Note buttons</a>&nbsp;area:</p><ul><li><span class=\"tn-icon bx bxs-dock-left\"></span>&nbsp;<em>(Split view)</em>, in which both the source code is available on one side and can be edited, and the preview is available on the other side.<ul><li>In this mode, the size of either the source pane or the preview pane can be adjusted by dragging the small border between them.</li></ul></li><li><span class=\"tn-icon bx bx-code\"></span>&nbsp;(<em>Source view)</em> which shows the source code on the entire screen for a more focused editing experience.</li><li><span class=\"tn-icon bx bx-show\"></span>&nbsp;<em>(Preview)</em> which displays only the rendering of the diagram or text in full screen, especially useful for read-only notes.</li></ul><p>The display node is stored at note level.</p><p>A Markdown note included in a text note, or a Markdown file embedded in one, has the same three display modes, switched from the title row and the toolbar of the include. See <em>Included Markdown</em> in&nbsp;<a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>.</p><h2>Relation to read-only notes</h2><p>If a note is marked as <a href=\"#root/_help_CoFPLs3dRlXc\">read-only</a>, the source view will not be editable. While in preview mode, marking a note as read-only has no effect since the preview itself is not editable.</p>",
"_help_t596jLvPrqkS": "<p>Some note types (such as&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;and saved search) intentionally limit the width of the content.</p><p>This might appear surprising at first, but the idea is to make text fit well on wider screens without appearing distorted. This is especially the case if the document contains&nbsp;<a class=\"reference-link\" href=\"#root/_help_mT0HEkOsz6i1\">Images</a>, tables or other width-dependent elements.</p><h2>Configuring the content width and alignment</h2><p>The content width is expressed in pixels and can be changed from&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Appearance</em> → <em>Content Width</em> and adjusting the <em>Max content width</em> section.</p><p>To effectively disable the content width limitation, simply set the width to a value larger than your screen size (e.g. 9999).</p><p>By default, the content is aligned to the left, but it can be centered horizontally by checking <em>Keep content centered</em> from the same section as the content width.</p><h2>Adjusting at note level</h2><p>For notes with large elements such as&nbsp;<a class=\"reference-link\" href=\"#root/_help_NdowYOC1GFKS\">Tables</a>, it sometimes makes sense to avoid the content width without affecting other notes. To do so:</p><ul><li>Go to&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>&nbsp;and toggle <em>Full width</em>.</li><li>Or manually apply the <code>fullContentWidth</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a> to the note.</li></ul><p>Since v0.107.0, a single table can also be made wider than the content width, in which case it scrolls sideways. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_NdowYOC1GFKS\">Tables</a>.</p><aside class=\"admonition note\"><p>Some <a href=\"#root/_help_KSZ04uQ2D1St\">note types</a> are full width by default, such as the&nbsp;<a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a>. In that case the <em>Full width</em> toggle will not be displayed and the label will have no effect.</p></aside><h2>Shared notes</h2><p>On a <a href=\"#root/_help_R9pX4DGra2Vt\">shared page</a>, a text note is shown at a fixed reading width, whatever the width configured in Options, and the navigation tree, the content and the table of contents are kept together in a column centered on a wide screen. A note with <code>fullContentWidth</code>, or of a type that is full width in the application, uses the whole width of the window there, with the navigation tree and the table of contents at its edges.</p>",
"_help_jcQVxzYybYgz": "<figure class=\"image image-style-align-right image_resized\" style=\"width:44.65%;\"><img style=\"aspect-ratio:514/291;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20contextual%20menu_image.png\" width=\"514\" height=\"291\"></figure><p>Right-clicking the content of some note types such as&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;or&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;reveals a contextual menu.</p><h2>Features</h2><ul><li>On the&nbsp;<a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a>, the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oBo3iHIZnbG2\">Spell Check</a>&nbsp;suggestions are shown when right clicking on a misspelled word.</li><li>The selected text can be searched either with a search engine (configured from&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>) or <a href=\"#root/_help_eIg8jdvaoNNd\">inside Trilium</a>.</li><li>Basic clipboard functionality (cut, copy, paste).</li><li>Copying the selected text as&nbsp;<a class=\"reference-link\" href=\"#root/_help_Oau6X9rCuegd\">Markdown</a>.</li><li>Performing quick operations using the&nbsp;<a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a>.</li></ul><h2>Differences between desktop and web</h2><p>The <a href=\"#root/_help_WOcw2SLH6tbX\">web version</a> behaves slightly different due to limitations imposed by web browsers:</p><ul><li>When no text is selected or a word is right-clicked, the browser's default contextual menu is displayed.<ul><li>This is intentional since it preserves the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oBo3iHIZnbG2\">Spell Check</a>&nbsp;functionality.</li></ul></li><li>When a text is selected, a reduced menu is displayed instead which features only the functionality that is available within the browser version<ul><li><em>Paste</em> is not available since the browser doesn't expose it, use <kbd>Ctrl</kbd>+<kbd>V</kbd> instead.</li><li>The browser menu can be triggered anyway by pressing <kbd>Shift</kbd> + <kbd>Right click</kbd>.</li></ul></li></ul>",
- "_help_AlJ73vBCjWDw": "<p>The status bar displays information about the current note and allows changing settings related to it such as configuring the language or attributes.</p><h2>Layout and interaction</h2><p>On the left side, the&nbsp;<a class=\"reference-link\" href=\"#root/_help_I6p2a06hdnL6\">Breadcrumb</a>&nbsp;is displayed which indicates the current note as well as its parent notes and allows for quick navigation throughout the hierarchy.</p><p>On the right side, specific sections will show depending on the type of the current note.</p><ol><li>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;notes, the language mode of the note is indicated (e.g. JavaScript, plain text), as well as allowing easy switching to another mode.<ol><li>Before it, the position of the cursor is shown as a line and a column, such as <em>Ln: 12 Col: 32</em>. It updates as the cursor moves.</li></ol></li><li>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes, the content language is displayed and can be changed, thus configuring the spell-check and the right-to-left support.<ol><li>Note that this applies to the entire note and not the selection, unlike some text editors.</li></ol></li><li>If a note is placed in multiple places in the tree (cloned), the number of the note paths will be displayed.<ol><li>Clicking it opens a popup with the full list of note paths, from which the note can also be cloned to a new location. The same list is available in the sidebar's&nbsp;<a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>.</li></ol></li><li>If a note has attachments, their number will be displayed.<ol><li>Clicking on it will reveal the list of attachments in a new tab.</li></ol></li><li>If a note is linked from other text notes (backlinks), the number of backlinks will be displayed.<ol><li>Clicking on it opens a popup with the list of notes that link to this note, as well as an excerpt of where the note is referenced. The same list is available in the sidebar's&nbsp;<a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>.</li></ol></li></ol><p>Regardless of note type, the following items will always be displayed if there is a note:</p><ol><li>Note info, which displays:<ol><li>The creation/modification date of the note.</li><li>The type and MIME of the note.</li><li>The note ID.</li><li>An estimation of the note size of the note itself and its children.</li><li>A button to reveal the Similar notes in the sidebar's&nbsp;<a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>.</li></ol></li></ol><aside class=\"admonition note\"><p>When pressing a button which reveals the&nbsp;<a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>, it has a specific behavior if the sidebar is hidden: the sidebar will be peeked instead of docked. Regardless the sidebar will be switched to the appropriate tab and the corresponding section will be highlighted.</p></aside>",
+ "_help_AlJ73vBCjWDw": "<p>The status bar displays information about the current note and allows changing settings related to it such as configuring the language or attributes.</p><h2>Layout and interaction</h2><p>On the left side, the&nbsp;<a class=\"reference-link\" href=\"#root/_help_I6p2a06hdnL6\">Breadcrumb</a>&nbsp;is displayed which indicates the current note as well as its parent notes and allows for quick navigation throughout the hierarchy.</p><p>On the right side, specific sections will show depending on the type of the current note.</p><ol><li>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;notes, the language mode of the note is indicated (e.g. JavaScript, plain text), as well as allowing easy switching to another mode.<ol><li>Before it, the position of the cursor is shown as a line and a column, such as <em>Ln: 12 Col: 32</em>. It updates as the cursor moves. While text is selected, the number of selected characters follows, such as <em>Selected: 120</em>.</li></ol></li><li>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes, the content language is displayed and can be changed, thus configuring the spell-check and the right-to-left support.<ol><li>Note that this applies to the entire note and not the selection, unlike some text editors.</li></ol></li><li>If a note is placed in multiple places in the tree (cloned), the number of the note paths will be displayed.<ol><li>Clicking it opens a popup with the full list of note paths, from which the note can also be cloned to a new location. The same list is available in the sidebar's&nbsp;<a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>.</li></ol></li><li>If a note has attachments, their number will be displayed.<ol><li>Clicking on it will reveal the list of attachments in a new tab.</li></ol></li><li>If a note is linked from other text notes (backlinks), the number of backlinks will be displayed.<ol><li>Clicking on it opens a popup with the list of notes that link to this note, as well as an excerpt of where the note is referenced. The same list is available in the sidebar's&nbsp;<a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>.</li></ol></li></ol><p>Regardless of note type, the following items will always be displayed if there is a note:</p><ol><li>Note info, which displays:<ol><li>The creation/modification date of the note.</li><li>The type and MIME of the note.</li><li>The note ID.</li><li>An estimation of the note size of the note itself and its children.</li><li>A button to reveal the Similar notes in the sidebar's&nbsp;<a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>.</li></ol></li></ol><aside class=\"admonition note\"><p>When pressing a button which reveals the&nbsp;<a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>, it has a specific behavior if the sidebar is hidden: the sidebar will be peeked instead of docked. Regardless the sidebar will be switched to the appropriate tab and the corresponding section will be highlighted.</p></aside>",
"_help_I6p2a06hdnL6": "<figure class=\"image\"><img style=\"aspect-ratio:1150/27;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Breadcrumb_image.png\" width=\"1150\" height=\"27\"></figure><p>The breadcrumb allows quickly viewing the note hierarchy of the current note and navigating through it.</p><p>It is part of the&nbsp;<a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>, displayed in the bottom-left of the screen.</p><h2>Layout and Interaction</h2><ul><li>If a note or workspace is hoisted, a badge will appear on the left-most side.<ul><li>Clicking on the badge will un-hoist the note/workspace.</li></ul></li><li>The left-most icon represents the root note, or the hoisted note or workspace.<ul><li>Clicking the icon will jump to the root note.</li><li>Right clicking the icon will display a menu that allows opening the note in a new tab, split, etc.</li></ul></li><li>Each segment shows the title of a note in the current note hierarchy.<ul><li>Clicking the icon will jump to that note.</li><li>Right clicking will open a menu with multiple options such as opening the note in a different tab/split/window, hoisting, moving/cloning the note, duplicating as well as changing the color of the note.</li></ul></li><li>Clicking the arrow next to each segment will reveal the child notes of the segment on the left.<ul><li>Clicking on an icon will navigate to that particular note.</li><li>It's also possible to create a new child note from here.</li><li>The menu can optionally hide the archived notes.</li></ul></li><li>If the current note is deep within a hierarchy, the segments will collapse into a […] button in order not to occupy too much space.<ul><li>Clicking this button will display each collapsed entry as a menu item. Clicking on it will navigate to that particular note.</li></ul></li><li>Right clicking on an empty space to the right of the breadcrumb (before the other status bar items) will reveal another menu that allows:<ul><li>Toggling whether archived notes are displayed in the breadcrumb and in the note tree.</li><li>Copying the current note path to clipboard.</li></ul></li></ul>",
"_help_BFs8mudNFgCS": "<p>Note is a central entity in Trilium. Main attributes of note are <a href=\"#root/_help_l7pigIGu01K2\">title</a> and content.</p><h3>Note types</h3><p>The main note type is a rich-text note type called&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>. For diagrams and drawing there is&nbsp;<a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a>&nbsp;and&nbsp;<a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a>.</p><p>There are also more complex note types such as&nbsp;<a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a>,&nbsp;<a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>&nbsp;that usually go hand-in-hand with&nbsp;<a class=\"reference-link\" href=\"#root/_help_CdNpE2pqjmI6\">Scripting</a>.</p><p>In Trilium there's no specific \"folder\" note type. Any note can have children and thus be a folder. To make a note that only shows its children, like a folder in other applications, use a <a class=\"reference-link\" href=\"#root/_help_8QqnMzx393bx\">Grid View</a> or <a class=\"reference-link\" href=\"#root/_help_mULW0Q3VojwY\">List View</a> collection. See also <a class=\"reference-link\" href=\"#root/_help_i6dbnitykE5D\">FAQ</a>.</p><h3>Root note</h3><p>There's one special note called \"root note\" which is root of the note tree. All other notes are placed below it in the structure.</p><h3>Tree structure</h3><p>Importantly, note itself doesn't carry information on its placement in note tree. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>&nbsp;for details.</p><p>Tree structure of notes can resemble file system - but compared to that notes in Trilium can act as both file and directory - meaning that note can both have its own content and have children. \"Leaf note\" is a note which doesn't have any children.</p><h3>Deleting / undeleting notes</h3><p>When you delete a note in Trilium, it is actually only marked for deletion (soft-delete) - the actual content, title, attributes etc. are not deleted, only hidden.</p><p>Within (by default) 7 days, it is possible to undelete these soft-deleted notes - open the&nbsp;<a class=\"reference-link\" href=\"#root/_help_r5JGHN99bVKn\">Recent Changes</a>&nbsp;dialog, and you will see a list of all modified notes including the deleted ones. Notes available for undeletion have a link to do so. This is kind of \"trash can\" functionality known from e.g. Windows.</p><p>Clicking an undelete will recover the note, its content and attributes - note should be just as before being deleted. This action will also undelete note's children which have been deleted in the same action.</p><p>To be able to undelete a note, it is necessary that deleted note's parent must be undeleted (otherwise there's no place where we can undelete it to). This might become a problem when you delete more notes in succession - the solution is then undelete in the reverse order of your deletion.</p><p>After the 7 days (configurable) the notes will be \"erased\" - their title, content, revisions and attributes will be erased, and it will not be possible anymore to recover them (unless you restore a&nbsp;<a class=\"reference-link\" href=\"#root/_help_ODY7qQn5m2FT\">Backup</a>).</p><h2>See also</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_CoFPLs3dRlXc\">Read-Only Notes</a></li></ul>",
"_help_l7pigIGu01K2": "<p>Alongside its content, the <strong>title</strong> is one of the two main attributes of a <a href=\"#root/_help_BFs8mudNFgCS\">note</a>. It's the short, human-readable name shown in the editable field at the top of every note, and it's what identifies the note throughout the interface (in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, in tabs, in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_I6p2a06hdnL6\">Breadcrumb</a>&nbsp;and win&nbsp;<a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a>.</p><p>Internally, notes are identified by a unique&nbsp;<a class=\"reference-link\" href=\"#root/_help_m1lbrzyKDaRB\">Note ID</a>&nbsp;rather than by their title, so the title is purely for your benefit. This has a few consequences:</p><ul><li><strong>Titles don't have to be unique.</strong> You can have any number of notes that share the same title without conflict.</li><li><strong>Renaming a note never breaks links to it.</strong> Links between notes point at the underlying note, so changing a title leaves existing links intact (they'll simply display the new title).</li><li><strong>The title can be left empty.</strong> Notes with no title display a placeholder (<em>type note's title here…</em>) but are otherwise perfectly valid.</li></ul><p>In addition:</p><ul><li>There is no limitation on the length of the title, however in exports the title might get trimmed.</li><li>There are no forbidden symbols, unsupported characters will get trimmed when exporting.</li><li>When exporting to a ZIP file, a meta file will contain the full title which will be recognized by Trilium when importing again.</li></ul><h2>Inline title</h2><p><a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes have a special title bar behavior in which the <a href=\"#root/_help_l7pigIGu01K2\">note title</a> is initially displayed in a larger font, while also displaying additional information such as the creation and the modification date.</p><p>Whenever the title is scrolled past, the fixed title is shown instead.</p><p>Note types that take the entirety of the screen, such as&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;and&nbsp;<a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a>, will always have only the fixed title bar.</p><p>Under the note title, the&nbsp;<a class=\"reference-link\" href=\"#root/_help_m3VlURMSeOrd\">New note type switcher</a>&nbsp;appears if the note is empty.</p><figure class=\"image\"><img style=\"aspect-ratio:899/122;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Title_image.png\" width=\"899\" height=\"122\"><figcaption>The <em>Inline title</em>, which is displayed at the top of the note and can be scrolled past.</figcaption></figure><figure class=\"image\"><img style=\"aspect-ratio:910/104;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/1_Title_image.png\" width=\"910\" height=\"104\"><figcaption>The fixed title bar. The title only appears after scrolling past the <em>Inline title</em>.</figcaption></figure><h3>Editing the title</h3><p>To rename a note, simply click into the title field and type. Changes are saved automatically as you type.</p><p>You can also begin editing the title directly from the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>&nbsp;by selecting a note and pressing <kbd>Enter</kbd> (see <em>Edit note title</em> in&nbsp;<a class=\"reference-link\" href=\"#root/_help_A9Oc6YKKc65v\">Keyboard Shortcuts</a>), which focuses the title field for the active note.</p><aside class=\"admonition note\"><p>Titles may contain any characters, including Unicode and emoji. For security, any HTML in the title is stripped automatically, so the title is always treated as plain text.</p></aside><h3>Easily navigating between the title and the content</h3><p>When the cursor is in the title field, pressing <kbd>Enter</kbd> moves focus into the note's content. For&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes this also inserts a fresh empty paragraph at the very top of the document, so you can start writing immediately — much like other note-taking apps.</p><p>This makes it possible to create a note, type its title, press <kbd>Enter</kbd>, and continue straight into the body without reaching for the mouse.</p><h3>Working with new notes</h3><p>When you create a new note it's given a default title (<em>new note</em>) which is pre-selected, so you can type a name right away to replace it. The default title for new notes can be customized per-section — see&nbsp;<a class=\"reference-link\" href=\"#root/_help_47ZrP6FNuoG8\">Default Note Title</a>.</p><p>If you decide you don't want the note after all, pressing <kbd>Escape</kbd> while the title of a freshly created note is still focused will discard it.</p><h3>Automatically generated titles</h3><p>Some notes get their titles assigned automatically rather than typed:</p><ul><li><strong>Day, week, month and year notes</strong> in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a>&nbsp;are named from a configurable date pattern.</li><li><a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a>&nbsp;notes are named after the search they perform.</li><li>When a note is duplicated, a suffix is appended to the copy's title to tell it apart from the original.</li></ul><h3>Protected notes</h3><p>For&nbsp;<a class=\"reference-link\" href=\"#root/_help_bwg0e8ewQMak\">Protected Notes</a>, the title is <em>not</em> encrypted — only the content is. The title therefore remains visible in the tree and tabs even when no protected session is active. While locked, however, the title field is read-only and cannot be edited until you enter your password.</p><p>The titles of&nbsp;<a class=\"reference-link\" href=\"#root/_help_bwg0e8ewQMak\">Protected Notes</a>&nbsp;are encrypted along with their content. Before entering your password, Trilium cannot decrypt the title, so it is shown as <code>[protected]</code> in instead and the title cannot be modified.</p><p>Once you enter your password and a protected session is active, the real title is decrypted and displayed, and becomes editable again.</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 <span class=\"tn-icon cke cke-table\"></span>button opens the form directly, without the grid.</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\"><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\".</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.</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>Text tools</h2><p>To change the selected lines or text, right-click the selection and pick an entry from one of these submenus:</p><ul><li><em>Line operations</em>: <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>Line removal</em>: <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>Text transform</em>: <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 line operations and the line removals change every line that the selection touches, even partly. The text transforms 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. 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>Text tools</h2><p>To change the selected lines or text, right-click the selection and pick an entry from one of these submenus:</p><ul><li><em>Line operations</em>: <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>Line removal</em>: <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>Text transform</em>: <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 line operations and the line removals change every line that the selection touches, even partly. The text transforms 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/Basic Concepts and Features/UI Elements/Status bar.md b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Status bar.md
index 1e56ceb294..71057ba17b 100644
--- a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Status bar.md
+++ b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Status bar.md
@@ -8,7 +8,7 @@ On the left side, the <a class="reference-link" href="Breadcrumb.md">Breadcrumb
On the right side, specific sections will show depending on the type of the current note.
1. For <a class="reference-link" href="../../Note%20Types/Code.md">Code</a> notes, the language mode of the note is indicated (e.g. JavaScript, plain text), as well as allowing easy switching to another mode.
- 1. Before it, the position of the cursor is shown as a line and a column, such as _Ln: 12 Col: 32_. It updates as the cursor moves.
+ 1. Before it, the position of the cursor is shown as a line and a column, such as _Ln: 12 Col: 32_. It updates as the cursor moves. While text is selected, the number of selected characters follows, such as _Selected: 120_.
2. For <a class="reference-link" href="../../Note%20Types/Text.md">Text</a> notes, the content language is displayed and can be changed, thus configuring the spell-check and the right-to-left support.
1. Note that this applies to the entire note and not the selection, unlike some text editors.
3. If a note is placed in multiple places in the tree (cloned), the number of the note paths will be displayed.
diff --git a/docs/User Guide/User Guide/Note Types/Code.md b/docs/User Guide/User Guide/Note Types/Code.md
index 6efccf4bf2..65bd326056 100644
--- a/docs/User Guide/User Guide/Note Types/Code.md
+++ b/docs/User Guide/User Guide/Note Types/Code.md
@@ -55,7 +55,7 @@ An included code note or an embedded code file can show or hide them on its own
The status bar at the bottom of the editor shows the position of the cursor, the current indentation settings and language.
-The cursor position is shown as _Ln_ (the line) and _Col_ (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.
+The cursor position is shown as _Ln_ (the line) and _Col_ (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, _Selected_ shows the number of selected characters, counting each line break as one.
Clicking on the indentation indicator opens a menu with three sections:
diff --git a/packages/codemirror/src/index.spec.ts b/packages/codemirror/src/index.spec.ts
index 1bed445b28..a7d53353f1 100644
--- a/packages/codemirror/src/index.spec.ts
+++ b/packages/codemirror/src/index.spec.ts
@@ -679,7 +679,8 @@ describe("CodeMirror", () => {
instance.setText("one\n\ttwo");
const getPosition = (selection: EditorSelection) => {
instance.dispatch({ selection });
- return instance.getCursorPosition();
+ const { line, column } = instance.getCursorPosition();
+ return { line, column };
};
expect(getPosition(EditorSelection.single(0))).toEqual({ line: 1, column: 1 });
@@ -692,6 +693,23 @@ describe("CodeMirror", () => {
expect(getPosition(EditorSelection.single(8))).toEqual({ line: 2, column: 6 });
});
+ it("counts the selected characters of every range, with a line break as one", () => {
+ const instance = build();
+ editor = instance;
+ instance.setNamedExtension("multi", EditorState.allowMultipleSelections.of(true));
+ instance.setText("one\ntwo");
+ const getLength = (selection: EditorSelection) => {
+ instance.dispatch({ selection });
+ return instance.getCursorPosition().selectionLength;
+ };
+
+ expect(getLength(EditorSelection.single(2))).toBe(0);
+ expect(getLength(EditorSelection.single(5, 2))).toBe(3);
+ expect(getLength(EditorSelection.create([
+ EditorSelection.range(0, 2), EditorSelection.range(4, 7)
+ ]))).toBe(5);
+ });
+
it("reports the position at once and then each change of it", () => {
const instance = build();
editor = instance;
@@ -700,19 +718,22 @@ describe("CodeMirror", () => {
const listener = vi.fn();
const unsubscribe = instance.addCursorPositionListener(listener);
- expect(listener.mock.calls).toEqual([ [ { line: 1, column: 1 } ] ]);
+ expect(listener.mock.calls).toEqual([ [ { line: 1, column: 1, selectionLength: 0 } ] ]);
instance.dispatch({ selection: EditorSelection.cursor(5) });
- expect(listener).toHaveBeenLastCalledWith({ line: 2, column: 5 });
+ expect(listener).toHaveBeenLastCalledWith({ line: 2, column: 5, selectionLength: 0 });
instance.setIndentSize(8);
- expect(listener).toHaveBeenLastCalledWith({ line: 2, column: 9 });
+ expect(listener).toHaveBeenLastCalledWith({ line: 2, column: 9, selectionLength: 0 });
+ // The cursor stays where it is, and the selection grows behind it.
+ instance.dispatch({ selection: EditorSelection.single(4, 5) });
+ expect(listener).toHaveBeenLastCalledWith({ line: 2, column: 9, selectionLength: 1 });
// Hiding the line numbers keeps the document and the selection, so nothing is counted.
const getCursorPosition = vi.spyOn(instance, "getCursorPosition");
listener.mockClear();
instance.setLineNumbers(false);
expect(getCursorPosition).not.toHaveBeenCalled();
- // An edit on another line keeps the line and the column of the cursor.
+ // An edit on another line keeps the cursor position and the selection length.
instance.dispatch({ changes: { from: 0, insert: "x" } });
expect(getCursorPosition).toHaveBeenCalled();
expect(listener).not.toHaveBeenCalled();
diff --git a/packages/codemirror/src/index.ts b/packages/codemirror/src/index.ts
index 96fd748ff8..b212951af1 100644
--- a/packages/codemirror/src/index.ts
+++ b/packages/codemirror/src/index.ts
@@ -106,6 +106,8 @@ export interface CursorPosition {
line: number;
/** The column as displayed, with a tab as wide as the tab size. */
column: number;
+ /** The number of selected characters, all ranges of the selection together. */
+ selectionLength: number;
}
function buildIndentUnit(indentSize: number, useTabs: boolean) {
@@ -309,20 +311,32 @@ export default class CodeMirror extends EditorView {
({ doc, selection, tabSize } = state);
const next = this.getCursorPosition();
- if (next.line === position.line && next.column === position.column) return;
+ if (next.line === position.line && next.column === position.column
+ && next.selectionLength === position.selectionLength) {
+ return;
+ }
position = next;
listener(position);
});
}
- /** The position of the main cursor, which is the end of the main selection that moves. */
+ /**
+ * The position of the main cursor, which is the end of the main selection that moves, and the
+ * length of the selection.
+ */
getCursorPosition(): CursorPosition {
const { doc, selection, tabSize } = this.state;
const { head } = selection.main;
const line = doc.lineAt(head);
+ let selectionLength = 0;
+ for (const range of selection.ranges) {
+ selectionLength += range.to - range.from;
+ }
+
return {
line: line.number,
- column: countColumn(line.text, tabSize, head - line.from) + 1
+ column: countColumn(line.text, tabSize, head - line.from) + 1,
+ selectionLength
};
}