!MMqDFaFUehZZVwknKE:matrix.org

Draftail

51 Members
A configurable rich text editor built with Draft.js https://www.draftail.org/21 Servers

Load older messages


SenderMessageTime
23 Aug 2019
@_slack_wagtailcms_UB1CW1P53:matrix.orgKalobTaulien changed their profile picture.17:22:24
25 Aug 2019
@faabler:matrix.org@faabler:matrix.org joined the room.04:21:09
@faabler:matrix.org@faabler:matrix.org left the room.04:21:18
@_slack_wagtailcms_U1HDLHL9M:matrix.orgcoenvanderkamp changed their profile picture.09:02:29
26 Aug 2019
@_slack_wagtailcms_UMQ2MVBEJ:matrix.orgMartin Kimmig joined the room.06:58:28
@_slack_wagtailcms_UMQ2MVBEJ:matrix.orgMartin Kimmig Hello together, We are trying to support fontawesomes Icons for the RichtextEditor(Draftail). So if an editor enters for example "fa-lightbulb" as content, the output will be the lightbulb-Icon on the content page. This works with following code plus Javascript-manipulation. hooks.register('register_rich_text_features') def register_mark_feature(features): feature_name = 'fontawesome_icon' type_ = 'MARK' tag = 'i' # configure how Draftail handles the feature in its toolbar. control = { 'type': type_, 'label': 'FontAwesome', 'description': 'Mark as FontAwesome Icon', 'style': {'background': 'lightblue'}, } ... # configure the content transform from the DB to the editor and back. db_conversion = { 'from_database_format': { 'i[class="rtfa fa"]': InlineStyleElementHandler(type_) }, 'to_database_format': { 'style_map': {type_: 'i class="rtfa fa"'} }, } ... JS-Manipulation: window.onload = function () { // get all elements that were marked as font awesome icons in richtext let richtTextFontAwesomeIcons = document.querySelectorAll(".rtfa"); // make them display the icon richtTextFontAwesomeIcons.forEach(rtfa => { rtfa.classList.add(rtfa.textContent); rtfa.textContent = ''; }); }; A prettier solution would be to directly manipulate the input string inside the register_mark_feature method. Do anybody of you know, whether there is a way to access the input string to use it in db_conversion? Thank you in advance for any help! 06:58:29
27 Aug 2019
@_slack_wagtailcms_U9BPTUQKT:matrix.orgRyan Verner changed their profile picture.05:21:23
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud changed their profile picture.08:55:44
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_UMQ2MVBEJ:matrix.org
Hello together, We are trying to support fontawesomes Icons for the RichtextEditor(Draftail). So if an editor enters for example "fa-lightbulb" as content, the output will be the lightbulb-Icon on the content page. This works with following code plus Javascript-manipulation. hooks.register('register_rich_text_features') def register_mark_feature(features): feature_name = 'fontawesome_icon' type_ = 'MARK' tag = 'i' # configure how Draftail handles the feature in its toolbar. control = { 'type': type_, 'label': 'FontAwesome', 'description': 'Mark as FontAwesome Icon', 'style': {'background': 'lightblue'}, } ... # configure the content transform from the DB to the editor and back. db_conversion = { 'from_database_format': { 'i[class="rtfa fa"]': InlineStyleElementHandler(type_) }, 'to_database_format': { 'style_map': {type_: 'i class="rtfa fa"'} }, } ... JS-Manipulation: window.onload = function () { // get all elements that were marked as font awesome icons in richtext let richtTextFontAwesomeIcons = document.querySelectorAll(".rtfa"); // make them display the icon richtTextFontAwesomeIcons.forEach(rtfa => { rtfa.classList.add(rtfa.textContent); rtfa.textContent = ''; }); }; A prettier solution would be to directly manipulate the input string inside the register_mark_feature method. Do anybody of you know, whether there is a way to access the input string to use it in db_conversion? Thank you in advance for any help!
I think you should be able to access the string by passing a function in style_map for type_:
'to_database_format': {
           'style_map': {type_: convert_icon_to_html}
       }
09:53:08
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_U0ME9SGR1:matrix.org
I think you should be able to access the string by passing a function in style_map for type_:
'to_database_format': {
           'style_map': {type_: convert_icon_to_html}
       }
then this function would be defined as:
from draftjs_exporter.dom import DOM

def convert_icon_to_html(props):
    text = props['children']
    icon_name = text

    return DOM.create_element('i', {
        'class': 'rtfa fa %s' % icon_name,
    })
09:55:49
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_U0ME9SGR1:matrix.org
then this function would be defined as:
from draftjs_exporter.dom import DOM

def convert_icon_to_html(props):
    text = props['children']
    icon_name = text

    return DOM.create_element('i', {
        'class': 'rtfa fa %s' % icon_name,
    })
I haven’t tried the code though
09:55:56
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_UFCCF5RND:matrix.org
image.png
I don’t think it’s possible unfortunately. There might be variations in markup that are close, but with the current implementation of list items this would make "Here’s a third item" behave as if it was the first item in a new ordered list
12:59:01
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_U9DQ4PP9R:matrix.org
Thibaud - I’m integrating draftail into an application. The application is wagtail, but I’m putting this into the non-wagtail, react part. I’m getting this error when I ‘unmount’ a component. Might you have a suggestion? > Warning: Can’t perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. in CommentEditor (created by CommentEditForm) in div (created by CommentEditForm) in form (created by CommentEditForm) in CommentEditForm (created by CommentItem) The error happens when the editor calls ‘save’ and my handler tries to update state, as in useState hook
I’ve seen this before as well
13:16:55
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_U0ME9SGR1:matrix.org
I’ve seen this before as well
I think this is exactly what you described, and probably a bug in Draftail – it should stop trying to call the "save" handler once unmounted
13:18:32
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_U0ME9SGR1:matrix.org
I think this is exactly what you described, and probably a bug in Draftail – it should stop trying to call the "save" handler once unmounted
https://github.com/springload/draftail/issues/208
14:01:46
28 Aug 2019
@_slack_wagtailcms_UBVEB3T0T:matrix.orgHanz van Aardt changed their profile picture.01:26:09
29 Aug 2019
@_slack_wagtailcms_U6VSCTBH6:matrix.orgscotchester changed their profile picture.17:57:33
30 Aug 2019
@_slack_wagtailcms_UMQ2MVBEJ:matrix.orgMartin Kimmig
In reply to@_slack_wagtailcms_U0ME9SGR1:matrix.org
I haven’t tried the code though
Hi Thibaud. I just tested it - and it seems to work 🙂 Thank you very very much! I highly appreciate your help! Have a nice weekend!
07:36:56
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_UMQ2MVBEJ:matrix.org
Hi Thibaud. I just tested it - and it seems to work 🙂 Thank you very very much! I highly appreciate your help! Have a nice weekend!
Sweet :) You too
09:19:36
2 Sep 2019
@_slack_wagtailcms_UFCCF5RND:matrix.orgJason Dilworth
In reply to@_slack_wagtailcms_U0ME9SGR1:matrix.org
I don’t think it’s possible unfortunately. There might be variations in markup that are close, but with the current implementation of list items this would make "Here’s a third item" behave as if it was the first item in a new ordered list
Ah that’s a real shame, I’m used to using some Markdown and having it ‘just work’ for want of a better phrase. I will ask the editors to just choose one type of list for now, thanks for the answer.
15:46:16
@_slack_wagtailcms_UFCCF5RND:matrix.orgJason Dilworth
In reply to@_slack_wagtailcms_UFCCF5RND:matrix.org
Ah that’s a real shame, I’m used to using some Markdown and having it ‘just work’ for want of a better phrase. I will ask the editors to just choose one type of list for now, thanks for the answer.
(edited) Ah that’s ... => Thibaud Ah that’s ...
15:46:31
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_UFCCF5RND:matrix.org
Thibaud Ah that’s a real shame, I’m used to using some Markdown and having it ‘just work’ for want of a better phrase. I will ask the editors to just choose one type of list for now, thanks for the answer.
I’ll check whether it would be possible to implement this but can’t promise anything
20:06:23
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud
In reply to@_slack_wagtailcms_U0ME9SGR1:matrix.org
I’ll check whether it would be possible to implement this but can’t promise anything
I see someone has just filed an issue for this, are they working with you or is it just a coincidence? https://github.com/springload/draftail/issues/209
20:06:53
5 Sep 2019
@_slack_wagtailcms_U9DQ4PP9R:matrix.orgsharpertool
In reply to@_slack_wagtailcms_U0ME9SGR1:matrix.org
https://github.com/springload/draftail/issues/208
Thanks Thibaud
22:45:46
6 Sep 2019
@_slack_wagtailcms_UFCCF5RND:matrix.orgJason Dilworth
In reply to@_slack_wagtailcms_U0ME9SGR1:matrix.org
I see someone has just filed an issue for this, are they working with you or is it just a coincidence? https://github.com/springload/draftail/issues/209
Just coincidence!
10:02:13
@_slack_wagtailcms_UFCCF5RND:matrix.orgJason Dilworth This might not be the place to ask, and please let me know if that’s the case, but does anyone know of a neat way to link to a RoutablePage within the editor? 10:05:30
@_slack_wagtailcms_U0ME9SGR1:matrix.orgThibaud generally I don’t think RoutablePage URLs are exposed anywhere in the Wagtail UI, including the editor 14:51:12
@_slack_wagtailcms_UB1CW1P53:matrix.orgKalobTaulien Sounds accurate. Although I wonder if that'd be a good idea to expose those urls in the page chooser modal? Got me thinking now haha 18:03:32
9 Sep 2019
@_slack_wagtailcms_U0L1Z4JMC:matrix.orgtom changed their profile picture.11:39:32
@_slack_wagtailcms_U9DQ4PP9R:matrix.orgsharpertool Thibaud - is this something you recognize? > const initialContent = { entityMap: {}, blocks: [] } > const initialEditorState = createEditorStateFromRaw(initialContent) I get an error on the 2nd line: “TypeError: cannot read property ‘getKey’ of undefined” This is nearly a cut-paste from your docs, so not sure what I’m missing. 16:16:42

Show newer messages


Back to Room ListRoom Version: 1