Any chance of enabling the copy from codeblock function in discourse?

Currently when people paste logs etc which can be quite long it is much easier to view them in a local editor rather than in the limited view box on the forum. Currently as far as I know there isn’t an easy way to copy the whole code block easily without inadvertently selecting everything on the page for example.

Discourse has a built in as of 2023 that enables a copy button on codeblocks but wasn’t enabled by default originally (but is now). Any chance of enabling it on the manjaro forum? It would make forum life so much easier.

Which discourse theme are you using for the forum? The feature is working when the Manjaro theme is set:

It is enabled, but the bug gremlins ate it after some update several months ago (and nobody can figure out how to fix it, at least from the 2-3 people that tried me included). Now it is only working in the manjaro theme. I wasn’t aware of that until now, i guess we can revisit this and try to compare the code.

For all other themes it is working in the mobile mode, that is, resizing the browser under 40em makes it appear. Quite a stupid workaround but sometimes useful.

2 Likes

Buttons for preformatted text data missing

Firefox HTML/CSS inspection shows buttons set to opacity:0 and visibility:hidden if min-width: 40rem

Buttons can be made visible again using this CSS override

  .codeblock-buttons .copy-cmd:not(.action-complete), .codeblock-buttons .fullscreen-cmd:not(.action-complete) {
    opacity: 1;
    visibility: visible;
  }

Ahh yes, I presumed it was theme agnostic since its a global setting. I can confirm it works on the Manjaro theme. I did change from the Manjaro theme to fix some other UI issue but I can’t recall what it was now so I guess I’ll stumble across it again soon enough. Thanks.

:thinking: I wonder if the themes need updating??? If they’re older than the global option perhaps they don’t include the code to display it???

As I recall the admin panel, the other themes available is provided as part of Discourse and should in theory be updated during normal maintenenance.

Let me take a look at it.

The following themes is maintained upstream

The Manjaro theme is maintained at Manjaro Gitlab and a while back I made some subtle changes to make the copy-to-clipboard and the code-full-screen-view buttons visible at higher resolutions.

This means that changes to other themes must be directed at the relevant repositories as show above.

4 Likes

Perfect, thanks :+1:

1 Like

Which file exactly should be overridden?

2 Likes

Thanks, but i am currently in the chromium camp. There is actually a very convoluted function to do it built in, but somehow it only worked on cache…
And i am not comfortable giving read access to all sites to some extension.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.