Skip to main content

Wagtail anchors set

Project description

Wagtail set

PyPI PyPI - Python Version PyPI - License Lines of code PyPI - Downloads GitHub contributors

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.

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

wagtailset-1.1.4.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtailset-1.1.4-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

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

Hashes for wagtailset-1.1.4.tar.gz
Algorithm Hash digest
SHA256 c22a3989b235fbc53971a9621e1d33f068a6549c0ef93074c105e5aca71e29cc
MD5 608260cf338ae0d02b3d89d832530410
BLAKE2b-256 8a895381d1f4cad3e97d932946f519d9640459a35d66fd45792fcfe0ec082af6

See more details on using hashes here.

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

Hashes for wagtailset-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fe6a360d1ccfd4d743a038acee8781a56a1d4519c56d66a9e11494b0e88dceb6
MD5 28dcb8e4040cdaa4cecaef41a130b876
BLAKE2b-256 22dd27b2d421854ad8721f0d6fba4c5f39990f60422ad876abcb45a0bc0d0cf3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page