-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update text view gesture recognizer to use textkit 2
- Loading branch information
1 parent
807eed1
commit f15e313
Showing
5 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// NSTextLayoutFragment.swift | ||
// Simplenote | ||
// | ||
// Created by Charlie Scheer on 12/20/24. | ||
// Copyright © 2024 Automattic. All rights reserved. | ||
// | ||
|
||
extension NSTextLayoutFragment { | ||
@available(iOS 17.0, *) | ||
func characterIndex(for location: CGPoint) -> Int? { | ||
guard let lineFragment = textLineFragment(forVerticalOffset: location.y, requiresExactMatch: true) else { | ||
return nil | ||
} | ||
return lineFragment.characterIndex(for: location) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// NSTextLayoutManager+Simplenote.swift | ||
// Simplenote | ||
// | ||
// Created by Charlie Scheer on 12/20/24. | ||
// Copyright © 2024 Automattic. All rights reserved. | ||
// | ||
|
||
extension NSTextLayoutManager { | ||
@available(iOS 17.0, *) | ||
func characterIndex(for location: CGPoint) -> Int? { | ||
guard let lineFragment = textLayoutFragment(for: location) else { | ||
return nil | ||
} | ||
return lineFragment.characterIndex(for: location) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters