Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pbauer opened this issue Mar 3, 2023 · 4 comments
Closed

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

pbauer opened this issue Mar 3, 2023 · 4 comments
Assignees

Comments

@pbauer
Copy link
Sponsor Member

pbauer commented Mar 3, 2023

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
Copy link
Sponsor Member

Similar to #20 -- thanks for the specific case

@ericof ericof closed this as completed in 78474aa Mar 3, 2023
@pbauer
Copy link
Sponsor Member Author

pbauer commented Mar 5, 2023

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': ''}]}]}

@pbauer pbauer reopened this Mar 5, 2023
@ericof
Copy link
Sponsor Member

ericof commented Mar 5, 2023 via email

@ericof
Copy link
Sponsor Member

ericof commented Mar 6, 2023

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

@ericof ericof closed this as completed Mar 6, 2023
ericof added a commit that referenced this issue Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants