o
    ÌÉhC  ã                   @   s   d dl mZ G dd„ dƒZdS )é    )Úhooksc                   @   st   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zedd„ ƒZdS )ÚFeatureRegistryaW  
    A central store of information about optional features that can be enabled in rich text
    editors by passing a ``features`` list to the RichTextField, such as how to
    whitelist / convert HTML tags, and how to enable the feature on various editors.

    This information may come from diverse sources - for example, wagtailimages might define
    an 'images' feature and a Draftail plugin for it, while a third-party module might
    define a TinyMCE plugin for the same feature. The information is therefore collected into
    this registry via the 'register_rich_text_features' hook.
    c                 C   s(   d| _ i | _g | _i | _i | _i | _d S )NF)Úhas_scanned_for_featuresÚplugins_by_editorÚdefault_featuresÚ
link_typesÚembed_typesÚconverter_rules_by_converter©Úself© r   úb/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/rich_text/feature_registry.pyÚ__init__   s   
zFeatureRegistry.__init__c                 C   ó   | j s|  ¡  | jS ©N)r   Ú_scan_for_featuresr   r
   r   r   r   Úget_default_features0   s   z$FeatureRegistry.get_default_featuresc                 C   s"   t  d¡D ]}|| ƒ qd| _d S )NÚregister_rich_text_featuresT)r   Ú	get_hooksr   )r   Úfnr   r   r   r   6   s   

z"FeatureRegistry._scan_for_featuresc                 C   ó   | j  |i ¡}|||< d S r   )r   Ú
setdefault)r   Úeditor_nameÚfeature_nameÚpluginÚpluginsr   r   r   Úregister_editor_plugin;   ó   z&FeatureRegistry.register_editor_pluginc                 C   ó4   | j s|  ¡  z| j| | W S  ty   Y d S w r   )r   r   r   ÚKeyError)r   r   r   r   r   r   Úget_editor_plugin?   ó   ÿz!FeatureRegistry.get_editor_pluginc                 C   ó   || j |j< d S r   )r   Ú
identifier©r   Úhandlerr   r   r   Úregister_link_typeH   ó   z"FeatureRegistry.register_link_typec                 C   r   r   )r   r   r   r
   r   r   r   Úget_link_typesK   ó   zFeatureRegistry.get_link_typesc                 C   r"   r   )r   r#   r$   r   r   r   Úregister_embed_typeP   r'   z#FeatureRegistry.register_embed_typec                 C   r   r   )r   r   r   r
   r   r   r   Úget_embed_typesS   r)   zFeatureRegistry.get_embed_typesc                 C   r   r   )r	   r   )r   Úconverter_namer   ÚruleÚrulesr   r   r   Úregister_converter_ruleX   r   z'FeatureRegistry.register_converter_rulec                 C   r   r   )r   r   r	   r   )r   r,   r   r   r   r   Úget_converter_rule\   r!   z"FeatureRegistry.get_converter_rulec                 C   s   t dtf| t|ƒdœƒS )z<Supports legacy registering of entity handlers as functions.Ú!EntityHandlerRegisteredAsFunction)r#   Úexpand_db_attributes)ÚtypeÚobjectÚstaticmethod)r#   r   r   r   r   Úfunction_as_entity_handlere   s   þýz*FeatureRegistry.function_as_entity_handlerN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r    r&   r(   r*   r+   r/   r0   r5   r6   r   r   r   r   r      s     		r   N)Úwagtailr   r   r   r   r   r   Ú<module>   s    