简化合并
This commit is contained in:
parent
9c44a4d425
commit
04c3f57218
11
markdown.js
11
markdown.js
@ -111,13 +111,10 @@ element.onclick = (event) => {
|
||||
return { index: i, rect: range.getBoundingClientRect() }
|
||||
})
|
||||
|
||||
const closest = positions.reduce(
|
||||
(closest, pos) => {
|
||||
const dist = Math.abs(x - pos.rect.left)
|
||||
return dist < closest.distance ? { ...pos, distance: dist } : closest
|
||||
},
|
||||
{ index: -1, distance: Infinity }
|
||||
)
|
||||
const closest = positions.reduce((closest, pos) => {
|
||||
const dist = Math.abs(x - pos.rect.left)
|
||||
return dist < closest.distance ? { ...pos, distance: dist } : closest
|
||||
}, { index: -1, distance: Infinity })
|
||||
|
||||
const rect = closest.rect
|
||||
const insertBefore = x < rect.left + rect.width / 2
|
||||
|
Loading…
Reference in New Issue
Block a user