Copying Code-Fenced Text

Hi,

Could code fencing be enhanced to provide a Copy to Clipboard feature, currently, a CTRL+A selects all of the text in the whole window, not just the text in the fenced area when it’s focused.

Perhaps something like this in the bottom right and corner?

image

Or, in keeping with the style of the post toolbar, you could have an ellipsis which expands out with some additional code-based-tools, displayed as icons - not sure what those other tools would be at the moment, although an option to make the scrollable text area full height could be useful possibly.

image

image

(excuse rather cobbled together imagery/icons - I know you fine people would do this better, just for illustration etc)

1 Like

There is a component to copy the code

4 Likes

Hey Daniela,

Thank you for this, I had seen this but it looked a bit involved with regards to setting it up. What I was suggesting was more about having this type of functionality as standard, it would just come with the code-fenced areas by default.

I will take another look at the above though and thank you for the reply. :slight_smile:

1 Like

It is possible but hardcore coding functionality is not really the point of Discourse.

1 Like

Hey Jeff,

Yeah, I understand, I suppose I saw this as a fairly minor piece of functionality to add to a feature which already supports popping the code into posts.

I’ll give the above a whirl and keep my fingers crossed I don’t break anything :slight_smile:

I don’t think the setup is too complicated anymore if you use the Theme Component, you just paste the URL in and it should set it up, then all you need to do is associate it with your theme, so it takes effect.

3 Likes

Thanks for this. :slight_smile:

I’ve not really played with the themes on our Discourse install, that was done by someone else. I know we have a dark and a light, so would the above need doing for each of those or just the once?

Ok, so yeah, not making much sense of this now…

Is the URL I need the link to GitHub? e.g. https://github.com/daemonite/discourse-clipboard

Assuming so, do I need to import this as a new theme or as a component? When I clicked on New and then selected URL, I pasted in the above and it appeared to import it as a new theme, but I don’t want to have this instead of what we already have, I would want this as well?

You see how this process can be very confusing @sam and @johani and @hawk – we have a lot of work to do here to make it better.

6 Likes

I don’t mean to cause any offence, it is obviously very clever in what it does and I did just make a bit of progress - but from what I can see it is going to create a new theme, which then means I either need to copy in all of our existing Light and Dark them content into this, or, vice-versa - and that’s the bit that doesn’t feel very straight forward. It also means doing it on our live environment, so, if I screw it up (I will), it will be visible instantly.

Unless I am missing something, as I say I’ve not really meddled with the themes/components before and I do appreciate you have links on that page to documentation - I just assumed this would be a click and go kinda party :slight_smile:

At the moment I feel the safest thing to do would be to do the import as a new theme, then inspect each part of it, copy/pasting that into what we already have - commenting it a bit so I can undo if needed, but that does then mean checking through the various sections, each one of these tabs for example;

to make sure I’ve not missed any bits that may be needed and then do that all again for the other theme we have too.

Again, I may be missing something, seems taxing.

Having the copy functionality as a built in, out of the box, would of course save this - but I do appreciate the early comments regarding the point of Discourse etc, and that there are a variety of other solutions for code sharing - we just like to have it in with the chat for feedback/help etc in our community :slight_smile:

I’ll keep fiddling…

3 Likes

Not at all, this is a complaint I have about our theming system, it has been vastly improved over the last 6-8 months but I think it is still confusing from a basic UI standpoint.

3 Likes

I fully hold my hand up to stating I’ve not used it very much though to even become familiar with it. I work with those who own/pay for the hosted solution and have been trusted with Admin access. I tend to cover the day to day stuff but one of the other guys did all of the themes/html/css stuff, both originally and since it changed a bit.

Needless to say, as its working I don’t tend to dig around in it too much as I don’t want to be the one who breaks it :slight_smile:

I think with the above my assumption was perhaps that when I added the URL to GitHub it would have brought in what was needed as a component to our existing themes, so perhaps the opposite of what it currently does now. Again, my misunderstanding most likely. That would have given me the ability to add-to what we have, much like the way the plugins work I suppose.

Fully appreciate all of the replies, info and support by the way - thank you all :slight_smile:

2 Likes

conceptually, theme relates to the whole kaboodle. Themes can be constructed of additional building blocks called “components”.

In this case you are not trying to swap out the whole kaboodle just add a piece to your theme.

Unfortunately the component you are trying to add is missing a flag to notify us about that so we import it as a component and not a theme. I sent a PR to fix this here: Add hint so Discourse imports as a component by SamSaffron · Pull Request #3 · Daemonite/discourse-clipboard · GitHub . For the time being you will need to import it and then click the convert button.

The URL you are looking to import is indeed https://github.com/daemonite/discourse-clipboard

5 Likes

Unfortunately the component you are trying to add is missing a flag to notify us about that so we import it as a component and not a theme.

Aha! Ok, that’s cool then, so the process of getting this in, once that flag is there, will actually be more straight forward - fab! :slight_smile:

For the time being you will need to import it and then click the convert button.

Does the convert button literally just change a theme to a component Sam or does it do other things also?

On a completely unrelated note - kaboodle - by far not used enough in conversation these days, +1 :slight_smile:

2 Likes

I arbitarily clicked the convert button without knowing what would happen - happy days! :smiley:

Ok, so that made it a component and then once I had a component I could add it easily to one of the existing themes that we have - that was fairly straight forward - thanks for that :slight_smile:

Only minor grumble now (sorry), is this;

image

  • the icon is over the scroll bar which makes it a bit hard to see, would be in the ideal position without the scrollbar
  • the icon is almost the same colour as the code background
  • the standard browser tool tip also appears - bit of a clutter

Are any of these items easily changeable?

1 Like

Scrollbars aren’t usually visible by default these days, depending on the operating system of course.

1 Like

This is because of the length of the code in the frame there though isn’t it? e.g. they would surely appear at some point when the content exceeded the length of the frame, so the issue would still occur when the scroll bar does appear?

Using Windows / Chrome…

Example topic : https://community.gamedev.tv/t/sound-is-not-working-desperate-for-help/89862/3

I see both horizontal and vertical?

That is all it does, just flips a bit.

4 Likes

Worked really nicely :slight_smile:

1 Like