1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-27 09:04:31 +02:00

port remove link button pr to master

This commit is contained in:
Ian Storm Taylor
2021-03-31 21:59:57 -04:00
parent c60020244b
commit 7723935b68

View File

@@ -25,6 +25,7 @@ const LinkExample = () => {
<Slate editor={editor} value={value} onChange={value => setValue(value)}> <Slate editor={editor} value={value} onChange={value => setValue(value)}>
<Toolbar> <Toolbar>
<LinkButton /> <LinkButton />
<RemoveLinkButton />
</Toolbar> </Toolbar>
<Editable <Editable
renderElement={props => <Element {...props} />} renderElement={props => <Element {...props} />}
@@ -134,6 +135,23 @@ const LinkButton = () => {
) )
} }
const RemoveLinkButton = () => {
const editor = useSlate()
return (
<Button
active={isLinkActive(editor)}
onMouseDown={event => {
if (isLinkActive(editor)) {
unwrapLink(editor)
}
}}
>
<Icon>link_off</Icon>
</Button>
)
}
const initialValue: Descendant[] = [ const initialValue: Descendant[] = [
{ {
type: 'paragraph', type: 'paragraph',