0

I'm trying to use this answer to copy and paste hyperlinks from Chrome as plain text and it seems to work when I paste to notepad. However, regardless of user-select: none;, when I paste the same clipboard contents to Libreoffice Writer all text is pasted. This happens when a styled block is surrounded by selectable blocks.

.unselectable {
  position: absolute;
  z-index: 1;
  color: green;
  user-select: none;
  -webkit-user-select: none;
}

.selectable {
  position: absolute;
  z-index: 2;
  color: rgba(0, 0, 0, 0);
  user-select: text;
  -webkit-user-select: text;
}
xxx
<p style="user-select: none;">
  <a href="mailto:unselectable@b.org">unselectable</a>
</p>

<p>
  <a href="mailto:default@b.org">default</a>
</p>

<div>
  <p unselectable="on" class="unselectable">unselectable2</p>
  <p>zzz</p>
</div>

enter image description here

enter image description here

basin
  • 3,676
  • 2
  • 23
  • 53

1 Answers1

0

Turns out this is a bug in Chrome.

A work around would be using -web-kit

.parent :not(.selectable-all) {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.selectable-all {
  -webkit-user-select: all;
  -moz-user-select: all;
  -ms-user-select: all;
  user-select: all;
}
<div class="parent">
  <span>un-selectable</span>
  <div class="child selectable-all">
    Selectable
  </div>
</div>

<div class="child selectable-all">
  Selectable
</div>

I tried and it works fine. Try and let me know if it worked for you as well.

Here is a link for reference;User-select: all inheritance not working in chrome 62

mw509
  • 1,605
  • 1
  • 18
  • 24