diff --git a/markdown.js b/markdown.js index 49bdc0c..f63d31d 100644 --- a/markdown.js +++ b/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