A Wagtail StreamField block powered by TinyMCE and its table plugin
Project description
A table block for Wagtail StreamField powered by TinyMCE
Links
TinyTableBlock is a StreamField block powered by TinyMCE and its table plugin.
Wagtail provides TableBlock
and
TypedTableBlock
which are good options if you want basic tables with some cell merging capability or StreamField-powered cell, but they have their limitations:
TableBlock
is using an old version of handsontable. It doesn't support multi-row header, column headers, nor pasting complex tables.TypedTableBlock
gets complex quickly depending on the types of blocks you add, and pasting is limited to single cells.
Wagtail TinyTableBlock (this package) provides the TinyMCE table editor which has improved copy/paste, multi-row and column headers, external link support and more. It does not currently support the Wagtail rich text data format for page and document links, nor does it support embedding images.
Installation
In your project's Django settings, add the app your INSTALLED_APPS
list (at the end is fine):
INSTALLED_APPS = [
# ...
"wagtail_tinytableblock",
]
Add the TinyTableBlock
model to your StreamField definition. For example
# yourapp/models.py
from wagtail.fields import StreamField
from wagtail.models import Page
from wagtail_tinytableblock import TinyTableBlock
class WonderfulPage(Page):
body = StreamField([
# ...
("table", TinyTableBlock()),
])
Finally, run Django's makemigrations
and migrate
commands to apply any model field changes to your project
$ python manage.py makemigrations
$ python manage.py migrate
Configuration
TinyTableBlock
accepts an allow_links
keyword argument which allows enabling the TinyMCE link
plugin. Note: this currently only works with external URLs.
from wagtail.blocks import StreamBlock
from wagtail_tinytableblock.blocks import TinyTableBlock
class ContentBlocks(StreamBlock):
table_block = TinyTableBlock(allow_links=True)
By default, we disable the TinyMCE contextual menu to allow the browser native one. If you want to use TinyMCE one,
pass enable_context_menu=True
:
from wagtail.blocks import StreamBlock
from wagtail_tinytableblock.blocks import TinyTableBlock
class ContentBlocks(StreamBlock):
table_block = TinyTableBlock(enable_context_menu=True)
Data representation
The table data is saved as a JSON-serialized dictionary with the following keys:
{
"headers": [],
"rows": [],
"html": the_sanitised_html
}
headers
/ rows
are lists of lists with cell values. Each cell is a dictionary with the following keys
key | value notes |
---|---|
value |
The cell value |
type |
"td" or "th" |
rowspan |
if set |
colspan |
if set |
scope |
if set |
align |
if set |
Contributing
All contributions are welcome! See CONTRIBUTING.md
Supported versions:
- Python 3.12, 3.13
- Django 4.2, 5.1
- Wagtail 6.3 (LTS), 6.4
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
File details
Details for the file wagtail_tinytableblock-0.3.4.tar.gz
.
File metadata
- Download URL: wagtail_tinytableblock-0.3.4.tar.gz
- Upload date:
- Size: 478.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8d0f68bf935e146cf20e75a7af89b262b8fd473fd365606252201b283d94f7c4
|
|
MD5 |
e27c66d5c44e1bf2cc4e8b8c12dfbed5
|
|
BLAKE2b-256 |
87aafcb6abfeaf65e65d45c0f4d9c4ad4b0023322bd3d8409a096ae1aba83c31
|
Provenance
The following attestation bundles were made for wagtail_tinytableblock-0.3.4.tar.gz
:
Publisher:
publish.yml
on torchbox/wagtail-tinytableblock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
wagtail_tinytableblock-0.3.4.tar.gz
-
Subject digest:
8d0f68bf935e146cf20e75a7af89b262b8fd473fd365606252201b283d94f7c4
- Sigstore transparency entry: 195012218
- Sigstore integration time:
-
Permalink:
torchbox/wagtail-tinytableblock@8e6668d7cfa677bfe3d11f0b61750232a9e6ed89
-
Branch / Tag:
refs/tags/v0.3.4
- Owner: https://github.com/torchbox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish.yml@8e6668d7cfa677bfe3d11f0b61750232a9e6ed89
-
Trigger Event:
release
-
Statement type:
File details
Details for the file wagtail_tinytableblock-0.3.4-py3-none-any.whl
.
File metadata
- Download URL: wagtail_tinytableblock-0.3.4-py3-none-any.whl
- Upload date:
- Size: 506.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
3b38fd59689a53ace5afbf2cdfedc4787b769727ebf8e9ffa1f339fcfd4a6485
|
|
MD5 |
2bf8199a9cab7d6ea94d5662af76f370
|
|
BLAKE2b-256 |
c50a58c91f231ade68e52a758175c7b45b668cd6a2d564e4959efb5871d886e1
|
Provenance
The following attestation bundles were made for wagtail_tinytableblock-0.3.4-py3-none-any.whl
:
Publisher:
publish.yml
on torchbox/wagtail-tinytableblock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
wagtail_tinytableblock-0.3.4-py3-none-any.whl
-
Subject digest:
3b38fd59689a53ace5afbf2cdfedc4787b769727ebf8e9ffa1f339fcfd4a6485
- Sigstore transparency entry: 195012220
- Sigstore integration time:
-
Permalink:
torchbox/wagtail-tinytableblock@8e6668d7cfa677bfe3d11f0b61750232a9e6ed89
-
Branch / Tag:
refs/tags/v0.3.4
- Owner: https://github.com/torchbox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish.yml@8e6668d7cfa677bfe3d11f0b61750232a9e6ed89
-
Trigger Event:
release
-
Statement type: