concept7 / statamic-bard-set-clipboard
Copy Bard sets from the set menu and paste them with a toolbar button or Cmd/Ctrl+V
Package info
github.com/concept7/statamic-bard-set-clipboard
Language:JavaScript
Type:statamic-addon
pkg:composer/concept7/statamic-bard-set-clipboard
Requires
- php: ^8.2
- statamic/cms: ^6.39
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-03 20:18:18 UTC
README
Copy and paste Bard sets in the Statamic control panel, also between entries.
- Copy Set in the "⋯" menu of every Bard set.
- Paste Set button (clipboard icon) in the toolbar of every Bard field that has sets. It pastes at the cursor.
- Cmd/Ctrl+V pastes a copied set as well, also when it was copied with Statamic's own Cmd/Ctrl+C.
- A pasted set keeps its images and other previews, also in another entry. Without this addon, Statamic pastes such a set with empty previews, although the values are still there.
- Pasting a set into a Bard field that does not have that set shows a message instead of failing silently.
- Dutch translations included.
Screenshots
Copy Set in the "⋯" menu of a Bard set:
The Paste Set button in the toolbar of another entry:
The pasted set below the cursor, with its images:
Pasting into a Bard field that does not have that set shows a message, and nothing is pasted:
Requirements
Statamic 6.39 or newer. Older versions HTML-escape the values of a pasted set (<b> becomes <b>).
Installation
composer require concept7/statamic-bard-set-clipboard
The control panel script is published to public/vendor/statamic-bard-set-clipboard on install. Nothing to configure.
How it works
- Copy Set writes the set to the system clipboard in Bard's own
<bard-set>format, and keeps a copy with the set's meta inlocalStorage. - Paste Set pastes that copy through ProseMirror's
pasteHTML(), so it runs the same code as a keyboard paste. - Statamic's own Cmd/Ctrl+C also keeps the meta of the copied sets in
localStorage. When both copies hold the same set, the newest one is used. - A small ProseMirror plugin runs before Statamic's paste handler. It adds the copied set's meta to the target field, waits one tick for it to land, and then hands the paste back to Statamic.
Limitations
- The Paste Set button only pastes sets copied on the same control panel domain (
localStorage). - Cmd/Ctrl+V uses the system clipboard, so it also pastes a set copied on another site. That set has no images or other previews there, because its meta stays in the other site's
localStorage. The assets and entries it refers to must exist on that site. - Browsers only let a page write to the system clipboard over HTTPS or on
localhost. On a control panel served over plain HTTP, Copy Set says so, and only the Paste Set button pastes the set. - With
toolbar_mode: floatingthe toolbar only appears when text is selected, so the button is easier to reach with a fixed toolbar. - The "Add Set" menu has no extension point, so Paste is a toolbar button instead of an item in that menu.
Statamic internals this relies on
Check these after a Statamic upgrade:
- the
bard-fieldtype-setfield action binding, and itsvaluesbeing the set node's ownattrs.valuesbehind a Vue proxy (unwrapped withwindow.Vue.toRaw()); options.bardon thesetTiptap extension;meta.existing,updateMeta()andsetConfigson the Bard fieldtype;- the
<bard-set>clipboard format and Bard'ssetPastedTransformerpaste handler.
Test path
- Open an entry with a Bard field that has sets. Open a set's "⋯" menu and choose Copy Set.
- Click in the same Bard field and press the Paste Set button: a copy appears below the cursor.
- Open another entry with the same set, click in its Bard field and press Cmd/Ctrl+V. The set appears with its images.
- Paste into a Bard field without that set: a "This set is not available in this field" message appears and nothing is pasted.
License
MIT. See LICENSE.md.





