Customize document link rendering from RichTextBlock

129 Views Asked by At

I'm working in modernize a old website and i saw that the use buttons for redering document's URLs.
I saw that we can import documents from draftail but i'm not sure how can we modify document's rendering to show a button instead a link as this: enter image description here

Can anyone help me?

1

There are 1 best solutions below

0
gasman On

Buttons do not belong inside rich text content. A button is not text - it is a design element in its own right, and so you should define a specific StreamField block for that purpose.

from wagtail.core import blocks
from wagtail.documents.blocks import DocumentChooserBlock

class DocumentLinkButton(blocks.StructBlock):
    document = DocumentChooserBlock()
    button_text = blocks.CharBlock