mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-06 08:09:41 +01:00
fix the bug of user can't use 'mod + a' to select or delete all nodes when use image(void) element (#5344)
Co-authored-by: linqirong <609413692@qq.com>
This commit is contained in:
parent
2a0a530931
commit
ee7eac4331
@ -1,6 +1,7 @@
|
|||||||
import React, { useMemo } from 'react'
|
import React, { useMemo } from 'react'
|
||||||
import imageExtensions from 'image-extensions'
|
import imageExtensions from 'image-extensions'
|
||||||
import isUrl from 'is-url'
|
import isUrl from 'is-url'
|
||||||
|
import isHotkey from 'is-hotkey'
|
||||||
import { Transforms, createEditor, Descendant } from 'slate'
|
import { Transforms, createEditor, Descendant } from 'slate'
|
||||||
import {
|
import {
|
||||||
Slate,
|
Slate,
|
||||||
@ -29,6 +30,12 @@ const ImagesExample = () => {
|
|||||||
<InsertImageButton />
|
<InsertImageButton />
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
<Editable
|
<Editable
|
||||||
|
onKeyDown={event => {
|
||||||
|
if (isHotkey('mod+a', event)) {
|
||||||
|
event.preventDefault()
|
||||||
|
Transforms.select(editor, [])
|
||||||
|
}
|
||||||
|
}}
|
||||||
renderElement={props => <Element {...props} />}
|
renderElement={props => <Element {...props} />}
|
||||||
placeholder="Enter some text..."
|
placeholder="Enter some text..."
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user