Add TextKit Line Numbers And Foldable Sections Without Rebuilding Text Editing
Read OriginalThis article explains how to add line numbers and collapsible sections to a text editor using TextKit 2 without rebuilding the entire text editing system. It advocates for extending existing UITextView and NSTextView behaviors rather than choosing between SwiftUI's limited TextEditor or building a full custom editor. The post covers architecture with SwiftUI as the shell, UIKit for the editing surface, and TextKit for layout, including a gutter view, fold model, and NSTextAttachmentViewProvider reuse. It references WWDC26 sessions and beta-era TextKit 2 APIs for the 2027 SDK cycle.
Comments
No comments yet
Be the first to share your thoughts!
Browser Extension
Get instant access to AllDevBlogs from your browser
Top of the Week
No top articles yet