Skip to content

Commit

Permalink
Merge pull request #42 from vidalhara/feature/custom-link-open-type
Browse files Browse the repository at this point in the history
[Feature]: Add custom type to LinkOpenType
  • Loading branch information
NuPlay authored Jan 21, 2024
2 parents ff468d1 + c1dcc8e commit 560b3a6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Modifier | Default
- colorScheme(default: .auto) : light or dark mode (it changes text color)
- fontType(default: .system): Font type in RichText view
- linkColor (default: ColorSet(light: "#007AFF", dark: "#0A84FF")) : linkColor (Color or UIColor)
- linkOpenType (default: .Safari) : When the user clicks the link contained in html, Way to Show Webview
- linkOpenType (default: .Safari) : When the user clicks the link contained in html, Way to take action
- placeholder (default: nil) : What to display until Richtext views are completely drawn (View type)
- transition(default: .none) : Transition between PlaceHolder and Content
- colorPreference(default: .onlyLinks) : css '!important', It ignores the color in variable 'html'
Expand Down
1 change: 1 addition & 0 deletions Sources/RichText/Models/RichTextEnums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public enum LinkOpenType {
case SFSafariView(configuration: SFSafariViewController.Configuration = .init(), isReaderActivated: Bool? = nil, isAnimated: Bool = true)
#endif
case Safari
case custom((URL) -> Void)
case none
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/RichText/Views/Webview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ extension WebView {
#else
NSWorkspace.shared.open(url)
#endif
case let .custom(action):
action(url)
case .none:
break
}
Expand Down

0 comments on commit 560b3a6

Please sign in to comment.