There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat: fix global search empty item
DarkSkye273d1e6061e
diff --git a/libs/components/editor-plugins/src/search/search.tsx b/libs/components/editor-plugins/src/search/Search.tsxsimilarity index 87%rename from libs/components/editor-plugins/src/search/search.tsxrename to libs/components/editor-plugins/src/search/Search.tsxindex 2983df8e4c..5dd7c65096 100644--- a/libs/components/editor-plugins/src/search/search.tsx+++ b/libs/components/editor-plugins/src/search/Search.tsx@@ -103,13 +103,16 @@ export const Search = (props: SearchProps) => {result_hide: !result.length,})}>- {result.map(block => (- <BlockPreview- key={block.id}- block={block}- onClick={() => handle_navigate(block.id)}- />- ))}+ {result+ // 过滤掉空标题的文档+ .filter(block => block.content)+ .map(block => (+ <BlockPreview+ key={block.id}+ block={block}+ onClick={() => handle_navigate(block.id)}+ />+ ))}</MuiBox></Box></TransitionsModal>diff --git a/libs/components/editor-plugins/src/search/index.tsx b/libs/components/editor-plugins/src/search/index.tsxindex d4d4c0ef03..a19953ae8b 100644--- a/libs/components/editor-plugins/src/search/index.tsx+++ b/libs/components/editor-plugins/src/search/index.tsx@@ -1,9 +1,10 @@+/* eslint-disable filename-rules/match */import { StrictMode } from 'react';import { HookType } from '@toeverything/framework/virgo';import { BasePlugin } from '../base-plugin';-import { Search } from './search';+import { Search } from './Search';import { PluginRenderRoot } from '../utils';export class FullTextSearchPlugin extends BasePlugin {@@ -17,6 +18,13 @@ export class FullTextSearchPlugin extends BasePlugin {this.hooks.addHook(HookType.ON_SEARCH, this.handle_search, this);}+ protected override _onRender(): void {+ this.#root = new PluginRenderRoot({+ name: FullTextSearchPlugin.pluginName,+ render: this.editor.reactRenderRoot.render,+ });+ }+private unmount() {if (this.#root) {this.editor.setHotKeysScope();@@ -30,21 +38,22 @@ export class FullTextSearchPlugin extends BasePlugin {this.render_search();}private render_search() {- this.#root = new PluginRenderRoot({- name: FullTextSearchPlugin.pluginName,- render: this.editor.reactRenderRoot.render,- });- this.#root.mount();- this.#root.render(- <StrictMode>- <Search onClose={() => this.unmount()} editor={this.editor} />- </StrictMode>- );+ if (this.#root) {+ this.#root.mount();+ this.#root.render(+ <StrictMode>+ <Search+ onClose={() => this.unmount()}+ editor={this.editor}+ />+ </StrictMode>+ );+ }}public renderSearch() {this.render_search();}}-export type { QueryResult } from './search';-export { QueryBlocks } from './search';+export type { QueryResult } from './Search';+export { QueryBlocks } from './Search';