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:
@@ -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',
|
||||||
|
Reference in New Issue
Block a user