Skip to content

fix: Only allow selection line content instead of parent element #348

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

Merged
merged 2 commits into from
Oct 29, 2020

Conversation

rtfpessoa
Copy link
Owner

@rtfpessoa rtfpessoa commented Oct 27, 2020

Fixes #346

width: 100%;
}

.d2h-code-line-ctn {
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason this isn't working as good is that these rules are currently partly overridden by the ones in line 149.
Also it looks like this then needs the following style so it is aliged correctly. (On both .d2h-code-line-ctn and .d2h-code-line-prefix):

    vertical-align: middle;

Copy link
Contributor

Choose a reason for hiding this comment

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

diff --git a/src/ui/css/diff2html.css b/src/ui/css/diff2html.css
index a657891..bc267dc 100644
--- a/src/ui/css/diff2html.css
+++ b/src/ui/css/diff2html.css
@@ -113,12 +113,6 @@
   width: 100%;
 }
 
-.d2h-code-line-ctn {
-  display: inline-block;
-  user-select: text;
-  width: 100%;
-}
-
 .d2h-code-line del,
 .d2h-code-side-line del {
   display: inline-block;
@@ -144,14 +138,18 @@
   padding: 0;
   word-wrap: normal;
   white-space: pre;
+  vertical-align: middle;
 }
 
 .d2h-code-line-ctn {
-  display: inline;
+  display: inline-block;
   background: none;
   padding: 0;
   word-wrap: normal;
   white-space: pre;
+  user-select: text;
+  width: 100%;
+  vertical-align: middle;
 }
 
 .line-num1 {

Copy link
Owner Author

Choose a reason for hiding this comment

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

My bad, this works fine. I just did not understand the difference caused by the vertical-align.
Maybe it matters for different font sizes or other changes in the style?

@rtfpessoa rtfpessoa force-pushed the only-allow-selection-line-content branch from dbdb704 to 33076dc Compare October 29, 2020 09:01
@rtfpessoa
Copy link
Owner Author

@campersau if it looks good for you, should I go ahead and merge it?

Copy link
Contributor

@campersau campersau left a comment

Choose a reason for hiding this comment

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

LGTM

@rtfpessoa rtfpessoa merged commit 1f261e6 into master Oct 29, 2020
@rtfpessoa rtfpessoa deleted the only-allow-selection-line-content branch October 29, 2020 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Leading whitespace when selecting / copying code in Chrome
2 participants