1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-15 03:33:59 +02:00

Fix triple click handling in nested blocks (#4965)

This commit is contained in:
Eric Meier
2022-04-25 21:33:59 -04:00
committed by GitHub
parent 15e11f87e9
commit a4536e2aa2
2 changed files with 16 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
Fix tripple click handling in nested blocks

View File

@@ -780,9 +780,17 @@ export const Editable = (props: EditableProps) => {
}
if (event.detail === TRIPLE_CLICK && path.length >= 1) {
const start = Editor.start(editor, [path[0]])
const end = Editor.end(editor, [path[0]])
const range = Editor.range(editor, start, end)
let blockPath = path
if (!Editor.isBlock(editor, node)) {
const block = Editor.above(editor, {
match: n => Editor.isBlock(editor, n),
at: path,
})
blockPath = block?.[1] ?? path.slice(0, 1)
}
const range = Editor.range(editor, blockPath)
Transforms.select(editor, range)
return
}