Skip to content

Missing id for heading tag using richtext toolbar. #18

@marekndt04

Description

@marekndt04

Description:

In our project we have a model with "content" field built using StreamField. The field uses few different types of blocks. One of them is just RichTextBlock where we have enabled anchors using anchor-identifier feature from this library.

We found a bug that whenever we modify a piece of text to be a heading, the id value is not added to the html data. The process is shown below:

  1. We add a simple text with a part meant to be a heading (screenshot # 1)
heading issue - 1 2. We select this part and use the toolbar to convert it into a heading (screenshot # 2) heading issue - 2
  1. Save or publish the page model
  2. The data stored in the database looks like this (no id)
<h3 data-block-key=\"1ga2c\">I&#x27;m a piece of text meant to be a heading</h3><p data-block-key=\"eqk0d\"></p><p data-block-key=\"3liop\">I&#x27;m just text below</p>
  1. Re-saving/publishing adds an empty id value:
<h3 data-block-key=\"4jzq5\" id=\"\">I&#x27;m a piece of text meant to be a heading</h3><p data-block-key=\"eqk0d\"></p><p data-block-key=\"3liop\">I&#x27;m just text below</p>
  1. To fix the data we can edit any part of the text inside the block, so adding new text or just deleting and adding a character will help.

Using any other option to create a heading works as expected (using / with the features prompt, or choosing header type from the toolbar before typing any characters).

Django==4.2.6
wagtail==5.2.2
wagtail-draftail-anchors==0.6.0
Python == 3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions