django-machina icon indicating copy to clipboard operation
django-machina copied to clipboard

Different editor not working with machina

Open snehlata08 opened this issue 3 years ago • 2 comments

I replaced the markdown editor of machina with ckeditor using ckeditor javascript file. The content posted with that is not proper. Its removing all the html tags from the final output. Image upload also not working. Can anyone tell me the correct way to implement ckeditor with machina. This is what the content that i post. MicrosoftTeams-image (2) And this is how it appears.
MicrosoftTeams-image (3)

snehlata08 avatar Nov 08 '21 12:11 snehlata08

Did you follow this recipe? https://django-machina.readthedocs.io/en/stable/customization/recipes/using_another_markup_language.html

I used the Quill editor, and had to use these two settings and this function: MACHINA_MARKUP_LANGUAGE = ('xxx.views.utils.quill_html', {'safe_mode': True}) MACHINA_MARKUP_WIDGET = 'django_quill.widgets.QuillWidget'

def quill_html(json, safe_mode=True):
    if "delta" in json:
        html = Quill(json).html
        log.info("Rendering quill_html with json: %s = %s", json, html)
        return html
    else:
        return json

Not entirely sure how safe_mode is used, but it looks like it's just passed to markdown2 to handle in the default MACHINA_MARKUP_LANGUAGE here: https://github.com/ellmetha/django-machina/blob/main/machina/core/markdown.py#L6

vaughnd avatar Jul 04 '22 12:07 vaughnd

Add this to your project settings file

MACHINA_MARKUP_LANGUAGE = None
MACHINA_MARKUP_WIDGET = 'ckeditor.widgets.CKEditorWidget'

Also, Add CKEditor URL include to your project's urls.py file:

path('ckeditor/', include('ckeditor_uploader.urls')),

josylad avatar Oct 30 '22 19:10 josylad