https://github.com/krzyzanowskim/sttextview-plugin-annotations
Annotations Plugin
https://github.com/krzyzanowskim/sttextview-plugin-annotations
plugin sttextview textview
Last synced: 7 months ago
JSON representation
Annotations Plugin
- Host: GitHub
- URL: https://github.com/krzyzanowskim/sttextview-plugin-annotations
- Owner: krzyzanowskim
- License: unlicense
- Created: 2023-09-12T09:08:44.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-05T01:24:09.000Z (over 1 year ago)
- Last Synced: 2024-04-14T07:11:18.816Z (over 1 year ago)
- Topics: plugin, sttextview, textview
- Language: Swift
- Homepage:
- Size: 46.9 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[STTextView](https://github.com/krzyzanowskim/STTextView) Annotations Plugin
## Installation
Add the plugin package as a dependency of your application, then register/add it to the STTextView instance:
```swift
import STAnnotationsPluginclass AnnotationDataSource: STAnnotationsDataSource {
// Optional. Default implementation provided.
// func textView(_ textView: STTextView, viewForLineAnnotation lineAnnotation: any STLineAnnotation, textLineFragment: NSTextLineFragment, proposedViewFrame: CGRect) -> NSView? {
// // view for annotation
// }var textViewAnnotations: [any STLineAnnotation] = []
}let dataSource = AnnotationDataSource()
// Implement AnnotationsDataSource protocol to provide annotations
let plugin = STAnnotationsPlugin(dataSource: dataSource)// Add/register the plugin in the STTextView instance
textView.addPlugin(plugin)
```Check the Demo application (AppKit or UIKit) for a reference implementation.
