from __future__ import annotations

from django.apps import AppConfig


class Editor101Config(AppConfig):
    name = "editor101"
    verbose_name = "101 Editor"

    def ready(self) -> None:
        # Register RichTextField in Django admin's formfield defaults so that
        # AdminTextareaWidget (which matches TextField in the MRO) does not
        # replace our widget. RichTextField is more specific and must come first.
        from django.contrib.admin.options import FORMFIELD_FOR_DBFIELD_DEFAULTS
        from .fields import RichTextField
        from .widgets import RichTextWidget

        FORMFIELD_FOR_DBFIELD_DEFAULTS[RichTextField] = {"widget": RichTextWidget}
