mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 05:01:17 +02:00
fix findDOMPoint for non-empty void node offsets
This commit is contained in:
@@ -21,14 +21,17 @@ function findDOMPoint(point, win = window) {
|
||||
|
||||
for (const text of texts) {
|
||||
const node = text.childNodes[0]
|
||||
const length = text.hasAttribute('data-slate-length')
|
||||
? parseInt(text.getAttribute('data-slate-length'), 10)
|
||||
: node.textContent.length
|
||||
const domLength = node.textContent.length
|
||||
let slateLength = domLength
|
||||
|
||||
const end = start + length
|
||||
if (text.hasAttribute('data-slate-length')) {
|
||||
slateLength = parseInt(text.getAttribute('data-slate-length'), 10)
|
||||
}
|
||||
|
||||
const end = start + slateLength
|
||||
|
||||
if (point.offset <= end) {
|
||||
const offset = Math.max(0, point.offset - start)
|
||||
const offset = Math.min(domLength, Math.max(0, point.offset - start))
|
||||
return { node, offset }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user