mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-24 05:07:06 +08:00
feat: fix global search empty item
This commit is contained in:
+10
-7
@@ -103,13 +103,16 @@ export const Search = (props: SearchProps) => {
|
|||||||
result_hide: !result.length,
|
result_hide: !result.length,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{result.map(block => (
|
{result
|
||||||
<BlockPreview
|
// 过滤掉空标题的文档
|
||||||
key={block.id}
|
.filter(block => block.content)
|
||||||
block={block}
|
.map(block => (
|
||||||
onClick={() => handle_navigate(block.id)}
|
<BlockPreview
|
||||||
/>
|
key={block.id}
|
||||||
))}
|
block={block}
|
||||||
|
onClick={() => handle_navigate(block.id)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</MuiBox>
|
</MuiBox>
|
||||||
</Box>
|
</Box>
|
||||||
</TransitionsModal>
|
</TransitionsModal>
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
|
/* eslint-disable filename-rules/match */
|
||||||
import { StrictMode } from 'react';
|
import { StrictMode } from 'react';
|
||||||
|
|
||||||
import { HookType } from '@toeverything/framework/virgo';
|
import { HookType } from '@toeverything/framework/virgo';
|
||||||
|
|
||||||
import { BasePlugin } from '../base-plugin';
|
import { BasePlugin } from '../base-plugin';
|
||||||
import { Search } from './search';
|
import { Search } from './Search';
|
||||||
import { PluginRenderRoot } from '../utils';
|
import { PluginRenderRoot } from '../utils';
|
||||||
|
|
||||||
export class FullTextSearchPlugin extends BasePlugin {
|
export class FullTextSearchPlugin extends BasePlugin {
|
||||||
@@ -17,6 +18,13 @@ export class FullTextSearchPlugin extends BasePlugin {
|
|||||||
this.hooks.addHook(HookType.ON_SEARCH, this.handle_search, this);
|
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() {
|
private unmount() {
|
||||||
if (this.#root) {
|
if (this.#root) {
|
||||||
this.editor.setHotKeysScope();
|
this.editor.setHotKeysScope();
|
||||||
@@ -30,21 +38,22 @@ export class FullTextSearchPlugin extends BasePlugin {
|
|||||||
this.render_search();
|
this.render_search();
|
||||||
}
|
}
|
||||||
private render_search() {
|
private render_search() {
|
||||||
this.#root = new PluginRenderRoot({
|
if (this.#root) {
|
||||||
name: FullTextSearchPlugin.pluginName,
|
this.#root.mount();
|
||||||
render: this.editor.reactRenderRoot.render,
|
this.#root.render(
|
||||||
});
|
<StrictMode>
|
||||||
this.#root.mount();
|
<Search
|
||||||
this.#root.render(
|
onClose={() => this.unmount()}
|
||||||
<StrictMode>
|
editor={this.editor}
|
||||||
<Search onClose={() => this.unmount()} editor={this.editor} />
|
/>
|
||||||
</StrictMode>
|
</StrictMode>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public renderSearch() {
|
public renderSearch() {
|
||||||
this.render_search();
|
this.render_search();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { QueryResult } from './search';
|
export type { QueryResult } from './Search';
|
||||||
export { QueryBlocks } from './search';
|
export { QueryBlocks } from './Search';
|
||||||
|
|||||||
Reference in New Issue
Block a user