plone / blocks-conversion-tool

A tool to convert HTML (as used in Plone Classic) to Blocks (as used on Volto)
7 stars 5 forks source link

Conversion of spans leads to invalid blocks and drops images #21

Closed pbauer closed 1 year ago

pbauer commented 1 year ago

Source is an empty span:

<p><span></span></p>

Result:

{'@type': 'slate',
 'plaintext': '',
 'value': [{'children': [{'children': [], 'type': 'span'}], 'type': 'p'}]}

Problem: On editing it raises Error: Cannot get the start point in the node at path [0] because it has no start text node.

Source is a span with a image

<p><span><img src='image.jpeg'></span></p>

Result (same as above):

{'@type': 'slate',
 'plaintext': '',
 'value': [{'children': [{'children': [], 'type': 'span'}], 'type': 'p'}]}

Problem: The image is dropped. On editing it again raises Error: Cannot get the start point in the node at path [0] because it has no start text node.

Source is a span with image and text

<p><span><img src='image.jpeg'>text</span></p>

Result

{'@type': 'slate',
 'plaintext': 'text',
 'value': [{'children': [{'children': [{'text': 'text'}], 'type': 'span'}], 'type': 'p'}]}

Problem: The image is dropped, the block is valid

davisagli commented 1 year ago

Similar to #20 -- thanks for the specific case

pbauer commented 1 year ago

The new results don't seem right. The images are still dropped.

All these do not return a image-block: <div><img src="image.jpeg" /></div> <span><img src="image.jpeg" /></span> <img src="image.jpeg" /> They are only created when they exits within a <p>

The changes span seems to work but I expected it to be dropped. So instead {'type': 'p', 'children': [{'text': ''}]} is now is {'type': 'p', 'children': [{'type': 'span', 'children': [{'text': ''}]}]}

ericof commented 1 year ago

Looking into it

On Sun, Mar 5, 2023, 16:08 Philip Bauer @.***> wrote:

Reopened #21 https://github.com/plone/blocks-conversion-tool/issues/21.

— Reply to this email directly, view it on GitHub https://github.com/plone/blocks-conversion-tool/issues/21#event-8668504880, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKWXRHHAQZEVPPNVB5MWTW2TQDBANCNFSM6AAAAAAVOXTKV4 . You are receiving this because you modified the open/close state.Message ID: @.*** com>

ericof commented 1 year ago

@pbauer Additional tests implemented on Release 0.4.6 (And on main)