瀏覽代碼

feat: add id in block search

Ahmad Kholid 2 年之前
父節點
當前提交
72314f5a7f
共有 1 個文件被更改,包括 9 次插入5 次删除
  1. 9 5
      src/components/newtab/workflow/editor/EditorSearchBlocks.vue

+ 9 - 5
src/components/newtab/workflow/editor/EditorSearchBlocks.vue

@@ -47,6 +47,12 @@
             {{ item.description }}
           </p>
         </div>
+        <span
+          title="Block id"
+          class="text-xs w-16 text-overflow text-gray-600 dark:text-gray-300 bg-box-transparent p-1 rounded-md"
+        >
+          {{ item.id }}
+        </span>
       </template>
     </ui-autocomplete>
   </div>
@@ -90,12 +96,10 @@ const shortcut = useShortcut('editor:search-blocks', () => {
 });
 
 function searchNodes({ item, text }) {
-  const query = text.toLocaleLowerCase();
+  const isMatch = (str) =>
+    str.toLocaleLowerCase().includes(text.toLocaleLowerCase());
 
-  return (
-    item.name.toLocaleLowerCase().includes(query) ||
-    item.description.toLocaleLowerCase().includes(query)
-  );
+  return isMatch(item.id) || isMatch(item.name) || isMatch(item.description);
 }
 function toggleActiveSearch() {
   state.active = !state.active;