Noah Random
Noah Random

Reputation: 88

Link feature missing in Wagtail RichTextBlock

I am creating a Wagtail ArticlePage class in models.py. As a part of the body field in my article, which is a StreamField, I created a 'paragraph' component, which is a blocks.RichTextBlock(). When I test it in the admin console, I can create the article properly, but when I go to the paragraph section in the body and type '/' to add a component, I see there is no option to add a regular HTML link. The only available choices are Heading 2, Heading 3, Numbered list, Bulleted list, Embed and Image, but there is no option for 'link'. Without it, I can't add HTML links in the articles, which is very basic feature. How can I have the link added to the RichTextBlock paragraph?

I tried

class ArticlePage(Page):
....
body = StreamField([
    ('paragraph', blocks.RichTextBlock()),
    ('code', CodeBlock(label=('Code'))),
], use_json_field=True)

which works fine to create the article, but when I go to the Wagtail admin console for the article, to the edit a paragraph, I just see the options below and the link is not there:

enter image description here

I researched in the Wagtail documentation about RichTextField features, and I found that I can use the features parameter in the RichTextBlock, like shown below to be specific about what features I want listed.

('paragraph', blocks.RichTextBlock(features=['h2','h3','link'])),

However, it went worse. Now I can see only H2 and H3 in the options as shown below:

enter image description here

What am I missing or what am I doing wrong?

Thank you,

Upvotes: 1

Views: 129

Answers (1)

Noah Random
Noah Random

Reputation: 88

After doing some more testing, I found an alternative solution. When I highlighted some text in the paragraph, a pop-up message in the edit console came up, giving me the option to use a link. This is not the option when typing '/' in the paragraph, but still, works. It solves my problem and I put it here in case someone else finds the same situation. Below the image of the highlighted text and the pop-up message.

enter image description here

Thank you, anyway.

Upvotes: 2

Related Questions