diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f8e4c99..029063b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ Changelog ~~~~~~~~~~~~~~~~~~ * Fix error when exporting empty non-required ChooserBlocks (Kalob Taulinen, Jacob Topp-Mugglestone) + * Fix handling of embeds in rich text (Kalob Taulinen, Jacob Topp-Mugglestone) * Ensure that file URLs are always absolute by falling back on BASE_URL when MEDIA_URL is local (Kalob Taulinen) diff --git a/tests/tests/test_api.py b/tests/tests/test_api.py index 16ec983..2330daa 100644 --- a/tests/tests/test_api.py +++ b/tests/tests/test_api.py @@ -134,6 +134,29 @@ def test_rich_text_with_dead_page_link(self): for model, id, uid in data['mappings'] )) + def test_rich_text_with_image_embed(self): + with open(os.path.join(FIXTURES_DIR, 'wagtail.jpg'), 'rb') as f: + image = Image.objects.create( + title="Wagtail", + file=ImageFile(f, name='wagtail.jpg') + ) + + body = '

Here is an image

' % image.pk + page = PageWithRichText(title="The cake is a lie.", body=body) + + parent_page = Page.objects.get(url_path='/home/existing-child-page/') + parent_page.add_child(instance=page) + + response = self.get(page.id) + + self.assertEqual(response.status_code, 200) + data = json.loads(response.content) + + self.assertTrue(any( + model == 'wagtailimages.image' and pk == image.pk + for model, pk, uid in data['mappings'] + )) + def test_streamfield_with_page_links(self): # Check that page links in a complex nested StreamField - with StreamBlock, StructBlock, and ListBlock - # are all picked up in mappings diff --git a/wagtail_transfer/richtext.py b/wagtail_transfer/richtext.py index 6078bc5..b6188f3 100644 --- a/wagtail_transfer/richtext.py +++ b/wagtail_transfer/richtext.py @@ -83,6 +83,6 @@ def get_reference_handler(): link_handlers = features.get_link_types() REFERENCE_HANDLER = MultiTypeRichTextReferenceHandler([ RichTextReferenceHandler(link_handlers, FIND_A_TAG, 'linktype'), - RichTextReferenceHandler(embed_handlers, FIND_EMBED_TAG, 'embed') + RichTextReferenceHandler(embed_handlers, FIND_EMBED_TAG, 'embedtype') ]) return REFERENCE_HANDLER