From f5076a37aed404142d1eb7dfe1eff20fc35cb1e5 Mon Sep 17 00:00:00 2001 From: Daniel Dybing Date: Mon, 15 Dec 2025 08:32:00 +0100 Subject: [PATCH] feat(core): find todo list based on 'checkbox' search query (#13982) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This feature enhances the /slash command by allowing users to search for 'checkbox' and have the to-do list item show up as a result. Users come from different systems and environments, and some may use the name 'checkbox' but be confused as they cannot find it in the search menu. This is achieved by adding a `searchAlias` property on the to-do list item block that contains the string `checkbox`. ## Summary by CodeRabbit * **New Features** * Added search-alias support for slash menu items so entries can be found by alternative terms. * To-do List entry now includes "checkbox" as an additional searchable alias to improve discoverability. * Slash menu search results updated to reflect alias-driven matches (additional item appears when searching). ✏️ Tip: You can customize this high-level summary in your review settings. --------- Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> --- blocksuite/affine/blocks/note/src/configs/slash-menu.ts | 3 ++- blocksuite/affine/rich-text/src/conversion.ts | 2 ++ tests/blocksuite/e2e/slash-menu.spec.ts | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/blocksuite/affine/blocks/note/src/configs/slash-menu.ts b/blocksuite/affine/blocks/note/src/configs/slash-menu.ts index 3c41811cb..8efc0b299 100644 --- a/blocksuite/affine/blocks/note/src/configs/slash-menu.ts +++ b/blocksuite/affine/blocks/note/src/configs/slash-menu.ts @@ -82,12 +82,13 @@ function createConversionItem( config: TextConversionConfig, group?: SlashMenuItem['group'] ): SlashMenuActionItem { - const { name, description, icon, flavour, type } = config; + const { name, description, icon, flavour, type, searchAlias = [] } = config; return { name, group, description, icon, + searchAlias, tooltip: tooltips[name], when: ({ model }) => model.store.schema.flavourSchemaMap.has(flavour), action: ({ std }) => { diff --git a/blocksuite/affine/rich-text/src/conversion.ts b/blocksuite/affine/rich-text/src/conversion.ts index 61612c8b5..a48250bea 100644 --- a/blocksuite/affine/rich-text/src/conversion.ts +++ b/blocksuite/affine/rich-text/src/conversion.ts @@ -26,6 +26,7 @@ export interface TextConversionConfig { description?: string; hotkey: string[] | null; icon: TemplateResult<1>; + searchAlias?: string[]; } export const textConversionConfigs: TextConversionConfig[] = [ @@ -106,6 +107,7 @@ export const textConversionConfigs: TextConversionConfig[] = [ type: 'todo', name: 'To-do List', description: 'Add tasks to a to-do list.', + searchAlias: ['checkbox'], hotkey: null, icon: CheckBoxIcon, }, diff --git a/tests/blocksuite/e2e/slash-menu.spec.ts b/tests/blocksuite/e2e/slash-menu.spec.ts index e7c38748a..b23f7f132 100644 --- a/tests/blocksuite/e2e/slash-menu.spec.ts +++ b/tests/blocksuite/e2e/slash-menu.spec.ts @@ -577,7 +577,7 @@ test.describe('slash search', () => { // search should active the first item await type(page, 'co'); - await expect(slashItems).toHaveCount(4); + await expect(slashItems).toHaveCount(5); await expect(slashItems.nth(0).locator('.text')).toHaveText(['Copy']); await expect(slashItems.nth(1).locator('.text')).toHaveText(['Code Block']); await expect(slashItems.nth(2).locator('.text')).toHaveText(['Callout']); @@ -589,7 +589,7 @@ test.describe('slash search', () => { // assert backspace works await pressBackspace(page); - await expect(slashItems).toHaveCount(4); + await expect(slashItems).toHaveCount(5); await expect(slashItems.nth(0).locator('.text')).toHaveText(['Copy']); await expect(slashItems.nth(1).locator('.text')).toHaveText(['Code Block']); await expect(slashItems.nth(2).locator('.text')).toHaveText(['Callout']); @@ -608,7 +608,7 @@ test.describe('slash search', () => { await expect(slashMenu).toBeVisible(); await type(page, 'c'); - await expect(slashItems).toHaveCount(10); + await expect(slashItems).toHaveCount(11); await expect(slashItems.nth(0).locator('.text')).toHaveText(['Copy']); await expect(slashItems.nth(1).locator('.text')).toHaveText(['Italic']); await expect(slashItems.nth(2).locator('.text')).toHaveText(['Callout']);