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() {
return Editor.start(this.editor, {
path: [0, 0],
offset: 0,
});
return Editor.start(this.editor, [0]);
}
public getEnd() {

View File

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

View File

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

View File

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

View File

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