draftail | ๐๐ธ A configurable rich text editor built with Draft.js | Editor library
kandi X-RAY | draftail Summary
kandi X-RAY | draftail Summary
:memo::cocktail: A configurable rich text editor built with Draft.js. Check out our demos!.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Expands the current state of the editor into a compact block state .
draftail Key Features
draftail Examples and Code Snippets
from wagtail.admin.rich_text.converters.html_to_contentstate import BlockElementHandler
@hooks.register('register_rich_text_features')
def register_blockquote_feature(features):
"""
Registering the `blockquote` feature, which uses
Community Discussions
Trending Discussions on draftail
QUESTION
My editors want to have an ability to edit raw html within editor. For example, we can have simple list markup:
...ANSWER
Answered 2022-Feb-01 at 10:36Wagtail does not support raw HTML editing within the page editor out of the box intentionally. The philosophy (zen) of Wagtail is to help editors and developers 'wear the right hat' when working in Wagtail.
HTML editing is usually best provided to developers, where there is an expected knowledge of what is required for things like accessibility, security and the benefit of tooling (like git).
However, if HTML editing is a must, you will probably need to build your own editor field for that purpose or find a suitable package that works with HTML markup such as django-markupfield. Adding image/snippet/page chooser functionality however will have to be built for whatever you end up using. You may also want to look at the Wagtail markdown package either as an alternative to HTML or a starting point, it allows for a syntax of linking to pages/images.
Wagtail lets you use any kind of Django field or widget with the FieldPanel
.
Please ensure you consider all the risks when implementing this feature, such as accessible HTML (e.g. heading levels), security (disallow some tags such as script tags), malformed HTML leaking into the rendered template and of course the end user experience.
QUESTION
So basically I've added two custom features for coloring text to a RichTextBlock, and I'd like to make them so selecting one for a portion of text would automatically unselect the other color button, much like it's already the case for h tags.
I've searched for a bit but didn't find much, so I guess I could use some help, be it advice, instruction or even code.
My features go like this :
...ANSWER
Answered 2022-Jan-12 at 21:16This is possible, but it requires jumping through many hoops in Wagtail. The h1โฆh6
tags work like this out of the box because they are block-level formatting โ each block within the editor can only be of one type. Here youโre creating this RED_TEXT
formatting as inline formatting ("inline style"), which, intentionally supports multiple formats being applied to the same text.
If you want to achieve this mutually exclusive implementation anyway โ youโll need to write custom JS code to auto-magically remove the desired styles from the text when attempting to add a new style.
Here is a function that does just that. It goes through all of the characters in the userโs selection, and removes the relevant styles from them:
QUESTION
I've been using Wagtail to create a website with additional text annotations. The user flow is that there is some highlighted text in a paragraph, which when clicked shows an annotation off to one side. The expected HTML result is:
...ANSWER
Answered 2021-Apr-24 at 03:20to get What you want, easiest way is to create your own Template tags filters, create your own markdown replacements, let's say, in the rich text you assigned the link to part of your paragraph like this "Click here this is a hidden text" and then you put [ht] right before the "this is a hidden text" and a[th] right after that targeted hidden text,then in the template use self.field_name|replace:"[ht]"|replace:"[th]"
in template tag file (for example myapp/templatetags/my_richtext.py):
QUESTION
I'm trying to import posts from Wordpress to Wagtail including images.
I'm conscious about the fact that Draftail editor saves images with a dedicated tag, ex:
...ANSWER
Answered 2021-Feb-08 at 10:10I found what was causing the issue.
I was using a rendition image to fetch the id:
QUESTION
I have registered the following hooks:
...ANSWER
Answered 2021-Jan-05 at 16:14This doesn't work because p class="has-dropcap"
is not a valid HTML tag name. Injecting an attribute via the tag name might work as an unofficial hack in some places because those particular internals of Wagtail work by piecing together HTML strings, but other parts of Wagtail code (such as the Draftail editor) use the Javascript DOM API where tag names and attributes are completely distinct concepts.
I don't know if there's a workaround, but in any case, I wouldn't advise implementing dropcaps in this way. The whole point of a CMS like Wagtail is to separate content from presentation: if a user writing website content is making decisions about typography while writing it, then something has gone wrong in that process.
If your site design calls for the first paragraph of the body text to have a dropcap, then your CSS should represent that design choice, using a rule such as .body p:first
, rather than a manually-applied class name.
QUESTION
I'm running Wagtail 2.4 in Docker with a Postgres db, and getting an error when I attempt to edit a blog post in Wagtail. The initial post worked, and I can view the page fine on the site. When I go to edit the post in the Wagtail admin, it throws a 500 error: AssertionError "Unmatched tags: expected img, got p"
I initially thought that the issue was because the blog posts were initially imported from another database (old Drupal site) and the intro
and body
fields contained image tags, even though the intro should not have had any HTML markup at all. However, I removed them in the db using Navicat and the error is still occurring. Not sure what else to try, but I can confirm that not all posts are getting an error on the edit view, just the ones that were imported from Drupal. Anything newer that has been added in the Wagtail admin is fine.
The model looks like this:
...ANSWER
Answered 2020-Feb-22 at 02:23The problem is that Wagtail's parser is not tolerant of badly formed HTML, and the HTML you've imported from Drupal is badly formed (e.g., it includes unclosed tags). It's a little annoying that the Wagtail editor breaks with this because you have no way to fix the content from the editor.
What I've ended up doing in the past is fixing the bad HTML in the shell, using an HTML parser like Beautiful Soup. Something along these lines:
QUESTION
I am trying to implement a color-chooser option in wagtail RichTextBlock
so that I can select any color for my selected text.
This is my wagtail_hooks.py
file:
ANSWER
Answered 2020-Jan-21 at 20:14Could you add a charfield or charblock to your model or streamblock where you enter the hex value and in the template you read the field value and set the text color to that?
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install draftail
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page