diff --git a/wagtail/admin/rich_text/converters/html_to_contentstate.py b/wagtail/admin/rich_text/converters/html_to_contentstate.py index f41edf4b24..67fe38afe3 100644 --- a/wagtail/admin/rich_text/converters/html_to_contentstate.py +++ b/wagtail/admin/rich_text/converters/html_to_contentstate.py @@ -206,7 +206,12 @@ class PageLinkElementHandler(LinkElementHandler): try: page = Page.objects.get(id=attrs['id']).specific except Page.DoesNotExist: - return {} + # retain ID so that it's still identified as a page link (albeit a broken one) + return { + 'id': int(attrs['id']), + 'url': None, + 'parentId': None + } parent_page = page.get_parent() diff --git a/wagtail/admin/tests/test_contentstate.py b/wagtail/admin/tests/test_contentstate.py index 056aeff017..dbe9f24e06 100644 --- a/wagtail/admin/tests/test_contentstate.py +++ b/wagtail/admin/tests/test_contentstate.py @@ -326,7 +326,9 @@ class TestHtmlToContentState(TestCase): 'entityMap': { '0': { 'mutability': 'MUTABLE', 'type': 'LINK', - 'data': {} + 'data': { + 'id': 9999, 'url': None, 'parentId': None, + } } }, 'blocks': [