U
    {h                     @   sH   d Z ddlmZ ddlmZ ddlmZ G dd dZedegZ	dS )	z4
editor-html conversion for contenteditable editors
    )editor_html)get_image_model)get_image_formatc                   @   s(   e Zd ZdZedd Zedd ZdS )ImageEmbedHandlera  
    ImageEmbedHandler will be invoked whenever we encounter an element in HTML content
    with an attribute of data-embedtype="image". The resulting element in the database
    representation will be:
    <embed embedtype="image" id="42" format="thumb" alt="some custom alt text">
    c                 C   s   | d | d | d dS )z
        Given a tag that we've identified as an image embed (because it has a
        data-embedtype="image" attribute), return a dict of the attributes we should
        have on the resulting <embed> element.
        zdata-idzdata-formatzdata-alt)idformatalt )tagr	   r	   l/var/www/dating/data/www/fatepal.com/env/lib/python3.8/site-packages/wagtail/images/rich_text/editor_html.pyget_db_attributes   s    z#ImageEmbedHandler.get_db_attributesc                 C   sV   t  }z|jj| d d}W n |jk
r4   Y dS X t| d }||| ddS )z
        Given a dict of attributes from the <embed> tag, return the real HTML
        representation for use within the editor.
        r   )r   z<img alt="">r   r    )r   objectsgetZDoesNotExistr   Zimage_to_editor_html)attrsZImageimageZimage_formatr	   r	   r   expand_db_attributes   s    z&ImageEmbedHandler.expand_db_attributesN)__name__
__module____qualname____doc__staticmethodr   r   r	   r	   r	   r   r   	   s
   
r   r   N)
r   Z"wagtail.admin.rich_text.convertersr   Zwagtail.imagesr   Zwagtail.images.formatsr   r   ZEmbedTypeRuleZEditorHTMLImageConversionRuler	   r	   r	   r   <module>   s
   &