PHPackages                             linkrobins/clipboard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. linkrobins/clipboard

ActiveFlarum-extension[Utility &amp; Helpers](/categories/utility)

linkrobins/clipboard
====================

Adds a copy-to-clipboard button to code blocks, plus an optional language label. Ported to Flarum 2.0 from ffans/clipboardjs.

v1.1.1(1w ago)049↓38.8%[1 issues](https://github.com/linkrobins/clipboard/issues)MITJavaScriptPHP ^8.3

Since May 11Pushed 1w agoCompare

[ Source](https://github.com/linkrobins/clipboard)[ Packagist](https://packagist.org/packages/linkrobins/clipboard)[ RSS](/packages/linkrobins-clipboard/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Link Robins Clipboard
=====================

[](#link-robins-clipboard)

Adds a copy-to-clipboard button to every code block in posts, plus an optional language label in the top-right. Seven visual themes to choose from.

Ported to Flarum 2.0 from [`ffans/clipboardjs`](https://github.com/ffans/clipboardjs) (MIT). Credit to Golden for the original.

What it does
------------

[](#what-it-does)

Two features:

1. **Copy button on code blocks** — when a visitor hovers over a `` in a post, a small "copy" button appears. Click it; the code is on their clipboard. The button briefly flips to a checkmark to confirm. Seven button styles to match the look of GitHub, CSDN, Jianshu, etc.
2. **Language label on code blocks** — when a syntax highlighter (Prism, highlight.js, etc.) decorates `` with a `language-X` class, the extension hoists that class onto the parent `` and the CSS shows the language name in the top-right of the block.

Both features have independent toggles in the admin settings; you can use one without the other.

Requirements
------------

[](#requirements)

- Flarum **2.0** or later
- PHP **8.2** or later
- Optional: a syntax highlighter extension (for the language label feature to have something to display)

Installation
------------

[](#installation)

```
composer require linkrobins/clipboard
php flarum cache:clear

```

In Flarum admin → **Extensions**, find **Link Robins Clipboard** and enable it. Open its settings to pick a theme and toggle features.

Settings
--------

[](#settings)

- **Enable copy button on code blocks** — turn the copy button on or off
- **Copy button style** — default, GitHub, LingCoder, CSDN, cnBlogs, Jian Shu, SegmentFault
- **Show language label on code blocks** — turn the language label on or off

How it works under the hood
---------------------------

[](#how-it-works-under-the-hood)

The extension extends `CommentPost.oncreate` and, after each post renders, walks the post DOM for `` elements. For each one not already decorated, it inserts a themed button. Click handlers use the modern native `navigator.clipboard.writeText()` API to copy code text, with a hidden-textarea + `document.execCommand('copy')` fallback for older browsers or non-secure contexts.

The language detection sets up a `MutationObserver` once per page that watches `` elements for a `language-X` class. When one appears (after a syntax highlighter runs), the class is mirrored onto the parent `` so the CSS selectors in `_languages.less` can display the language name.

What changed from the 1.x original
----------------------------------

[](#what-changed-from-the-1x-original)

- Targets `flarum/core ^2.0`
- Renamed namespace: `linkrobins-clipboard.*`
- **Dropped the `clipboard` npm dependency** — modern browsers have a native clipboard API, and the original library is now obsolete
- **Dropped the `SaveSettings` listener** — it used `Flarum\Api\Event\Serializing` which was removed in Flarum 2.0, and its work is redundant with the `serializeToForum` extender calls already in `extend.php`
- **No webpack/JSX build** — vanilla JS, hand-written, no `node_modules`
- Uses `app.registry.for('linkrobins-clipboard')` (the 2.0 name) instead of `app.extensionData.for(...)`
- Setting type renamed `switch` → `boolean` (both work; `boolean` is the modern name)
- CSS class renamed to `LinkRobinsClipboard` (the `.clipboard` button class stays the same so themes from upstream still apply)

License
-------

[](#license)

MIT. Credit to [Golden / ffans](https://github.com/ffans) for the original implementation.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance98

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Total

3

Last Release

10d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.1.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ba4ada28098b217152b5ec67bff43409a54b808d7d038119af6f56715a1c3f9?d=identicon)[linkrobins](/maintainers/linkrobins)

---

Top Contributors

[![linkrobins](https://avatars.githubusercontent.com/u/213107296?v=4)](https://github.com/linkrobins "linkrobins (4 commits)")

### Embed Badge

![Health badge](/badges/linkrobins-clipboard/health.svg)

```
[![Health](https://phpackages.com/badges/linkrobins-clipboard/health.svg)](https://phpackages.com/packages/linkrobins-clipboard)
```

###  Alternatives

[flarum-lang/russian

Russian language pack for Flarum.

12127.5k](/packages/flarum-lang-russian)[fof/byobu

Well integrated, advanced private discussions.

61112.4k10](/packages/fof-byobu)[flarum/tags

Organize discussions into a hierarchy of tags and categories.

38744.9k133](/packages/flarum-tags)[fof/gamification

Upvotes and downvotes for your Flarum community

4162.0k6](/packages/fof-gamification)[fof/polls

 A Flarum extension that adds polls to your discussions

25130.2k9](/packages/fof-polls)[michaelbelgium/flarum-discussion-views

Add views to flarum discussions

3155.4k6](/packages/michaelbelgium-flarum-discussion-views)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
