A Wagtail plugin to copy and paste blocks between pages
Project description
Wagtail Block Exchange
A Wagtail plugin that allows copying and pasting blocks between pages, even across different Wagtail instances.
Features
- Copy any StreamField block to a persistent clipboard
- Paste blocks into any compatible StreamField
- Works with all common Wagtail block types:
- Basic blocks (CharBlock, TextBlock, etc.)
- StructBlock, ListBlock, and StreamBlock
- RichTextBlock with preserved formatting
- ImageChooserBlock with automatic image reference resolution
- DocumentChooserBlock with document restoration
- PageChooserBlock with proper page linking
- DateTimeBlock and related date/time fields
- SnippetChooserBlock with model-aware restoration
- Block clipboard accessible from the Wagtail admin menu
- Compatible with any Wagtail project, not just FlexiblePages
- Cross-instance compatibility for sharing blocks between Wagtail sites
Installation
From PyPI
pip install wagtail-block-exchange
Manual Installation
- Clone this repository or download the source code
- Install the package in development mode:
cd wagtail-block-exchange
pip install -e .
Configuration
- Add
wagtail_block_exchangeto yourINSTALLED_APPSin your Django settings:
INSTALLED_APPS = [
# ...
'wagtail_block_exchange',
# ...
]
- Run migrations:
python manage.py migrate wagtail_block_exchange
- Collect static files:
python manage.py collectstatic
Usage
Copying blocks
- Edit any page with StreamField blocks
- Hover over a block to reveal its menu (with move, duplicate, and delete options)
- Click the "Copy to Clipboard" button in the block menu
- The block will be added to your clipboard for later use
Managing the clipboard
- Click on "Block Clipboard" in the Wagtail admin menu
- View all your copied blocks
- Delete blocks from the clipboard when no longer needed
Pasting blocks
- From the Block Clipboard page, click "Paste to Page" on any block
- Select the destination page
- The block will be added to the first compatible StreamField
- You'll be redirected to the edited page to see the result
Using the Insert Block Dialog
When adding a new block to a StreamField, you'll see a section for "Clipboard Items" below the standard block types. Click on any clipboard item to insert it at the current location.
For End Users
This package comes with pre-built JavaScript files, so users don't need to run any JavaScript build commands. Just install the package with pip and you're ready to go.
For Developers
If you're making changes to the JavaScript code, you'll need to rebuild the JavaScript files:
# Install JavaScript dependencies
npm install
# Build the JavaScript bundle
npm run build
# Run collectstatic to copy the built files
python manage.py collectstatic
Development
Frontend Development
The plugin uses modern JavaScript with ES6 modules, bundled using Webpack.
- Install frontend dependencies:
cd wagtail_block_exchange
npm install
- Start the development server:
npm run dev
- Build for production:
npm run build
Python Development
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install development dependencies:
pip install -e ".[testing]"
- Run tests:
pytest
Releasing
This package is designed to be easily installable without requiring end users to have npm or to build JavaScript files themselves. The package includes pre-built JavaScript files.
Using the Build Script
To build the package with pre-built JavaScript files, run:
python build_package.py
This script will:
- Clean up previous build directories
- Build the JavaScript files using npm (if available)
- Copy the built files to the right locations
- Build both source and wheel distributions
- Verify that the JavaScript files are included in the distributions
For more details, see the RELEASE.md file.
License
This plugin is released under the MIT License.
Credits
Developed by Rich Ross at Micro Team.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wagtail_block_exchange-0.1.0.tar.gz.
File metadata
- Download URL: wagtail_block_exchange-0.1.0.tar.gz
- Upload date:
- Size: 67.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6951b56d7fabd221d597a6d6bcf8b5cfb73d0ebfeabca597cc17bee818c1904
|
|
| MD5 |
184d8b1d4cbb8c80876dceaa78bd6faa
|
|
| BLAKE2b-256 |
b942a9ff18f562655958e66660ee06755bf8c10b10a1dfef1f871aa3f9956ac0
|
File details
Details for the file wagtail_block_exchange-0.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: wagtail_block_exchange-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b34fd94828d77963d5736e1370a20673c40145a3b73f3027c54b7b4421e0363
|
|
| MD5 |
e407634b02c3f966277c64e037531274
|
|
| BLAKE2b-256 |
f6e85ead195f90890975bf9e9006f0f9987ebf597316063262ea675283925bee
|