Skip to content

Build your personal knowledge base with Trilium Notes

feat(text): choose an image's position from one menu

Elian Doran6836eaaaf808
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 4c14af9676..dbffe8651d 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -4600,7 +4600,8 @@
"block-type": "Block type",
"camera": "Camera",
"move-up": "Move up",
- "move-down": "Move down"
+ "move-down": "Move down",
+ "image-position": "Image position"
},
"task-state-dropped-title": "Invalid task states",
"task-state-dropped-message_one": "A custom task state definition is invalid and was ignored.",
diff --git a/apps/client/src/widgets/type_widgets/text/config.spec.ts b/apps/client/src/widgets/type_widgets/text/config.spec.ts
index a1d29bbe93..7edf184756 100644
--- a/apps/client/src/widgets/type_widgets/text/config.spec.ts
+++ b/apps/client/src/widgets/type_widgets/text/config.spec.ts
@@ -511,6 +511,12 @@ describe("CK config - language & emoji", () => {
});
describe("CK config - image actions", () => {
+ it("places the image in one position menu, in place of the style buttons", async () => {
+ const toolbar = ((await buildConfig(baseOpts())).image as { toolbar: unknown[] }).toolbar;
+ expect(toolbar[0]).toBe("imagePosition");
+ expect(JSON.stringify(toolbar)).not.toContain("imageStyle:");
+ });
+
it("adds the copy-image toolbar action only when raw image copy is supported", async () => {
const unsupported = await buildConfig(baseOpts());
const unsupportedToolbar = (unsupported.image as { toolbar: unknown[] }).toolbar;
diff --git a/apps/client/src/widgets/type_widgets/text/config.ts b/apps/client/src/widgets/type_widgets/text/config.ts
index fba000d101..cc08eef009 100644
--- a/apps/client/src/widgets/type_widgets/text/config.ts
+++ b/apps/client/src/widgets/type_widgets/text/config.ts
@@ -114,21 +114,7 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfi
}
],
toolbar: [
- // Image styles, see https://ckeditor.com/docs/ckeditor5/latest/features/images/images-styles.html#demo.
- "imageStyle:inline",
- "imageStyle:alignCenter",
- {
- name: "imageStyle:wrapText",
- title: "Wrap text",
- items: ["imageStyle:alignLeft", "imageStyle:alignRight"],
- defaultItem: "imageStyle:alignRight"
- },
- {
- name: "imageStyle:block",
- title: "Block align",
- items: ["imageStyle:alignBlockLeft", "imageStyle:alignBlockRight"],
- defaultItem: "imageStyle:alignBlockLeft"
- },
+ "imagePosition",
"|",
"imageResize:25",
"imageResize:50",
diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.json
index 1c3c289b1e..c437ba3d83 100644
--- a/apps/server/src/assets/help/help_content.json
+++ b/apps/server/src/assets/help/help_content.json
@@ -130,7 +130,7 @@
"_help_nRhnJkTT8cPs": "<p>Trilium allows two different editing experiences for text notes, based on your preference.</p><p>The type of formatting toolbar can be changed by going to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;and then looking for the&nbsp;<a class=\"reference-link\" href=\"#root/_hidden/_options/_optionsTextNotes\">Text Notes</a>&nbsp;section. In it, look for the <em>Formatting toolbar</em> category.</p><h2>Floating</h2><p>The floating bar is a more minimalist option, in which the formatting is hidden behind two different popups.</p><h3>Block-level popup</h3><p>The first popup is the block-level popup. This will appear to the left of the current paragraph you are currently editing, as a sequence of dots:<br><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Formatting%20toolbar_image.jpg\"></p><p>Clicking this popup will reveal the formatting options that are specific to the entire paragraph, such as setting a heading, lists, tables, etc.</p><p>The dots are also a drag handle: drag them to move the paragraph, all the selected paragraphs, or a selected element such as an image, a table or an included note to another place in the note. Right-clicking them copies a reference to the paragraph or to the selected paragraphs, see&nbsp;<a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>.</p><figure class=\"image\"><img style=\"aspect-ratio:1404/156;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_Formatting%20toolbar_image.png\" width=\"1404\" height=\"156\"></figure><h3>Inline popup</h3><p>The inline popup appears automatically when selecting a text:</p><figure class=\"image\"><img style=\"aspect-ratio:1008/154;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Formatting%20toolbar_image.png\" width=\"1008\" height=\"154\"></figure><p>All the options here apply only to the selected portion of text, such as changing the font size, or making the text bold.</p><h2>Fixed</h2><p>The fixed formatting offers a more traditional editing paradigm, usually useful if a lot of formatting is needed.</p><p>All the options are combined into a single toolbar that will appear at the above the note. When using&nbsp;<a class=\"reference-link\" href=\"#root/_help_luNhaphA37EO\">Split View</a>, a single toolbar will be available to save space and it acts on the active note.</p><p>The sequence of dots to the left of the current paragraph is still shown, but only as a drag handle: drag it to move the paragraph, all the selected paragraphs, or a selected element such as an image, a table or an included note to another place in the note. Clicking it does not open a popup, and right-clicking it copies a reference to the block, see&nbsp;<a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>. The drag handle is not shown in the mobile layout.</p><figure class=\"image\"><img style=\"aspect-ratio:1440/60;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Formatting%20toolbar_image.png\" width=\"1440\" height=\"60\"></figure><p>By default, if the toolbar does not fit on the screen, the rest of the options will be grouped into a single option at the end. It is possible to display items on multiple lines by checking the corresponding option in the <em>Formatting toolbar</em> section.</p>",
"_help_Gr6xFaF6ioJ5": "<h2>Headings</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:255/284;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_General%20formatting_image.png\" width=\"255\" height=\"284\"></figure><p>Trilium provides headings to define sections within text. Headings are numbered from 2 to 6.</p><p>The reason why Heading 1 is missing from the list is that it is being reserved for the title of note.</p><p>To turn a heading back into a normal text, select <em>Paragraph</em> from the list.</p><p>Apart from using the UI, it is also possible to quickly insert headings using the Markdown-like shortcuts:</p><ul><li><code>##</code> for Heading 2</li><li><code>###</code> for Heading 3</li><li><code>####</code> for Heading 4</li><li><code>#####</code> for Heading 5</li><li><code>######</code> for Heading 6</li></ul><h2>Font size</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:363/249;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/General%20formatting_image.png\" width=\"363\" height=\"249\"></figure><p>One way to highlight a portion of text is to increase the size of the font.</p><p>To do so, select some text and choose an option from the <em>Font size</em> (<span class=\"tn-icon cke cke-font-size\"></span>) selector (as pictured to the right).</p><p>Unlike other text editors such as Microsoft Word, the font size is relative (i.e. “Tiny”, “Small” instead of a number like 12).</p><p>Avoid using this feature just to simply make all text bigger. In that case it's generally better to adjust the font size for all notes in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;or by zooming.</p><h2>Bold, italic, underline, strike-through</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:215/71;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/3_General%20formatting_image.png\" width=\"215\" height=\"71\"></figure><p>Text can be formatted as <strong>Bold,</strong> <em>Italic,</em> Underline or <del>Strike-through</del> via the dedicated buttons (<span class=\"tn-icon cke cke-bold\"></span>, <span class=\"tn-icon cke cke-italic\"></span>, <span class=\"tn-icon cke cke-underline\"></span>, <span class=\"tn-icon cke cke-strikethrough\"></span>) in the formatting toolbar.</p><p>This formatting can be easily removed using the <em>Remove formatting</em> (<span class=\"tn-icon cke cke-remove-format\"></span>) item.</p><p>The following keyboard shortcuts can be used here:</p><ul><li><kbd>Ctrl</kbd>+<kbd>B</kbd> for bold</li><li><kbd>Ctrl</kbd>+<kbd>I</kbd> for italic</li><li><kbd>Ctrl</kbd>+<kbd>U</kbd> for underline</li></ul><p>Alternatively, Markdown-like formatting can be used:</p><ul><li><strong>Bold</strong>: Type <code>**text**</code> or <code>__text__</code></li><li><em>Italic</em>: Type <code>*text*</code> or <code>_text_</code></li><li><del>Strikethrough</del>: Type <code>~~text~~</code></li></ul><h2>Superscript, subscript</h2><p>This allows writing superscript or subscript text.</p><p>This is mostly useful for units of measure (e.g. cm3 for cubic centimeters) and chemical notations (e.g. NaHCO3)</p><p>For mathematical formulas, prefer the&nbsp;<a class=\"reference-link\" href=\"#root/_help_YfYAtQBcfo5V\">Math Equations</a>&nbsp;feature instead.</p><h2>Font color and background color</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:167/204;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_General%20formatting_image.png\" width=\"167\" height=\"204\"></figure><p>Selected text can be colored with one of the predefined colors from a palette or any color can be selected using the color picker (<span class=\"tn-icon cke cke-color-palette\"></span>).</p><p>Once there is at least one color defined in the document, it will appear in the list for easy reuse.</p><p>Colors adapt to the <a href=\"#root/_help_Wy267RK4M69c\">theme</a>. Trilium shows each color in a lighter or darker shade that suits the current theme, so the text stays readable after switching between light and dark themes. The hue stays the same: red text is red in both themes, only lighter or darker. This applies to the palette, the color picker and the document colors alike, and to shared notes too. Printed notes and PDF exports always use the shades of light themes, which suit white paper. The note itself keeps the color as it was picked, so an exported note shows it unchanged.</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><p>When you paste text copied from a web page in Chrome, Edge or a Chromium-based app (such as Visual Studio Code), Trilium removes the page's styling:</p><ul><li>Text and background colors.</li><li>Fonts and font sizes.</li><li>Table borders, backgrounds and spacing.</li></ul><p>The following formatting is preserved:</p><ul><li>Bold, italic, underline and strikethrough.</li><li>Subscript and superscript.</li><li>Links, code and tables.</li></ul><p>Colors are preserved when pasting from Word, Google Docs or another note.</p><p>To remove either the background or foreground color of a text, select the corresponding formatting button (<span class=\"tn-icon cke cke-font-color\"></span> or <span class=\"tn-icon cke cke-font-background\"></span>) and press <em>Remove color</em> (<span class=\"tn-icon cke cke-eraser\"></span>) or use the <em>Remove formatting</em> (<span class=\"tn-icon cke cke-remove-format\"></span>) toolbar item.</p><h2>Remove formatting</h2><p>The&nbsp;<span class=\"tn-icon cke cke-remove-format\"></span> <em>Remove formatting</em> button is a quick way to eliminate the general formatting styling of a particular text.</p><p>Simply select the text and press the button to remove the formatting (bold, italic, colors, sizes, etc.). If the text does not have any removable formatting, the button will appear disabled.</p><p>Note that heading styles are not taken into consideration, these must be manually changed back to a paragraph according to the <em>Headings</em> section.</p><p>When pasting content that comes with undesired formatting, an alternative to pasting and then removing formatting is pasting as plain text via <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>V</kbd>.</p><h2>Format painter</h2><p>The&nbsp;<a class=\"reference-link\" href=\"#root/_help_5wZallV2Qo1t\">Format Painter</a>&nbsp;allows users to copy the formatting of text (such as bold, italic, Strikethrough, etc.) and apply it to other parts of the document. It helps maintain consistent formatting and accelerates the creation of rich content.</p><h2>Support for Markdown</h2><p>When exported to&nbsp;<a class=\"reference-link\" href=\"#root/_help_Oau6X9rCuegd\">Markdown</a>, most of the general formatting is maintained such as headings, bold, italic, underline, etc.</p>",
"_help_AxshuNRegLAv": "<aside class=\"admonition note\"><p>This page has been relocated to&nbsp;<a class=\"reference-link\" href=\"#root/_help_2dcGDhp9WFKb\">Outline tab</a>.</p></aside>",
- "_help_mT0HEkOsz6i1": "<p>Trilium supports storing and displaying images. Supported formats are PNG, JPEG, GIF, BMP, WebP, AVIF and SVG.</p><p>An image can be uploaded in the form of note's <a href=\"#root/_help_0vhv7lsOLy82\">attachment</a> or as a standalone <a href=\"#root/_help_kBrnXNG3Hplm\">note</a> placed into the <a href=\"#root/_help_kBrnXNG3Hplm\">note tree</a>. Its reference can be copied into a text note, in order to display it in the text itself.</p><h2>Uploading images</h2><p>To add an image to the note:</p><ul><li>Simply drag it from file explorer onto the note editor inside Trilium and the image will be uploaded.</li><li>Alternatively, from the&nbsp;<a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>&nbsp;look for the <span class=\"tn-icon cke cke-image-upload\"></span> <em>Upload image from computer</em> button.</li><li>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, press the <span class=\"tn-icon cke cke-paper-clip\"></span> button of the formatting toolbar and select <em>Camera</em> to take a photo and insert it.</li><li>You can also copy and paste an image from web (see section below).</li></ul><aside class=\"admonition tip\"><p>To link a picture instead of displaying it, attach it with <em>Attach file as a link</em>, from the arrow beside the <span class=\"tn-icon cke cke-paper-clip\"></span><em>Attach file</em> button. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a>.</p></aside><h2>Clipboard &amp; automatic download of images</h2><p>Trilium has a special handling for images copied to and pasted from the clipboard.</p><ul><li>For a mix of text and images, the images are downloaded automatically by the server (or desktop app, depending on what is being used).<ul><li>This means that the image must be publicly accessible and reachable from wherever Trilium is running. Inaccessible images will end up as broken images.</li></ul></li><li>If a single image is pasted into Trilium, it will prefer the image that comes in the clipboard. This makes it possible to copy images that Trilium would not otherwise be able to reach, such as Google Chat, Slack, etc.</li><li>When a text with images is copied from Trilium and pasted in another app (such as Microsoft Word or LibreOffice Writer), the images will be preserved.</li></ul><p>The automatic download of images is enabled by default and can be toggled from&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Media</em> → <em>Download images automatically.</em></p><h2>Configuring the images</h2><p>Clicking on an image will reveal a popup with multiple options:<br><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Images_image.png\"></p><h3>Alignment</h3><p>The first set of options configure the alignment are, in order:</p><figure class=\"table\"><table><thead><tr><th>Icon</th><th>Option</th><th>Preview</th><th>Description</th></tr></thead><tbody><tr><td><span class=\"tn-icon cke cke-object-inline\"></span></td><td>Inline</td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Images_image.jpg\"></td><td>As the name suggests, the name can be put inside a paragraph and moved around similarly as if it was a block of text. Use drag &amp; drop or cut-paste to move it around.</td></tr><tr><td><span class=\"tn-icon cke cke-object-center\"></span></td><td>Centered image</td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Images_image.jpg\"></td><td>The image will be displayed as a block and centered, not allowing text in either the left or right of it.</td></tr><tr><td><span class=\"tn-icon cke cke-object-inline-right\"></span></td><td>Wrap text</td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/3_Images_image.jpg\"></td><td>The image will be displayed to the left or the right of the text.</td></tr><tr><td><span class=\"tn-icon cke cke-object-left\"></span></td><td>Block align</td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_Images_image.jpg\"></td><td>Similarly to <em>Centered image</em>, the image will be displayed as a block and aligned either to the left or to the right, but not allowing text to flow on either of its sides.</td></tr></tbody></table></figure><h3>Drawing over an image</h3><p>To draw or write over an image, press the <span class=\"tn-icon bx bxs-pen\"></span> <em>Convert image to a drawing canvas</em> button of its toolbar. The image becomes a drawing canvas that shows all of it, locked in place. See the drawing canvases section of <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>.</p><h2>Compression</h2><p>Since Trilium isn't really meant to be primary storage for image data, it attempts to compress and resize (with pretty aggressive settings) uploaded images before storing them to the database. You may then notice some quality degradation. Basic quality settings is available in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Media</em>.</p><p>If you want to save images in their original resolution, it is recommended to save them as attachment to note (look for the contextual menu in&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>&nbsp;→ <em>Import files</em>).</p><h2>Aligning images side-by-side</h2><p>There are generally two ways to display images side by side:</p><ul><li>If they are roughly the same size, simply make the two images in-line, according to the alignment section above. The images can be dragged &amp; dropped onto the same line.</li><li>If they are on different size, create a <a href=\"#root/_help_NdowYOC1GFKS\">table</a> with invisible borders.</li></ul>",
+ "_help_mT0HEkOsz6i1": "<p>Trilium supports storing and displaying images. Supported formats are PNG, JPEG, GIF, BMP, WebP, AVIF and SVG.</p><p>An image can be uploaded in the form of note's <a href=\"#root/_help_0vhv7lsOLy82\">attachment</a> or as a standalone <a href=\"#root/_help_kBrnXNG3Hplm\">note</a> placed into the <a href=\"#root/_help_kBrnXNG3Hplm\">note tree</a>. Its reference can be copied into a text note, in order to display it in the text itself.</p><h2>Uploading images</h2><p>To add an image to the note:</p><ul><li>Simply drag it from file explorer onto the note editor inside Trilium and the image will be uploaded.</li><li>Alternatively, from the&nbsp;<a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>&nbsp;look for the <span class=\"tn-icon cke cke-image-upload\"></span> <em>Upload image from computer</em> button.</li><li>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, press the <span class=\"tn-icon cke cke-paper-clip\"></span> button of the formatting toolbar and select <em>Camera</em> to take a photo and insert it.</li><li>You can also copy and paste an image from web (see section below).</li></ul><aside class=\"admonition tip\"><p>To link a picture instead of displaying it, attach it with <em>Attach file as a link</em>, from the arrow beside the <span class=\"tn-icon cke cke-paper-clip\"></span><em>Attach file</em> button. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a>.</p></aside><h2>Clipboard &amp; automatic download of images</h2><p>Trilium has a special handling for images copied to and pasted from the clipboard.</p><ul><li>For a mix of text and images, the images are downloaded automatically by the server (or desktop app, depending on what is being used).<ul><li>This means that the image must be publicly accessible and reachable from wherever Trilium is running. Inaccessible images will end up as broken images.</li></ul></li><li>If a single image is pasted into Trilium, it will prefer the image that comes in the clipboard. This makes it possible to copy images that Trilium would not otherwise be able to reach, such as Google Chat, Slack, etc.</li><li>When a text with images is copied from Trilium and pasted in another app (such as Microsoft Word or LibreOffice Writer), the images will be preserved.</li></ul><p>The automatic download of images is enabled by default and can be toggled from&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Media</em> → <em>Download images automatically.</em></p><h2>Configuring the images</h2><p>Clicking on an image will reveal a popup with multiple options:<br><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Images_image.png\"></p><h3>Alignment</h3><p>The first button of the popup, <em>Image position</em>, shows the icon of the image's current position. It opens a menu that groups the positions by how text runs around the image:</p><figure class=\"table\"><table><thead><tr><th>Icon</th><th>Option</th><th>Preview</th><th>Description</th></tr></thead><tbody><tr><td><span class=\"tn-icon cke cke-object-inline\"></span></td><td><em>In line</em></td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Images_image.jpg\"></td><td>The image sits inside a paragraph, like a large character, and moves with the text around it. Use drag &amp; drop or cut-paste to move it around.</td></tr><tr><td><span class=\"tn-icon cke cke-object-center\"></span></td><td><em>Break text</em> → <em>Align left</em>, <em>Align center</em> or <em>Align right</em></td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Images_image.jpg\"> <img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_Images_image.jpg\"></td><td>The image is displayed on a line of its own, at the left, in the center or at the right; text continues above and below it but not beside it.</td></tr><tr><td><span class=\"tn-icon cke cke-object-inline-right\"></span></td><td><em>Wrap text</em> → <em>Align left</em> or <em>Align right</em></td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/3_Images_image.jpg\"></td><td>The image is displayed at the left or the right, and the text flows beside it.</td></tr></tbody></table></figure><h3>Drawing over an image</h3><p>To draw or write over an image, press the <span class=\"tn-icon bx bxs-pen\"></span> <em>Convert image to a drawing canvas</em> button of its toolbar. The image becomes a drawing canvas that shows all of it, locked in place. See the drawing canvases section of <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>.</p><h2>Compression</h2><p>Since Trilium isn't really meant to be primary storage for image data, it attempts to compress and resize (with pretty aggressive settings) uploaded images before storing them to the database. You may then notice some quality degradation. Basic quality settings is available in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>Media</em>.</p><p>If you want to save images in their original resolution, it is recommended to save them as attachment to note (look for the contextual menu in&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>&nbsp;→ <em>Import files</em>).</p><h2>Aligning images side-by-side</h2><p>There are generally two ways to display images side by side:</p><ul><li>If they are roughly the same size, simply make the two images in-line, according to the alignment section above. The images can be dragged &amp; dropped onto the same line.</li><li>If they are on different size, create a <a href=\"#root/_help_NdowYOC1GFKS\">table</a> with invisible borders.</li></ul>",
"_help_0Ofbk1aSuVRu": "<figure class=\"image image-style-align-right image_resized\" style=\"width:50.47%;\"><img style=\"aspect-ratio:880/553;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Images/Image%20references_image.png\" width=\"880\" height=\"553\"></figure><p>Image references are an easy way to embed the preview of another note type into a&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;note.</p><h2>Supported note types</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a></li><li><a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a></li><li><a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a></li></ul><h2>Steps</h2><ol><li>Go to one of the supported notes (listed above) and look for the&nbsp;<span class=\"tn-icon bx bx-copy\"></span> button in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_1P8QXI5edXNd\">Note buttons</a>&nbsp;area.</li><li>Go to a&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;note and use the Paste function to insert the reference to that note.</li></ol><h2>Interaction</h2><ul><li>Double-clicking an image reference from a text note will automatically open the target note.</li><li>Clicking an image reference while <kbd>Ctrl</kbd> is pressed will open the target note in a new tab.</li><li>Modifying the target note should also update the image reference. If that doesn't happen, consider&nbsp;<a class=\"reference-link\" href=\"#root/_help_s8alTXmpFR61\">Refreshing the application</a>.</li></ul>",
"_help_VRoP0g1uHHc2": "<figure class=\"image image-style-align-center image_resized\" style=\"width:76.29%;\"><img style=\"aspect-ratio:1479/865;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/In-editor%20AI%20assistant_image.png\" width=\"1479\" height=\"865\"></figure><p>The AI assistant works on the text you are already writing: select a passage and have it rewritten, translated or turned into a table, or ask for new content at the cursor. Unlike the <a href=\"#root/_help_LrKznOtw9cQD\">AI chat</a>, it does not open a conversation window, the result is previewed in place and only enters the note when you accept it.</p><h2>Requirements</h2><p>The assistant is only available once at least one provider is configured in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>AI / LLM</em>, with at least one model selected for it. Until then the toolbar entry is not shown at all.</p><h2>Accessing the AI assistant</h2><p>To access the AI assistant:</p><ul><li>Look for the&nbsp;<span class=\"tn-icon cke cke-trilium-ai\"></span> button in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>. Press the button itself to enter the <em>Ask AI</em> mode or press the arrow key next to it to access the quick commands and the model selection. On a phone, the button has no arrow: tapping it opens the same menu at the bottom of the screen, with <em>Ask AI…</em> at its top, and a group such as <em>Translate</em> opens as a page of its own.</li><li>Look for <em>AI assistant</em> or any of the <em>AI</em>-prefixed quick commands in&nbsp;<a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>.</li><li>Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>K</kbd>.</li><li>Select a text and choose the <em>AI assistant</em> option in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_jcQVxzYybYgz\">Note contextual menu</a>.</li></ul><h2>What the assistant works on</h2><figure class=\"table\"><table><thead><tr><th>Situation</th><th>What is sent</th></tr></thead><tbody><tr><td>Text is selected</td><td>The selection.</td></tr><tr><td>Nothing is selected, and you pick a quick action</td><td>The paragraph the cursor is in.</td></tr><tr><td>Nothing is selected, and you type your own prompt</td><td>Nothing, the response is new content written at the cursor.</td></tr></tbody></table></figure><p>In all cases the assistant also sends the text before and after the target, so that the model can tell what it is writing into: asked to <em>Continue writing</em> or to summarize, a model that can only see the selected words is guessing at the document around them. This surrounding text is context only, it is never rewritten.</p><aside class=\"admonition important\"><p>That means a single run sends more than the passage you highlighted. See&nbsp;<a class=\"reference-link\" href=\"#root/_help_cRRrdZjgyhNc\">Privacy</a>&nbsp;for exactly what leaves your machine.</p></aside><h2>Quick actions</h2><p>The arrow beside the toolbar button opens a menu of ready-made instructions, grouped by what they do.</p><ul><li>The <em>Reformat</em> actions produce real Trilium content rather than plain text: <em>Diagram</em> inserts a Mermaid diagram, <em>Callout</em> an admonition, and <em>Collapsible</em> a collapsible block.</li><li>The <em>Translate</em> group lists the <a href=\"#root/_help_veGu4faJErEM\">content languages</a> you have enabled, or a predefined list if no content languages are set. It can be filled from within the editor, the last entry of the submenu opens the language configuration directly.</li></ul><p>Actions that need something to work on are greyed out when there is nothing to work on (for example an empty paragraph with no selection).</p><h2>Asking for something specific</h2><p>Choosing <em>Ask AI…</em> (<span class=\"tn-icon bx bx-message-square-dots\"></span>) opens a prompt where you can describe the change in your own words, for example: \"make this less formal\", \"add a row for 2024\", \"write an intro paragraph for this section\". Press <kbd>Enter</kbd> or the <span class=\"tn-icon cke cke-arrow-up\"></span> send button to run it.</p><p>Once a response arrives you can keep going in the same prompt, and the assistant treats it as a conversation rather than as a fresh request: after <em>Translate this to German</em>, asking for <em>make it shorter</em> shortens the German, not the original.</p><h2>Reviewing the result</h2><p>The response streams in as it is generated, and can be interrupted at any point by pressing the <em>Stop</em> (<span class=\"tn-icon cke cke-stop\"></span>) button; whatever arrived before that stays usable.</p><p>Nothing is written into the note until you say so. The review offers:</p><ul><li><em>Result</em>, which displays the response as it will be inserted.</li><li><em>Changes</em>, which displays an inline diff against the original, with insertions and deletions marked. When the model rewrote the passage rather than editing it, the review opens on <em>Result</em> instead: a diff of two texts with little in common is harder to read than the answer itself.</li><li><em>Try again</em> (<span class=\"tn-icon cke cke-refresh\"></span>), to re-run the same instruction.</li><li><em>Replace</em>, which substitutes the original passage</li><li><em>Insert below</em>, which keeps the original and adds the response after it.</li></ul><p>Trilium also reports the model that produced it, the tokens consumed and, for providers that report it, the price.</p><p>If you ask for a correction and there is nothing to correct, the assistant will indicate it instead of showing a blank diff.</p><h2>Choosing the model</h2><p>The bottom of the quick actions menu shows which model the assistant runs on, and lets you pick another from the models you selected in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ <em>AI / LLM</em>, grouped by provider.</p><p>The model can also be changed while asking for something specific, or after the assistant has generated its response (i.e. if the response needs a better model).</p><p>This choice is separate from the model used by the chat, and is remembered across notes and devices. Left unset, the assistant follows the first configured provider.</p>",
"_help_mVEYwt20exhO": "<p><em>Quick actions</em> are a feature of the&nbsp;<a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a>&nbsp;for&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;notes which automatically triggers an LLM suggestion based on a defined prompt. The built-in quick actions come with a predefined prompt, but it is also possible to define your own quick actions.</p><h2>Creating a custom quick action</h2><p>In the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>: </p><ol><li>Right-click the note where you want to place the quick action.</li><li>Select <em>Insert child note</em>.</li><li>Select <em>More</em> → <em>AI Quick Action</em>. The entry appears only when AI is enabled.</li></ol><p>Afterwards, simply type in the content of the note the desired prompt. The text can be formatted in the same manner as a normal text note and it will be passed to the LLM as Markdown.</p><p>The title of the note will become the title of the quick action.</p><p>Of note:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;notes work too.</li><li>An empty note is ignored.</li><li><a class=\"reference-link\" href=\"#root/_help_MKmLg5x6xkor\">Archived Notes</a>&nbsp;are also excluded.</li></ul><h2>Using a quick action</h2><p>Once a quick action is defined, the action will appear under the <em>Quick Actions</em> dropdown in a group called <em>Custom</em>.</p>",
diff --git a/docs/User Guide/User Guide/Note Types/Text/Images.md b/docs/User Guide/User Guide/Note Types/Text/Images.md
index a6a3b39c43..e1ec05d8ad 100644
--- a/docs/User Guide/User Guide/Note Types/Text/Images.md
+++ b/docs/User Guide/User Guide/Note Types/Text/Images.md
@@ -33,14 +33,13 @@ Clicking on an image will reveal a popup with multiple options:
### Alignment
-The first set of options configure the alignment are, in order:
+The first button of the popup, _Image position_, shows the icon of the image's current position. It opens a menu that groups the positions by how text runs around the image:
| Icon | Option | Preview | Description |
| --- | --- | --- | --- |
-| <span class="tn-icon cke cke-object-inline"></span> | Inline | ![](Images_image.jpg) | As the name suggests, the name can be put inside a paragraph and moved around similarly as if it was a block of text. Use drag & drop or cut-paste to move it around. |
-| <span class="tn-icon cke cke-object-center"></span> | Centered image | ![](1_Images_image.jpg) | The image will be displayed as a block and centered, not allowing text in either the left or right of it. |
-| <span class="tn-icon cke cke-object-inline-right"></span> | Wrap text | ![](3_Images_image.jpg) | The image will be displayed to the left or the right of the text. |
-| <span class="tn-icon cke cke-object-left"></span> | Block align | ![](2_Images_image.jpg) | Similarly to _Centered image_, the image will be displayed as a block and aligned either to the left or to the right, but not allowing text to flow on either of its sides. |
+| <span class="tn-icon cke cke-object-inline"></span> | _In line_ | ![](Images_image.jpg) | The image sits inside a paragraph, like a large character, and moves with the text around it. Use drag & drop or cut-paste to move it around. |
+| <span class="tn-icon cke cke-object-center"></span> | _Break text_ → _Align left_, _Align center_ or _Align right_ | ![](1_Images_image.jpg) ![](2_Images_image.jpg) | The image is displayed on a line of its own, at the left, in the center or at the right; text continues above and below it but not beside it. |
+| <span class="tn-icon cke cke-object-inline-right"></span> | _Wrap text_ → _Align left_ or _Align right_ | ![](3_Images_image.jpg) | The image is displayed at the left or the right, and the text flows beside it. |
### Drawing over an image
diff --git a/packages/ckeditor5/src/plugins.ts b/packages/ckeditor5/src/plugins.ts
index 4f9c31b7cf..d445f9bfdf 100644
--- a/packages/ckeditor5/src/plugins.ts
+++ b/packages/ckeditor5/src/plugins.ts
@@ -82,6 +82,7 @@ import ToolbarGroupMenu from "./plugins/toolbar_group_menu.js";
import MobileToolbarItems from "./plugins/mobile_toolbar_items.js";
import TextFormattingToolbar from "./plugins/text_formatting_toolbar.js";
import ContextToolbar from "./plugins/context_toolbar.js";
+import ImagePosition from "./plugins/image_position.js";
import ColorMenu from "./plugins/color_menu.js";
import BlockDragHandle from "./plugins/block_drag_handle.js";
@@ -135,6 +136,7 @@ const TRILIUM_PLUGINS: typeof Plugin[] = [
MobileToolbarItems,
TextFormattingToolbar,
ContextToolbar,
+ ImagePosition,
ColorMenu,
CopyAnchorLinkButton,
CopyLinkUrlButton,
diff --git a/packages/ckeditor5/src/plugins/image_position.spec.ts b/packages/ckeditor5/src/plugins/image_position.spec.ts
new file mode 100644
index 0000000000..402f0edc30
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/image_position.spec.ts
@@ -0,0 +1,89 @@
+import {
+ _setModelData as setModelData,
+ ButtonView, type ClassicEditor, DropdownView, Essentials, Image, ImageStyle, ListItemGroupView, ListItemView,
+ type ListView, Paragraph, type View
+} from "ckeditor5";
+import { describe, expect, it } from "vitest";
+
+import { createTestEditor } from "../../test/editor-kit.js";
+import ImagePosition from "./image_position.js";
+
+const STYLES = ["inline", "alignBlockLeft", "alignCenter", "alignBlockRight", "alignLeft", "alignRight", "side"];
+const BLOCK_IMAGE = "[<imageBlock src=\"a.png\"></imageBlock>]<paragraph>b</paragraph>";
+
+describe("ImagePosition", () => {
+ async function createEditor(styles = STYLES) {
+ const editor = await createTestEditor([Essentials, Paragraph, Image, ImageStyle, ImagePosition], {
+ toolbar: ["imagePosition"],
+ image: { styles: { options: styles } }
+ });
+ return { editor, dropdown: getDropdown(editor) };
+ }
+
+ it("lists the positions under the way text runs around the image, the current one on", async () => {
+ const { editor, dropdown } = await createEditor();
+ setModelData(editor.model, BLOCK_IMAGE.replace("<imageBlock", "<imageBlock imageStyle=\"alignRight\""));
+
+ expect(dropdown.buttonView).toMatchObject({ label: "Image position", tooltip: true });
+ expect(rows(dropdown)).toStrictEqual([
+ "In line",
+ "# Break text", "Align left", "Align center", "Align right",
+ "# Wrap text", "Align left", "Align right ✓"
+ ]);
+ expect(dropdown.buttonView.icon).toBe(styleIcon(editor, "alignRight"));
+ });
+
+ it("sets the position picked, and shows it on its button", async () => {
+ const { editor, dropdown } = await createEditor();
+ setModelData(editor.model, BLOCK_IMAGE);
+
+ pick(dropdown, "Wrap text", "Align left");
+ expect(editor.getData()).toContain("image-style-align-left");
+ expect(dropdown.buttonView.icon).toBe(styleIcon(editor, "alignLeft"));
+
+ pick(dropdown, "Break text", "Align right");
+ expect(editor.getData()).toContain("image-style-block-align-right");
+ });
+
+ it("leaves out the positions the editor has no style for, and is off without an image", async () => {
+ const { editor, dropdown } = await createEditor(["inline", "alignCenter", "alignLeft"]);
+ setModelData(editor.model, BLOCK_IMAGE);
+ expect(rows(dropdown)).toStrictEqual(["In line", "# Break text", "Align center", "# Wrap text", "Align left"]);
+
+ setModelData(editor.model, "<paragraph>b[]</paragraph>");
+ expect(dropdown.isEnabled).toBe(false);
+ });
+});
+
+function getDropdown(editor: ClassicEditor) {
+ const item = editor.ui.view.toolbar.items.first;
+ if (!(item instanceof DropdownView)) throw new Error("expected the image position dropdown");
+ return item;
+}
+
+function styleIcon(editor: ClassicEditor, name: string) {
+ return editor.plugins.get("ImageStyleEditing").normalizedStyles?.find((style) => style.name === name)?.icon;
+}
+
+/** The rows of the dropdown's list: a heading as `# label`, a row that is on with a check. */
+function rows(dropdown: DropdownView) {
+ dropdown.isOpen = true;
+ dropdown.isOpen = false;
+ const text = (items: Iterable<View>): string[] => [ ...items ].flatMap((item) => {
+ if (item instanceof ListItemGroupView) return [ `# ${item.label}`, ...text(item.items) ];
+ const button = item instanceof ListItemView ? item.children.first : null;
+ return button instanceof ButtonView ? [ button.isOn ? `${button.label} ✓` : button.label ?? "" ] : [];
+ });
+ return text((dropdown.listView as ListView).items);
+}
+
+function pick(dropdown: DropdownView, heading: string, label: string) {
+ dropdown.isOpen = true;
+ const group = [ ...(dropdown.listView as ListView).items ]
+ .find((item): item is ListItemGroupView => item instanceof ListItemGroupView && item.label === heading);
+ const button = [ ...group?.items ?? [] ]
+ .map((item) => (item instanceof ListItemView ? item.children.first : null))
+ .find((view): view is ButtonView => view instanceof ButtonView && view.label === label);
+ if (!button) throw new Error(`expected "${label}" under "${heading}"`);
+ button.fire("execute");
+}
diff --git a/packages/ckeditor5/src/plugins/image_position.ts b/packages/ckeditor5/src/plugins/image_position.ts
new file mode 100644
index 0000000000..aa03e7ad4b
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/image_position.ts
@@ -0,0 +1,95 @@
+import {
+ addListToDropdown, Collection, createDropdown, ImageStyleEditing, Plugin, UIModel
+} from "ckeditor5";
+import type {
+ ButtonView, Command, ImageStyleOptionDefinition, ListDropdownButtonDefinition, ListDropdownItemDefinition,
+ Locale
+} from "ckeditor5";
+
+/**
+ * Registers `imagePosition`, one dropdown for the styles of an image, in place of CKEditor's
+ * separate style buttons and their "Wrap text" and "Block align" dropdowns, whose rows read the
+ * same. The rows are grouped by how text runs around the image, as Word and Google Docs name it:
+ * in line with it, broken above and below it ("Break text"), or wrapped around it ("Wrap text").
+ * The button shows the icon of the current style.
+ */
+export default class ImagePosition extends Plugin {
+
+ static get requires() {
+ return [ImageStyleEditing] as const;
+ }
+
+ static get pluginName() {
+ return "ImagePosition" as const;
+ }
+
+ init() {
+ this.editor.ui.componentFactory.add("imagePosition", (locale) => this.createDropdown(locale));
+ }
+
+ private createDropdown(locale: Locale) {
+ const editor = this.editor;
+ const t = editor.t;
+ // Always registered: `ImageStyleEditing` adds it.
+ const command = editor.commands.get("imageStyle") as Command;
+ const styles = new Map((editor.plugins.get(ImageStyleEditing).normalizedStyles ?? [])
+ .map((style) => [style.name, style]));
+
+ const groups: { label?: string; rows: [string, string][] }[] = [
+ { rows: [["inline", t("In line")]] },
+ {
+ label: t("Break text"),
+ rows: [["alignBlockLeft", t("Align left")], ["alignCenter", t("Align center")], ["alignBlockRight", t("Align right")]]
+ },
+ { label: t("Wrap text"), rows: [["alignLeft", t("Align left")], ["alignRight", t("Align right")]] }
+ ];
+
+ const items = new Collection<ListDropdownItemDefinition>();
+ for (const { label, rows } of groups) {
+ const buttons = new Collection<ListDropdownButtonDefinition>();
+ for (const [name, rowLabel] of rows) {
+ const style = styles.get(name);
+ if (style) {
+ buttons.add(createRow(style, rowLabel, command));
+ }
+ }
+ if (!buttons.length) {
+ continue;
+ }
+ if (label) {
+ items.add({ type: "group", label, items: buttons });
+ } else {
+ items.addMany(buttons);
+ }
+ }
+
+ const dropdown = createDropdown(locale);
+ addListToDropdown(dropdown, items, { role: "menu" });
+ dropdown.buttonView.set({ label: t("Image position"), tooltip: true });
+ dropdown.buttonView.bind("icon").to(command, "value", (value) => {
+ const current = typeof value === "string" ? styles.get(value) : undefined;
+ return (current ?? styles.get("inline") ?? styles.values().next().value)?.icon;
+ });
+ dropdown.bind("isEnabled").to(command);
+ dropdown.on("execute", (evt) => {
+ const { styleName } = evt.source as ButtonView & { styleName: string };
+ editor.execute("imageStyle", { value: styleName });
+ editor.editing.view.focus();
+ });
+ return dropdown;
+ }
+}
+
+function createRow(style: ImageStyleOptionDefinition, label: string, command: Command): ListDropdownButtonDefinition {
+ const model = new UIModel({
+ label, icon: style.icon, withText: true, role: "menuitemradio", styleName: style.name
+ });
+ model.bind("isOn").to(command, "value", (value) => value === style.name);
+ return { type: "button", model };
+}
+
+declare module "ckeditor5" {
+ interface PluginsMap {
+ [ImagePosition.pluginName]: ImagePosition;
+ }
+}
diff --git a/packages/ckeditor5/src/plugins/toolbar_group_menu.spec.ts b/packages/ckeditor5/src/plugins/toolbar_group_menu.spec.ts
index 3003d48827..7ad4002d8b 100644
--- a/packages/ckeditor5/src/plugins/toolbar_group_menu.spec.ts
+++ b/packages/ckeditor5/src/plugins/toolbar_group_menu.spec.ts
@@ -92,7 +92,7 @@ class SampleDropdown extends Plugin {
items.add({ type: "button", model: new UIModel({ withText: true }) });
items.add({
type: "group",
- model: new UIModel({ label: "Grouped" }),
+ label: "Grouped",
items: new Collection([{
type: "button" as const,
model: new UIModel({ label: "Inside", withText: true })
@@ -493,8 +493,10 @@ describe("ToolbarGroupMenu", () => {
groupDropdown(getToolbar(editor), "Insert").isOpen = true;
expect(labels(last().items)).toStrictEqual(["Bold", "—", "Italic", "Odd list", ""]);
- // A list's groups are passed over, and an unlabeled button or dropdown is named "".
- expect(labels(entry(last().items, "Odd list").children ?? [])).toStrictEqual(["First", "—", ""]);
+ // A list's group is a heading over its rows, and an unlabeled button or dropdown is named "".
+ const odd = entry(last().items, "Odd list").children ?? [];
+ expect(labels(odd)).toStrictEqual(["First", "—", "", "Grouped", "Inside"]);
+ expect(odd[3]?.kind).toBe("heading");
expect(labels(entry(last().items, "").children ?? [])).toStrictEqual(["Row"]);
});
diff --git a/packages/ckeditor5/src/plugins/toolbar_group_menu.ts b/packages/ckeditor5/src/plugins/toolbar_group_menu.ts
index c7a166c0bb..42b199618c 100644
--- a/packages/ckeditor5/src/plugins/toolbar_group_menu.ts
+++ b/packages/ckeditor5/src/plugins/toolbar_group_menu.ts
@@ -1,6 +1,6 @@
import {
BalloonToolbar, BlockToolbar, ButtonView, DropdownView, type Editor, type FocusTracker,
- ListItemView, ListSeparatorView, ListView, Plugin, SearchTextView, SplitButtonView, SwitchButtonView,
+ ListItemGroupView, ListItemView, ListSeparatorView, ListView, Plugin, SearchTextView, SplitButtonView, SwitchButtonView,
type ToolbarConfig, type ToolbarConfigItem, ToolbarSeparatorView, type ToolbarView, type View
} from "ckeditor5";
@@ -428,6 +428,8 @@ function describeListEntries(dropdown: DropdownView, run: (view: View) => () =>
for (const entry of entries) {
if (entry instanceof ListSeparatorView) {
addRule(rows);
+ } else if (entry instanceof ListItemGroupView) {
+ rows.push({ kind: "heading", label: entry.label });
} else {
rows.push(describeButton(entry, run(entry)));
}
@@ -479,15 +481,21 @@ function listEntriesOf(dropdown: DropdownView) {
return undefined;
}
- const entries: Array<ButtonView | ListSeparatorView> = [];
- for (const item of listView.items) {
+ return listItemEntries(listView.items);
+}
+
+/** The buttons and separators of a list's items, a group's label before its own. */
+function listItemEntries(items: Iterable<View>) {
+ const entries: Array<ButtonView | ListSeparatorView | ListItemGroupView> = [];
+ for (const item of items) {
if (item instanceof ListSeparatorView) {
entries.push(item);
+ } else if (item instanceof ListItemGroupView) {
+ entries.push(item, ...listItemEntries(item.items));
} else if (item instanceof ListItemView && item.children.first instanceof ButtonView) {
entries.push(item.children.first);
}
}
-
return entries;
}