diff --git a/Example/Example/SwiftUI/SampleUI.swift b/Example/Example/SwiftUI/SampleUI.swift index 81f8bb4..620af80 100644 --- a/Example/Example/SwiftUI/SampleUI.swift +++ b/Example/Example/SwiftUI/SampleUI.swift @@ -4,16 +4,14 @@ import MarkdownView struct SampleUI: View { var body: some View { ScrollView { - Text("Header") - .frame(maxWidth: .infinity, idealHeight: 44) - .background(Color.red) - - MarkdownUI(body: markdown) - - Text("Footer") - .frame(maxWidth: .infinity, idealHeight: 44) - .background(Color.red) + .onTouchLink { link in + print(link) + return false + } + .onRendered { height in + print(height) + } } } diff --git a/Example/Podfile.lock b/Example/Podfile.lock index f2ccd96..9ede851 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - MarkdownView (1.9.0) + - MarkdownView (1.9.1) DEPENDENCIES: - MarkdownView (from `../`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - MarkdownView: a3cace707de758a21246d45dba9430fdaf02776a + MarkdownView: 22249778219cc22901f1454e8355298dd0bda7f0 PODFILE CHECKSUM: aca8c849eff30cf020f460dc2fb5cc0b4a16e14a diff --git a/MarkdownView.podspec b/MarkdownView.podspec index 7c52e9f..540a760 100644 --- a/MarkdownView.podspec +++ b/MarkdownView.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MarkdownView" - s.version = "1.9.0" + s.version = "1.9.1" s.summary = "Markdown View for iOS." s.homepage = "https://github.com/keitaoouchi/MarkdownView" s.license = { :type => "MIT", :file => "LICENSE" } diff --git a/MarkdownView.xcodeproj/project.pbxproj b/MarkdownView.xcodeproj/project.pbxproj index 328f4ea..e17f052 100644 --- a/MarkdownView.xcodeproj/project.pbxproj +++ b/MarkdownView.xcodeproj/project.pbxproj @@ -294,7 +294,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.9.0; + MARKETING_VERSION = 1.9.1; PRODUCT_BUNDLE_IDENTIFIER = com.keita.oouchi.MarkdownView; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -321,7 +321,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 1.9.0; + MARKETING_VERSION = 1.9.1; PRODUCT_BUNDLE_IDENTIFIER = com.keita.oouchi.MarkdownView; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/README.md b/README.md index 75f621b..e28aa0f 100644 --- a/README.md +++ b/README.md @@ -18,28 +18,27 @@ ```swift import MarkdownView -let markdownView = MarkdownView() -markdownView.load(markdown: "# Hello World!") +let md = MarkdownView() +md.load(markdown: "# Hello World!") ``` #### SwiftUI -``` +```swift import SwiftUI import MarkdownView struct SampleUI: View { var body: some View { - ScrollView { - Text("Header") - .frame(maxWidth: .infinity, idealHeight: 44) - .background(Color.red) - + ScrollView { MarkdownUI(body: markdown) - - Text("Footer") - .frame(maxWidth: .infinity, idealHeight: 44) - .background(Color.red) + .onTouchLink { link in + print(link) + return false + } + .onRendered { height in + print(height) + } } } diff --git a/Sources/MarkdownView/MarkdownUI.swift b/Sources/MarkdownView/MarkdownUI.swift index 1dc4004..77129a8 100644 --- a/Sources/MarkdownView/MarkdownUI.swift +++ b/Sources/MarkdownView/MarkdownUI.swift @@ -9,11 +9,16 @@ public final class MarkdownUI: UIViewRepresentable { self._body = .constant(body ?? "") self.markdownView = MarkdownView(css: css, plugins: plugins, stylesheets: stylesheets, styled: styled) self.markdownView.isScrollEnabled = false - - self.markdownView.onRendered = { height in - print(height) - - } + } + + public func onTouchLink(perform action: @escaping ((URLRequest) -> Bool)) -> MarkdownUI { + self.markdownView.onTouchLink = action + return self + } + + public func onRendered(perform action: @escaping ((CGFloat) -> Void)) -> MarkdownUI { + self.markdownView.onRendered = action + return self } }