Clean up Draftail image enitity definition, use the same attrs as Hallo

pull/4136/head
Thibaud Colas 2018-01-15 14:37:07 +02:00
rodzic bafc042364
commit e5856c6f34
3 zmienionych plików z 9 dodań i 7 usunięć

Wyświetl plik

@ -10,10 +10,10 @@ class ImageSource extends ModalSource {
parseData(imageData) {
this.onConfirmAtomicBlock({
src: imageData.preview.url,
altText: imageData.alt,
id: imageData.id,
alignment: imageData.format,
src: imageData.preview.url,
alt: imageData.alt,
format: imageData.format,
});
}

Wyświetl plik

@ -342,7 +342,7 @@ class TestHtmlToContentState(TestCase):
],
'entityMap': {
'0': {
'data': {'alignment': 'left', 'altText': 'an image', 'id': '1', 'src': '/media/not-found'},
'data': {'format': 'left', 'alt': 'an image', 'id': '1', 'src': '/media/not-found'},
'mutability': 'IMMUTABLE', 'type': 'IMAGE'
}
}

Wyświetl plik

@ -81,9 +81,9 @@ def image_entity(props):
"""
return DOM.create_element('embed', {
'embedtype': 'image',
'format': props.get('alignment'),
'format': props.get('format'),
'id': props.get('id'),
'alt': props.get('altText'),
'alt': props.get('alt'),
})
@ -123,8 +123,10 @@ class ImageElementHandler(AtomicBlockEntityElementHandler):
src = ''
return Entity('IMAGE', 'IMMUTABLE', {
'id': attrs['id'],
'src': src,
'altText': attrs.get('alt'), 'id': attrs['id'], 'alignment': attrs['format']
'alt': attrs.get('alt'),
'format': attrs['format']
})