Making WordPress.org

Opened 22 months ago

Last modified 22 months ago

#6756 reviewing feature request

Add a copy to clipboard button to code blocks

Reported by: johnbillion's profile johnbillion Owned by: tellyworth's profile tellyworth
Milestone: Priority: normal
Component: Make (Get Involved) / P2 Keywords:
Cc:

Description

Many web services display a "Copy to clipboard" button on the right hand side of a code block. It would be great to have the same on code blocks that appear on the Make sites, and maybe even the developer reference.

Change History (2)

#1 @tellyworth
22 months ago

  • Owner set to tellyworth
  • Status changed from new to reviewing

This is already the case in the Developer reference, for example: https://developer.wordpress.org/reference/functions/add_settings_section/#more-information

I'll look into whether we can enable the same code syntax highlighter plugin on Make sites.

#2 @tellyworth
22 months ago

There's more to it than just enabling the plugin on Make sites. The Developer reference has some custom JS that adds copy and expand buttons:

https://github.com/WordPress/wporg-developer/blob/trunk/source/wp-content/themes/wporg-developer-2023/js/function-reference.js#L30-L99

@ryelle what's your take on the best way to make that feature available elsewhere? Do we need a second companion plugin for code-syntax-block that would incorporate those buttons and other customizations for use across the site?

Note: See TracTickets for help on using tickets.