Set of Wagtail blocks, utils and helpers
Project description
Wagtailset
Set of Wagtail blocks, utils and helpers.
Installation
Install using pip
:
pip install wagtailset
Blocks
Wagtail Draftail Anchors
Adds the ability to add and edit anchors in the Draftail rich text editor, as well as automatically adding (slug-form) anchor ids to all headings with possibility to changes heading ids. Inspired by wagtail_draftail_anchors with some improvements like possibility to edit previous anchor id and headings' ids.
Instalation
Add 'wagtailset.draftail_anchors'
to INSTALLED_APPS
below wagtail.admin
.
Add 'anchor-identifier'
to the features of any rich text field where you have overridden the default feature list.
Note: 'anchor-identifier' must be added before any heading('h1',...,'h6') feature and also before 'link' feature:
body = RichTextField(features=['anchor-identifier', 'h2', 'h3', 'bold', 'italic', 'link'])
Configuration
Rendered representation of anchors
By default, anchor-identifier
rich text entities will be rendered as HTML anchor
elements, e.g.:
<a href="#my-element" id="my-element" data-id="my-element">My element</a>
This package provides an alternative renderer that renders anchor-identifier
entities as HTML span
elements, e.g.:
<span id="my-element">My element</span>
The desired renderer can be specified using the DRAFTAIL_ANCHORS_RENDERER
setting. To use the span
renderer, configure your application as follows:
DRAFTAIL_ANCHORS_RENDERER = "wagtail_draftail_anchors.rich_text.render_span"
It is possible to define your own renderer. It should be a callable that takes a dict
of attributes, and returns a string containing the opening tag of the HTML element that represents the anchor target. The dict
passed to the renderer, for an anchor with an identifier of "my-anchor"
, would look like the following:
{"data-id": "my-anchor", "href": "#my-anchor", "id": "my-anchor", "linktype": "my-anchor"}
If you define your own renderer, you should set the value of DRAFTAIL_ANCHORS_RENDERER
to your custom renderer's import path.
See render_span
and render_a
in wagtail_draftail_anchors.rich_text
for examples.
Project details
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 wagtailset-0.0.1.tar.gz
.
File metadata
- Download URL: wagtailset-0.0.1.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fb5ba84ff6e04882ee84dbeb4c9b5456db7bee9bcc86a76755f0a3e199879ea |
|
MD5 | bbec667f911aad5b34379004a6437445 |
|
BLAKE2b-256 | 3ea1889b021fc2132b312021eff9611c2d513d11757a6ced2bdb351721fad908 |
File details
Details for the file wagtailset-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: wagtailset-0.0.1-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b344f192d41bd5554c5086349a12059f56f821d3d0f160c63fa3d72904cf2d3c |
|
MD5 | 25473bb9d5e6af1f0112f072af0dcd02 |
|
BLAKE2b-256 | 41e19150ebd28fdb8492710df1c6c2a99d17276bf6fc5b488f924eb7263077e2 |