slidev icon indicating copy to clipboard operation
slidev copied to clipboard

How to make text Copyable?

Open ahandsel opened this issue 2 years ago • 9 comments

Is your feature request related to a problem? Please describe.

I really like Slidev but unlike reveal.js, I cannot copy the text from my Slidev slides. Being dyslexic, I need my slides to be readable by my text-to-audio programs.

I noticed that Slidev's CSS includes the following:

{
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none
}

How can I disable this CSS that prevents simple copying of text?

Describe the solution you'd like A simple way to disable the CSS (mentioned above) to enable copying of text

Thank you for your time 🙇‍♂️

ahandsel avatar Mar 14 '22 08:03 ahandsel

you can set selectable to true in the frontmatter of your first slide.

LarchLiu avatar Mar 20 '22 18:03 LarchLiu

Thank you @LarchLiu ! 🥳 I did not think to use selectable when searching for the text selection feature. It is so obvious in hindsight!

Adding a bit more information for others. + Update

To Make Text Copyable in Slidev Slides

Method 1 - selectable setting

Enable the selectable setting by adding selectable: true in the first slide's frontmatter.
It is laid out in Slidev's config.ts file.
⚠️ Warning: This method may not work with imported Slidev themes.

First slide's frontmatter

---
theme: seriph
class: text-center
highlighter: shiki
lineNumbers: false
drawings:
  persist: false
selectable: true
download: true
background: ./background/patrick-tomasso-Oaqk7qqNh_c-unsplash.jpeg
title: Pandas~
info: Presentation on how amazing pandas are!
---

Method 2 - Add a overriding style.css file

Create a style.css file in the project root folder with the following to override all other style configurations for your Slidev project. ⚡ This works with any Slidev theme.

style.css

.slidev-layout {
  h1, h2, h3, h4, p, div {
    @apply select-text;
  }
}

ahandsel avatar Mar 20 '22 19:03 ahandsel

PR welcome to support selectable: false and remove the global user-select disabling.

antfu avatar Mar 21 '22 10:03 antfu

If it is just a matter of the default value for the selectable option, I created a PR for selectable to be false by default: https://github.com/slidevjs/slidev/pull/545

tonai avatar Apr 13 '22 16:04 tonai

Yea, adding another frontmatter prop like code_copy: true would be super helpful i think.

So that, in all our code snippets, we can copy the text without any issues.

Making selectable in first slide is not a solution, it enables us to copy all the slide text (for example: we can select heading, images etc.., but actually we want to copy code alone.)

anburocky3 avatar Jul 01 '22 09:07 anburocky3

v0.34.2 added the button to copy the code for each code block.

antfu avatar Jul 01 '22 13:07 antfu

Cool release! Thanks

How about making selectable to code blocks?

What suppose, while on presentation, we have to tell them line by line by selection? I know we can do it by adding animations like {1}, but even after displaying that animation, explaining them in detail requires this selectable.

Like this: image

The problem i have is that, when i have selectable: true, all slide elements are selectable.

anburocky3 avatar Jul 01 '22 14:07 anburocky3

Would

.slidev-code {
  user-select: text;
}

work?

antfu avatar Jul 01 '22 14:07 antfu

Would

.slidev-code {
  user-select: text;
}

work?

Works Great! I think we can close this issue.

anburocky3 avatar Jul 02 '22 09:07 anburocky3