Table of Contents
copy2clipboard Plugin
Compatible with DokuWiki
- 2024-02-06 "Kaos" yes
- 2023-04-04 "Jack Jackrum" yes
- 2022-07-31 "Igor" yes
- 2020-07-29 "Hogfather" yes
Similar to clipboardutils, codeclipboard, copycode
Example/Usage
- Install the plugin
- Enjoy!
Once installed, it will automatically add a «copy to clipboard»
button to every <code>
or <file>
code block
as shown on the screenshot below. Actually, on desktop browser, buttons become visible
only when mouse cursor enters the <code>
or <file>
region. On mobile
browsers, the buttons are always visible.
Description
This extension add a clipboard button to <code>
and <file>
blocks that copies text to the clipboard
This is already done by other extensions, copycode and codeclipboard.
However, it has the following advantages over the other extensions (being horribly partial here ):
- made of pure javascript, there is no PHP requirement, no DokuWiki requirement. It will work on any DokuWiki version, with any PHP version,
- It uses a relatively new but stable javacript API, so it should work for years before it becomes incompatible with navigators,
- Thus, as far as I can see, there will be no need to update this extension in the next millenia,
- It correctly copies codes formatted by geshi1). if you encounter the dreaded “Unrecognized character \xC2” error when you copy code to perl or python, manually or with other extensions, then copy2clipboard is the extension you need,
It has no known bugs, yet.2)
Installation
Install the plugin using the Extensions Manager Plugin and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.
This plugin does not require any DokuWiki or PHP component. As it is made of pure javascript, it should work with any DokuWiki version.
Browser compatibility
Copy2clipboard is javascript only and requires that your browser supports writing text to the clipboard via the clipboard API. As of 2021, it seems to me that this is a not so old feature. Check the Clipboard Browser compatibility table on MDN for the major browser compatibility status. If you can't use your browser, either update your browser, use another extension (copycode and codeclipboard for example), or send a simple fix as a PR on github.
Configuration and Settings
There is nothing to configure. If you want that this plugin uses your language, please add a translation on https://translate.dokuwiki.org/plugin/copy2clipboard.
Change Log
- version up (2024-12-01 15:53)
- Merge pull request #12 from dokuwiki-translate/lang_update_1005_17328… (2024-12-01 15:41)
- translation update (2024-11-29 10:35)
- version up (2023-04-17 19:47)
- Merge pull request #10 from dokuwiki-translate/lang_update_613_168167… (2023-04-17 09:04)
- translation update (2023-04-16 23:05)
- version up (2022-05-16 20:51)
- don't let the cp2clip div cover a nearby edit button (2022-05-16 20:50)
Known Bugs and Issues
- lone NO-BREAK SPACEs, (aka NBSP, aka U+00A0) on a line by themselves are not copied to the clipboard.
- This is not a bug but a feature. A lone NBSP almost never happens intentionally in a source code, so this will virtually break no code. On the other hand, geshi which is used by DokuWiki adds it to every empty lines, making empty lines non empty. Moreover, U+00A0 is not a white space, and it causes syntax error in programming languages, or formatted text file such as YAML or LDIF. The benefit of removing this character is much greater than the drawback of keeping it.
Issues, bug, suggestions should only be discussed on github issues page.
Please note that issues relating to browser compatibility will not be fixed (by the author).
FAQ
Discussion
Please, use github issue page so this page stays as clear and simple as possible.