question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Blacklist for Richtext elements

See original GitHub issue

I was happy to find the whitelister hook for richtext elements, but a bit disappointed that I could not blacklist elements, which is much more important for me having users copying stuff from word and who knows what… Instead of having a blacklister, it would be also ok to have an option to overwrite the original whitelist, not merge it…

In reality it seems not such a big problem, unless you copy html directly into your chrome dev tools richtext html field, but I want to make sure…

Also a way to replace html elements would be great, for example the <b> and <i> tags from hello js with <strong> and <em>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
gasmancommented, Jan 26, 2018

Yep, I think this is fully covered by rich text features, as of #4079.

1reaction
gasmancommented, Jan 26, 2018

It looks like it should be possible to ‘blacklist’ an element with the following code (untested):

def reject_tag(tag):
    tag.unwrap()

@hooks.register('construct_whitelister_element_rules')
def whitelister_element_rules():
    return {
        'h1': reject_tag
    }

You could probably use something similar to replace the tag with another one (although, if I recall correctly, the HTML spec specifically advises that HTML authoring tools shouldn’t replace <i> with <em> unless they’re absolutely certain that the author intended it as emphasis, rather than, say, a book title.)

I agree we ought to make this easier, though. (I’m surprised that the requirement to remove elements from the whitelist hasn’t come up before - I guess most people aren’t really on board with the Wagtail philosophy of taking flexibility away from editors 😃 ) A couple of easy ways to do that:

  1. provide the above reject_tag method in wagtail.wagtailcore.whitelist, alongside allow_without_attributes
  2. in https://github.com/torchbox/wagtail/blob/ba807e5f45812e85bf83b49bf04d2c796ef63cda/wagtail/wagtailcore/whitelist.py#L136-L144, treat a None or False rule the same way as a KeyError (so that the above code could be simply return {'h1': False}).
Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request: help prevent name clashes - Concrete CMS
There should be a maintained blacklist for unfavorable blocknames to prevent people from generating not fully functional blocks. :) PS: I know I...
Read more >
Rich text element overview - Webflow University
A rich text element (RTE) is the perfect element for creating long-form content like blog posts, about pages, biographies — you name it....
Read more >
[CONFSERVER-21179] Allow Opera users to edit in Rich Text mode ...
Quick summary of change: we currently blacklist Opera; I've switched it to allow instead. I don't think it's worth version sniffing, we can...
Read more >
Feature Request: HTML or Rich Text Editor for Signatures
Freshdesk has a rich text editor for creating signatures. I would like to see this in the brands section for creating a brand...
Read more >
Rich-text editing (WYSIWYG) | Silverstripe CMS Documentation
On top of the base functionality, we use our own insertion dialogs to ... we use shortcodes to store information about inserted images...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found