Open ewartmouton opened 1 month ago
For anybody finding this. I did manage to insert the editor into my admin form but wasn't able to configure it to use paid features like ExportPdf which to be honest is the only reason I need CKEditor instead of more well documented options like tinyMCE. My imports in the forms.modelAdmin form:
from django.templatetags.static import static
class Media:
js = (
static('myapp/js/ckeditor-init.js'),
format_html(
'<script type="importmap"> \
{{ \
"imports": {{ \
"ckeditor5": "https://cdn.ckeditor.com/ckeditor5/43.0.0/ckeditor5.js", \
"ckeditor5/": "https://cdn.ckeditor.com/ckeditor5/43.0.0/", \
"ckeditor5-premium-features": "https://cdn.ckeditor.com/ckeditor5-premium-features/43.0.0/ckeditor5-premium-features.js", \
"ckeditor5-premium-features/": "https://cdn.ckeditor.com/ckeditor5-premium-features/43.0.0/" \
}} \
}} \
</script>'
),
format_html('<script type="module" src="{}"></script>', static('myapp/js/ckeditor-init.js'))
)
css = {
'all': (
'https://cdn.ckeditor.com/ckeditor5/43.0.0/ckeditor5.css',
'https://cdn.ckeditor.com/ckeditor5-premium-features/43.0.0/ckeditor5-premium-features.css',
),
}
The only other change is the ckeditor-init.js file in static which was generated by https://ckeditor.com/ckeditor-5/builder/ and modified to replace the relevant django admin form fields with ckeditor
@ewartmouton This is currently not supported but adding it should not be too complicated (especially once we upgrade to ckeditor 42.x)
Is it possible to use premium features like export to PDF? https://ckeditor.com/docs/ckeditor5/latest/features/converters/export-pdf.html#installation where do you specify API details like token URL etc