DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:copy2clipboard

This is an old revision of the document!


copy2clipboard Plugin

Compatible with DokuWiki

  • 2020-07-29 "Hogfather" yes
  • 2018-04-22 "Greebo" yes
  • 2017-02-19 "Frusterick Manners" yes
  • 2016-06-26 "Elenor Of Tsort" yes

plugin Add a clipboard button to <code> and <file> blocks that copies text to the clipboard

Last updated on
2021-05-13
Repository
Source

Similar to clipboardutils, codeclipboard, copycode

Tagged with clipboard, copy

Example/Usage

  1. Install the plugin
  2. 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.

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 (beeing horribly partial here ;-)) :

  1. made of pure javascript, there is no PHP requirement, no DokuWiki requirement. It will work on any DokuWiki version, with any PHP version,
  2. 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,
  3. 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,
  4. It makes sure line endings are adapted to the os the navigator is running on. This eliminates powershell bug 496 and 3816 where lines are pasted in reverse order.
  5. It has no known bugs, yet.

Installation

Install the plugin using the Plugin Manager 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

Copy2code 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

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.

1)
This is the library component used by DokuWiki to highlight syntax
plugin/copy2clipboard.1620893779.txt.gz · Last modified: 2021-05-13 10:16 by schplurtz