This was my first attempt at building the same live-preview functionality as #Obsidian and Bear 2.0. These apps hide all #Markdown syntax by default, but then insert the syntax only when cursor is positioned inside a range of text with styling applied (e.g. bold or italic). For example, we have a word "hello" with bold styling. By default, no syntax is displayed – the word is just "hello". But when placing cursor inside the word "**h|ello**", the syntax is now displayed. My first attempt at building this functionality was **VERY** buggy. This was mostly because I ran into issues with SwiftUI's default behavior, where it re-rendered the text view. This messed up my code. #dev #macOS #AppKit #Swift #SwiftUI
Been working on the ‘Source’ mode for my #Markdown editor. It’s working well, though currently only basic formatting works like headings (level 1-6), **bold**, _italic_, and `inline code`. I’ve decided to get the ‘Source’ mode working perfectly before I begin the implementation of the ‘Live Preview’ mode. The ‘Source’ mode is also a live preview, as it shows the formatting but with the Markdown syntax as well. However, the ‘Live Preview’ mode works more like a WYSIWYG editor because it hides all the Markdown syntax. Next task is to get code blocks working, and afterwards, get images to be displayed correctly. The Markdown editor is fundamentally different from my block-based editor as Markdown is linear whereas my block-based JSON notes are divided into multiple blocks where each block is its own text view. Using separate text views makes it much easier to display images and to make them interactive (e.g. clicking an image makes it full screen), because I can place a SwiftUI image in between two text views. In the Markdown editor, I need to embed images into the actual text view. TextKit2 works well for this. I’ve made a working solution before using `NSTextAttachmentViewProvider`. #dev #macOS #AppKit #Swift #SwiftUI View quoted note →
Worked on a color picker today for my notes app. It's fully functional, except for the alpha/opacity slider. After that's implemented, I'll work on making the UI look nice. #dev #macOS #Swift #SwiftUI #AppKit image