Skip to content

fix: Selection clicking editor padding #1717

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: click-between-blocks-fix
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
25 changes: 18 additions & 7 deletions packages/core/src/editor/Block.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,32 @@ BASIC STYLES
}

.bn-block-content {
display: flex;
transition: font-size 0.2s;
width: 100%;
}

.bn-block-content::before {
/* content: ""; */
transition: all 0.2s;
/*margin: 0px;*/
}

.bn-block-content.ProseMirror-selectednode > *,
/* Case for node view renderers */
.ProseMirror-selectednode > .bn-block-content > * {
border-radius: 4px;
outline: 4px solid rgb(100, 160, 255);
}

.bn-block-content::before {
transition: all 0.2s;
/* Workaround for selection issue on Chrome, see #1588 and also here:
https://discuss.prosemirror.net/t/mouse-down-selection-behaviour-different-on-chrome/8426
The :before element causes the selection to be set in the wrong place vs
other browsers. Setting no height fixes this, while list item indicators are
still displayed fine as overflow is not hidden. */
height: 0;
/* Also have to center the text vertically to ensure alignment at different
line heights (which we change for `.bn-inline-content` below). */
display: flex;
align-items: center;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also explicitly set the overflow to show. There are many CSS resets out there so if you rely on a default behavior it may not work in some projects.

}

.bn-inline-content {
width: 100%;
/* We use line height on `.bn-inline-content` to mimic padding on
Expand Down Expand Up @@ -182,11 +191,11 @@ NESTED BLOCKS
.bn-block-content::before {
margin-right: 0;
content: "";
display: inline;
}

/* Ordered */
.bn-block-content[data-content-type="numberedListItem"] {
align-items: center;
display: flex;
gap: 0.5em;
}
Expand All @@ -213,12 +222,14 @@ NESTED BLOCKS

/* Unordered */
.bn-block-content[data-content-type="bulletListItem"] {
align-items: center;
display: flex;
gap: 0.5em;
}

/* Checked */
.bn-block-content[data-content-type="checkListItem"] > div {
align-items: center;
display: flex;
width: 100%;
}
Expand Down
Loading