diff --git a/NextcloudTalk.xcodeproj/project.pbxproj b/NextcloudTalk.xcodeproj/project.pbxproj index e58657c6f..4e8edb76a 100644 --- a/NextcloudTalk.xcodeproj/project.pbxproj +++ b/NextcloudTalk.xcodeproj/project.pbxproj @@ -3134,7 +3134,7 @@ repositoryURL = "https://github.com/nextcloud-deps/CDMarkdownKit.git"; requirement = { kind = revision; - revision = a425cc36263996ce4d992178f9847760a166fe8e; + revision = 7675b9c3f8b55ffd129e4a93032efb6a4e00db75; }; }; 1F0ECBFB2A73F21A00921E90 /* XCRemoteSwiftPackageReference "realm-swift" */ = { diff --git a/NextcloudTalk/MessageBodyTextView.m b/NextcloudTalk/MessageBodyTextView.m index 5cdb05241..65db81636 100644 --- a/NextcloudTalk/MessageBodyTextView.m +++ b/NextcloudTalk/MessageBodyTextView.m @@ -27,17 +27,22 @@ #import "NCUtils.h" #import "OpenInFirefoxControllerObjC.h" +#import "NextcloudTalk-Swift.h" + @implementation MessageBodyTextView - (instancetype)init { - // Use TextKit1 to have the background of code/syntax blocks span the whole line - if (@available(iOS 16.0, *)) { - self = [MessageBodyTextView textViewUsingTextLayoutManager:false]; - } else { - self = [super init]; - } - + NSTextStorage *textStorage = [NSTextStorage new]; + + NSLayoutManager *layoutManager = (NSLayoutManager *)[SwiftMarkdownObjCBridge getLayoutManager]; + [textStorage addLayoutManager: layoutManager]; + + NSTextContainer *textContainer = [NSTextContainer new]; + [layoutManager addTextContainer: textContainer]; + + self = [[MessageBodyTextView alloc] initWithFrame:CGRectZero textContainer:textContainer]; + if (!self) { return nil; } @@ -50,7 +55,6 @@ - (instancetype)init self.editable = NO; self.scrollEnabled = NO; self.delegate = self; - return self; } diff --git a/NextcloudTalk/SwiftMarkdownObjCBridge.swift b/NextcloudTalk/SwiftMarkdownObjCBridge.swift index 761468735..de4c63c97 100644 --- a/NextcloudTalk/SwiftMarkdownObjCBridge.swift +++ b/NextcloudTalk/SwiftMarkdownObjCBridge.swift @@ -53,4 +53,10 @@ import UIKit static func parseMarkdown(markdownString: NSAttributedString) -> NSMutableAttributedString { return NSMutableAttributedString(attributedString: markdownParser.parse(markdownString)) } + + static func getLayoutManager() -> CDMarkdownLayoutManager { + let manager = CDMarkdownLayoutManager() + manager.roundAllCorners = true + return manager + } }