mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-27 00:54:22 +02:00
port remove link button pr to master
This commit is contained in:
@@ -25,6 +25,7 @@ const LinkExample = () => {
|
||||
<Slate editor={editor} value={value} onChange={value => setValue(value)}>
|
||||
<Toolbar>
|
||||
<LinkButton />
|
||||
<RemoveLinkButton />
|
||||
</Toolbar>
|
||||
<Editable
|
||||
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[] = [
|
||||
{
|
||||
type: 'paragraph',
|
||||
|
Reference in New Issue
Block a user