Wagtail anchors set
Project description
Wagtail set
Wagtail anchors set.
Installation
Install using pip:
pip install wagtailset
Table of Contents
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'])
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>
Configuration
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 = "wagtailset.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 wagtailset.draftail_anchors.rich_text for examples.
Wagtail Draftail Anchored Internal Links
Adds the ability to add (and edit) anchors to the internal links in the Draftail rich text editor.
Instalation
Installed by default. No extra configuration needed.
How it works
Add anchor to the internal link:
Edit anchor of the internal link:
Rendered representation of anchors
By default, link rich text entities will be rendered as HTML with anchor in the end if it is set, e.g.:
Database representation:
<a hash="header-1" id="3" linktype="page">bla</a>
HTML representation:
<a href="/page3/#header-1">bla</a>
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
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 wagtailset-1.1.4.tar.gz.
File metadata
- Download URL: wagtailset-1.1.4.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c22a3989b235fbc53971a9621e1d33f068a6549c0ef93074c105e5aca71e29cc
|
|
| MD5 |
608260cf338ae0d02b3d89d832530410
|
|
| BLAKE2b-256 |
8a895381d1f4cad3e97d932946f519d9640459a35d66fd45792fcfe0ec082af6
|
File details
Details for the file wagtailset-1.1.4-py3-none-any.whl.
File metadata
- Download URL: wagtailset-1.1.4-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe6a360d1ccfd4d743a038acee8781a56a1d4519c56d66a9e11494b0e88dceb6
|
|
| MD5 |
28dcb8e4040cdaa4cecaef41a130b876
|
|
| BLAKE2b-256 |
22dd27b2d421854ad8721f0d6fba4c5f39990f60422ad876abcb45a0bc0d0cf3
|