mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 23:43:41 +08:00
fix: typewriter shake after press enter (#1852)
This commit is contained in:
parent
dd672d75f1
commit
63642d3921
@ -618,10 +618,13 @@ class Selection {
|
|||||||
if (range.getClientRects) {
|
if (range.getClientRects) {
|
||||||
// range.collapse(true)
|
// range.collapse(true)
|
||||||
let rects = range.getClientRects()
|
let rects = range.getClientRects()
|
||||||
if (rects.length === 0) {
|
if (rects.length === 0 && range.startContainer && (range.startContainer.nodeType === Node.ELEMENT_NODE || range.startContainer.nodeType === Node.TEXT_NODE)) {
|
||||||
rects = range.startContainer && range.startContainer.nodeType === Node.ELEMENT_NODE
|
rects = range.startContainer.parentElement.getClientRects()
|
||||||
? range.startContainer.getClientRects()
|
// prevent tiny vibrations
|
||||||
: []
|
if (rects.length) {
|
||||||
|
const rect = rects[0]
|
||||||
|
rect.y = rect.y + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (rects.length) {
|
if (rects.length) {
|
||||||
const { left, top, x: rectX, y: rectY, width: rWidth } = rects[0]
|
const { left, top, x: rectX, y: rectY, width: rWidth } = rects[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user