Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix co-ordinate issue with display: contents nodes #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/domcoords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ function posFromCaret(view: EditorView, node: Node, offset: number, coords: {top
if (!desc) return null
if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent || !desc.contentDOM)) {
let rect = (desc.dom as HTMLElement).getBoundingClientRect()
if (!rect.width && !rect.height) {
// its possible to have a node with display:contents, yet it contains other block nodes.
dan-cooke marked this conversation as resolved.
Show resolved Hide resolved
cur = desc.dom.parentNode!
sawBlock = true;
continue;
}
if (desc.node.isBlock && desc.parent) {
// Only apply the horizontal test to the innermost block. Vertical for any parent.
if (!sawBlock && rect.left > coords.left || rect.top > coords.top) outsideBlock = desc.posBefore
Expand Down