@@ -20,7 +20,7 @@ import textEditor from '@hcengineering/text-editor'
20
20
import { type CompletionOptions } from '../Completion'
21
21
import MentionList from './MentionList.svelte'
22
22
import { SvelteRenderer } from './node-view'
23
- import type { SuggestionKeyDownProps , SuggestionProps } from './extension/suggestion'
23
+ import type { SuggestionKeyDownProps , SuggestionOptions , SuggestionProps } from './extension/suggestion'
24
24
import InlineCommandsList from './InlineCommandsList.svelte'
25
25
26
26
export const mInsertTable = [
@@ -141,14 +141,29 @@ export function inlineCommandsConfig (
141
141
) : Partial < CompletionOptions > {
142
142
return {
143
143
suggestion : {
144
- items : ( ) => {
145
- return [
144
+ items : ( { query } : { query : string } ) => {
145
+ const items = [
146
146
{ id : 'image' , label : textEditor . string . Image , icon : view . icon . Image } ,
147
147
{ id : 'table' , label : textEditor . string . Table , icon : view . icon . Table2 } ,
148
148
{ id : 'code-block' , label : textEditor . string . CodeBlock , icon : view . icon . CodeBlock } ,
149
149
{ id : 'separator-line' , label : textEditor . string . SeparatorLine , icon : view . icon . SeparatorLine } ,
150
150
{ id : 'todo-list' , label : textEditor . string . TodoList , icon : view . icon . TodoList }
151
151
] . filter ( ( { id } ) => ! excludedCommands . includes ( id as InlineCommandId ) )
152
+
153
+ // to handle case of `todo-list` and `action-item` being the same
154
+ const searchableItems = items . map ( item =>
155
+ item . id === 'todo-list'
156
+ ? { ...item , searchLabels : [ 'action-item' , textEditor . string . TodoList ] }
157
+ : { ...item , searchLabels : [ item . label ] }
158
+ )
159
+
160
+ const filteredItems = searchableItems . filter ( item =>
161
+ item . searchLabels . some ( label =>
162
+ label . toLowerCase ( ) . includes ( query . toLowerCase ( ) )
163
+ )
164
+ )
165
+
166
+ return filteredItems . length > 0 ? filteredItems : items
152
167
} ,
153
168
command : ( { editor, range, props } : { editor : Editor , range : Range , props : any } ) => {
154
169
editor . commands . deleteRange ( range )
@@ -169,6 +184,7 @@ export function inlineCommandsConfig (
169
184
element : document . body ,
170
185
props : {
171
186
...props ,
187
+ query : props . query ,
172
188
close : ( ) => {
173
189
component . destroy ( )
174
190
}
0 commit comments