Lexical iOS is an extensible text editor framework that integrates the APIs and philosophies from Lexical Web with a Swift API built on top of TextKit.
This mostly does what we want but the selection logic is weird. If you move the cursor before the decorator block node, the cursor is at the "root" level, which then makes deletions and insertions behave weirdly.
If you look at this video, when the cursor is before the decorator node, you can see in the debug footer that the selection is "root" with the offset of 1. So when you hit backspace, it deletes the whole next paragraph node instead of a single character.
I think we could potentially just handle that case, but then there are other cases where it will throw an invariant violation around losing the cursor position.
If we can figure out how the selection should work for this I can fix the node insertion issues (there is an issue where if you insert the decorator block node within a paragraph with text, it treats it as an inline element). I had a fix for this but lost it when trying to clean up some debug logging.
This mostly does what we want but the selection logic is weird. If you move the cursor before the decorator block node, the cursor is at the "root" level, which then makes deletions and insertions behave weirdly.
https://github.com/user-attachments/assets/a47403f8-db1a-451d-ae73-c9542f9d3b50
If you look at this video, when the cursor is before the decorator node, you can see in the debug footer that the selection is "root" with the offset of 1. So when you hit backspace, it deletes the whole next paragraph node instead of a single character.
I think we could potentially just handle that case, but then there are other cases where it will throw an invariant violation around losing the cursor position.
If we can figure out how the selection should work for this I can fix the node insertion issues (there is an issue where if you insert the decorator block node within a paragraph with text, it treats it as an inline element). I had a fix for this but lost it when trying to clean up some debug logging.