feat: Link feature add search function

This commit is contained in:
xiaodong zuo 2022-09-03 09:24:03 +08:00
parent e18a35989f
commit a89d5847df
5 changed files with 10 additions and 12 deletions

View File

@ -690,10 +690,7 @@ class SlateUtils {
} }
public getStart() { public getStart() {
return Editor.start(this.editor, { return Editor.start(this.editor, [0]);
path: [0, 0],
offset: 0,
});
} }
public getEnd() { public getEnd() {

View File

@ -185,10 +185,12 @@ export const DoubleLinkMenu = ({
} }
} }
const { type, anchorNode } = editor.selection.currentSelectInfo; const { type, anchorNode } = editor.selection.currentSelectInfo;
if (!anchorNode) {
return;
}
if ( if (
!isOpen || !isOpen ||
(type === 'Range' && (type === 'Range' &&
anchorNode &&
anchorNode.id !== curBlockId && anchorNode.id !== curBlockId &&
editor.blockHelper.isSelectionCollapsed(anchorNode.id)) editor.blockHelper.isSelectionCollapsed(anchorNode.id))
) { ) {

View File

@ -3,7 +3,7 @@ import { BasePlugin } from '../../base-plugin';
import { PluginRenderRoot } from '../../utils'; import { PluginRenderRoot } from '../../utils';
import { DoubleLinkMenu } from './DoubleLinkMenu'; import { DoubleLinkMenu } from './DoubleLinkMenu';
const PLUGIN_NAME = 'reference-menu'; const PLUGIN_NAME = 'doublelink-menu';
export class DoubleLinkMenuPlugin extends BasePlugin { export class DoubleLinkMenuPlugin extends BasePlugin {
private _root?: PluginRenderRoot; private _root?: PluginRenderRoot;

View File

@ -181,10 +181,10 @@ const common_handler_for_inline_menu: ClickItemHandler = ({
}); });
break; break;
case inlineMenuNamesKeys.link: case inlineMenuNamesKeys.link:
add_link({ // add_link({
editor, // editor,
blockId: anchorNodeId, // blockId: anchorNodeId,
}); // });
editor.plugins.emit('showAddLink'); editor.plugins.emit('showAddLink');
setShow(false); setShow(false);
break; break;

View File

@ -204,7 +204,7 @@ export const LinkMenu = ({ editor, hooks }: LinkMenuProps) => {
</LinkModalContainerIcon> </LinkModalContainerIcon>
<LinkModalContainerInput <LinkModalContainerInput
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
placeholder="Paste link url, like https://affine.pro" placeholder="Paste link url"
autoComplete="off" autoComplete="off"
value={searchText} value={searchText}
onChange={handleFilterChange} onChange={handleFilterChange}
@ -240,7 +240,6 @@ const LinkModalContainer = styled('div')(({ theme }) => ({
backgroundColor: '#fff', backgroundColor: '#fff',
alignItems: 'center', alignItems: 'center',
zIndex: '1', zIndex: '1',
width: '354px',
})); }));
const LinkModalContainerIcon = styled('div')(({ theme }) => ({ const LinkModalContainerIcon = styled('div')(({ theme }) => ({