-
Notifications
You must be signed in to change notification settings - Fork 114
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
Keep media inside BlockSpan when at buffer end #668
Keep media inside BlockSpan when at buffer end #668
Conversation
Thank you @hypest! thanks for throwing light on how end of buffer should work (I actually learn with the explanations and the minimum code changes here helps me understand a lot better how spans are meant to be used). I tested and could observe this fix does indeed solve the end of buffer edge case 🎉 As seen here, the starting Gutenberg delimiter comment is lost when inserting the image at the beginning of text. But good news is that seems to be fixed by adding a similar check like this following one:
in line 147 of LineBlockFormatter.kt. With that change there, I could confirm both the original issue #659 and the ones being exposed in #666 (comment) and here above are gone (at least by following the provided steps to reproduce by the letter). Would be good to see and run the tests @daniloercoli is working on in this branch (with that requested change in line 147) and maybe we can take it from here. |
I'm a bit confused about all of these edges cases honestly. It seems that the Spans approach is easily error prone in general; this comment is not meant for this PR, but it's a general consideration. Back to the code, I'm running into a situation where adding a picture at the beginning of the 2nd paragraph ends up stripping GB code from it. |
I noticed yesterday as I was investigating the root cause that All in all, this doesn't seem to be an issue of the GB comments handling anyway. |
I thought about the same (probably in a rather broader or superficial way than you can do) yesterday, and also that thought linked to nested Gutenberg Blocks, which are going to be there some time in the future.
I must admit I've been approaching the general span-based PRs in a more "let's make it fail" and "gotcha" mood than anything else 😉 but when testing and trying to understand it makes sense to follow the spans architecture overall, as it's the core mechanism Aztec has to understand "what's where" in visual mode without having to keep a "map" up to date elsewhere. |
Added ebcb60e that attempts to fix the media insertion issues reported so far. |
Additional PR to fix the issue reported at #666 (comment)
It seems that the media insertion code doesn't properly account for the buffer end position and ends up appending the media outside the BlockSpan. This PR adds a check for the buffer end.
While at it, added a fix for the cursor position issue when switching between html and visual mode as mentioned by Mario. BTW, that cursor issue is present in current
develop
too.cc @daniloercoli , @mzorz