Search by

concept7 / statamic-bard-set-clipboard

concept7

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

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-12-03 20:12 UTC

This package is auto-updated.

Last update: 2026-12-03 20:18:18 UTC


README

Bard Set Clipboard: copy and paste Bard sets between entries, with their images

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 "⋯" menu of a Gallery set with Copy Set at the top

The Paste Set button in the toolbar of another entry:

The Paste Set button in the Bard toolbar

The pasted set below the cursor, with its images:

A pasted Gallery set in another entry, still showing its three images

Pasting into a Bard field that does not have that set shows a message, and nothing is pasted:

The "This set is not available in this field" message

Requirements

Statamic 6.39 or newer. Older versions HTML-escape the values of a pasted set (<b> becomes &lt;b&gt;).

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 the set, its previews are kept, paste it in another entry

  • 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 in localStorage.
  • 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: floating the 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-set field action binding, and its values being the set node's own attrs.values behind a Vue proxy (unwrapped with window.Vue.toRaw());
  • options.bard on the set Tiptap extension;
  • meta.existing, updateMeta() and setConfigs on the Bard fieldtype;
  • the <bard-set> clipboard format and Bard's setPastedTransformer paste handler.

Test path

  1. Open an entry with a Bard field that has sets. Open a set's "⋯" menu and choose Copy Set.
  2. Click in the same Bard field and press the Paste Set button: a copy appears below the cursor.
  3. Open another entry with the same set, click in its Bard field and press Cmd/Ctrl+V. The set appears with its images.
  4. 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.