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

disable user-select on console line numbers and times #390

Merged
merged 1 commit into from
Oct 26, 2021
Merged

disable user-select on console line numbers and times #390

merged 1 commit into from
Oct 26, 2021

Conversation

saj
Copy link
Contributor

@saj saj commented Oct 20, 2021

This trivial patch goes some way towards addressing a problem I reported on the lists a while ago.

Our goal is as follows. We would like to select and copy text from the console UI without superfluous noise. The text in the user's clipboard buffer must closely match what is displayed in the browser. (We can happily live without colours or other stuff that cannot be represented in plain text.)

There are at least two smaller problems here:

  1. We must avoid copying the leading line number and trailing timestamp (or time offset).
  2. We must avoid superfluous blank lines between content lines.

This patch seems to fix (1) but does not fix (2).

Before:

before

After:

after

On Firefox, copying the selected text produces the following on paste:

 _____ 

< moo >

 ----- 

As far as I can tell, this probably has something to do with the trailing newline in the span content (because white-space: pre-wrap?):

<code class="ansi-hook console_output__2qZpe"><div class="console_line__1ir27"><span class="console_line-number__3zolU">1</span><span class="loc-html console_line-content__3xTWR">+ cowsay moo
</span><span class="console_line-time__oQvWj">0s</span></div><div class="console_line__1ir27"><span class="console_line-number__3zolU">2</span><span class="loc-html console_line-content__3xTWR"> _____ 
</span><span class="console_line-time__oQvWj">0s</span></div><div class="console_line__1ir27"><span class="console_line-number__3zolU">3</span><span class="loc-html console_line-content__3xTWR">&lt; moo &gt;
</span><span class="console_line-time__oQvWj">0s</span></div><div class="console_line__1ir27"><span class="console_line-number__3zolU">4</span><span class="loc-html console_line-content__3xTWR"> ----- 
</span><span class="console_line-time__oQvWj">0s</span></div><div class="console_line__1ir27"><span class="console_line-number__3zolU">5</span><span class="loc-html console_line-content__3xTWR">        \   ^__^
</span><span class="console_line-time__oQvWj">0s</span></div><div class="console_line__1ir27"><span class="console_line-number__3zolU">6</span><span class="loc-html console_line-content__3xTWR">         \  (oo)\_______
</span><span class="console_line-time__oQvWj">0s</span></div><div class="console_line__1ir27"><span class="console_line-number__3zolU">7</span><span class="loc-html console_line-content__3xTWR">            (__)\       )\/\
</span><span class="console_line-time__oQvWj">0s</span></div><div class="console_line__1ir27"><span class="console_line-number__3zolU">8</span><span class="loc-html console_line-content__3xTWR">                ||----w |
</span><span class="console_line-time__oQvWj">0s</span></div><div class="console_line__1ir27"><span class="console_line-number__3zolU">9</span><span class="loc-html console_line-content__3xTWR">                ||     ||
</span><span class="console_line-time__oQvWj">0s</span></div><div></div></code>

I don't know anything about web stuff. This problem has caused quite a bit of consternation, though, so I thought I'd at least try to get the ball rolling in the hope that you can see an easy way forward. Please feel free to do whatever you like with this patch.

@d1wilko
Copy link
Contributor

d1wilko commented Oct 26, 2021

Hi @saj, this looks ok to me :) I will merge

@d1wilko d1wilko merged commit f0c4109 into drone:main Oct 26, 2021
@d1wilko d1wilko added the bug label Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants