I have now implemented support for note documents based on a JSON-structure. The rendering is looking nicely and shortcuts are working - such as `CMD + B` for applying bold styling.
Still work to do with the UI. For example, I'm not really sure where the toolbar should be with all the formatting options. Maybe it should only appear when selecting some text. Then the toolbar could show above the selected text. But that approach is also a bit annoying, because the toolbar will then cover part of the text... The Craft app is using that approach and I'm not particularly a fan of it.
The word and character counters are totally incorrect. They are based on some old logic that I haven't updated yet.
Saving the note is working with shortcut `CMD + S`. I need to show a popup when trying to close a note with unsaved changes. This was actually working before, but the logic was based on an older ViewModel called `NotesViewModel`.
I'm still in the process of switching from having one massive ViewModel to multiple independent ViewModels each with their own responsibilities (some examples of my new VMs are `TabsViewModel`, `FilesViewModel`, `SearchViewModel`, etc.).
Obviuosly, it's bad practice to centralize all code in one ViewModel because it grows so massive that it becomes difficult to maintain (it breaks SRP from SOLID). The reason for me having just one ViewModel for so long, was that I really just wanted to move fast so I could quickly get something working. But when I later wanted to introduce new ViewModels, it then became much harder, because there was so much code that had to be restructured and moved into new ViewModels. So many things broke and it almost took a full day to get everything working again. Some small parts still isn't working, but that's because I just haven't prioritized those things. There are much more important things than getting character counters working again... #dev #Swift #AppKit #macOS

