Closed jim-acb closed 1 week ago
Thank you, this is how I ended up doing it.
# apps/core/wagtail_hooks.py
from django.templatetags.static import static
from django.utils.html import format_html
from wagtail import hooks
@hooks.register("insert_global_admin_js", order=100)
def global_admin_js():
return format_html('<script src="{}"></script>', static("js/easymde_custom.js"))
# apps/core/static/js/easymde_custom.js
window.wagtailMarkdown = window.wagtailMarkdown || {};
window.wagtailMarkdown.options = {
toolbar: ["bold", "link"],
spellChecker: false,
shortcuts: {
// Disable all shortcuts except for bold and link.
// https://github.com/Ionaru/easy-markdown-editor?tab=readme-ov-file#keyboard-shortcuts
// toggleBold: null,
// drawLink: null,
cleanBlock: null,
toggleHeadingSmaller: null,
toggleItalic: null,
toggleUnorderedList: null,
togglePreview: null,
toggleCodeBlock: null,
drawImage: null,
toggleOrderedList: null,
toggleHeadingBigger: null,
toggleSideBySide: null,
toggleFullScreen: null,
toggleHeading1: null,
toggleHeading2: null,
toggleHeading3: null,
toggleHeading4: null,
toggleHeading5: null,
toggleHeading6: null,
},
};
I am using the wagtail-markdown package with a MarkdownBlock in Wagtail’s StreamField. I would like to restrict the Markdown toolbar in the Wagtail admin interface to only allow the specific options (for example 'strong' only), disabling all other Markdown formatting options.
I attempted the following:
Despite these changes, the editor continues to display all toolbar options, and users can still see other Markdown features.
I would like to request a feature or guidance on how to limit the editor to specific Markdown formatting options.
Thank you!