I finally figured out a solution to fix the many issues I had with my approach for the editor 😅
https://video.nostr.build/b5d44cefb9a6153336fe9375f56963d37450090ef8a1d7838d8a041675fda900.mp4
Basically, I was using an independent and separate `NSTextView` inside of each block.
For example, if I had two text blocks, it would be two separate `NSTextView`s.
This was causing issues with caret navigation using the arrow up and down keys. The reason was that the textviews weren’t connected in any way, so I had to implement a custom solution. It mostly worked, but the x-position was sometimes off by a few characters.
Another problem was selecting text across multiple blocks. This isn’t possible by default either. I didn’t try to implement a custom solution for this, because I could already see that my approach of using separate textviews was flawed. I would’ve ended up spending a lot of time fixing basic things like text selection not working.
I then thought, _what if I could just use a single textview?_ I realized that using `NSMutableAttributedString` could be useful. I spent all of Sunday working on this, but I finally have a solution that seems pretty solid.
Now all blocks are displayed in the same textview, so selecting text across multiple blocks finally works 🚀
**Next tasks:**
- Get images and videos working using `NSTextAttachment`.
- I also need to get the animation working when collapsing a heading, so that the text moves up and its opacity decreases.
- The pointer cursor does not show correctly when hovering the ellipsis button. It still shows the text selection cursor.
#dev #Swift #AppKit #SwiftUI
nostr:nevent1qvzqqqqqqypzp8yls8khjhc0tma9tzfjsfrg0kz0cln2fnaxmdwk6w6sljmlltkzqyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqpz3mhxue69uhhyetvv9ujuerpd46hxtnfduqzpvnzzs3jlhukcp4gxax04y7kywdcxn220f2nde464k9jh259rsv07j43jl
Login to reply