@@ -48,6 +48,17 @@ class EditTextView: NSTextView, NSTextFinderClient {
48
48
super. drawInsertionPoint ( in: newRect, color: EditTextView . fontColor, turnedOn: flag)
49
49
}
50
50
51
+ override func becomeFirstResponder( ) -> Bool {
52
+ let shouldBecomeFirstResponder = super. becomeFirstResponder ( )
53
+ if shouldBecomeFirstResponder && string. isEmpty {
54
+ DispatchQueue . main. async {
55
+ self . applyParagraphStyle ( )
56
+ }
57
+ }
58
+
59
+ return shouldBecomeFirstResponder
60
+ }
61
+
51
62
override func updateInsertionPointStateAndRestartTimer( _ restartFlag: Bool ) {
52
63
super. updateInsertionPointStateAndRestartTimer ( true )
53
64
if let range = selectedRanges [ 0 ] as? NSRange , range. length > 0 , range != initRange {
@@ -981,6 +992,13 @@ class EditTextView: NSTextView, NSTextFinderClient {
981
992
NSWorkspace . shared. open ( url)
982
993
}
983
994
995
+ public func applyParagraphStyle( ) {
996
+ let paragraphStyle = NSTextStorage . getParagraphStyle ( )
997
+ typingAttributes [ . paragraphStyle] = paragraphStyle
998
+ defaultParagraphStyle = paragraphStyle
999
+ textStorage? . updateParagraphStyle ( )
1000
+ }
1001
+
984
1002
override func viewDidChangeEffectiveAppearance( ) {
985
1003
guard let note = EditTextView . note else { return }
986
1004
guard let vc = ViewController . shared ( ) else { return }
0 commit comments