diff --git a/submodules/BrowserUI/Sources/BrowserInstantPageContent.swift b/submodules/BrowserUI/Sources/BrowserInstantPageContent.swift index 8661daac51..f334322e60 100644 --- a/submodules/BrowserUI/Sources/BrowserInstantPageContent.swift +++ b/submodules/BrowserUI/Sources/BrowserInstantPageContent.swift @@ -414,8 +414,7 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg if let state = self.initialState { didSetScrollOffset = true contentOffset = CGPoint(x: 0.0, y: CGFloat(state.contentOffset)) - } - else if let anchor = self.initialAnchor, !anchor.isEmpty { + } else if let anchor = self.initialAnchor, !anchor.isEmpty { self.initialAnchor = nil if let items = self.currentLayout?.items { didSetScrollOffset = true @@ -1312,35 +1311,35 @@ final class BrowserInstantPageContent: UIView, BrowserContent, UIScrollViewDeleg } private func presentReferenceView(item: InstantPageTextItem, referenceAnchor: String) { -// guard let theme = self.theme, let webPage = self.webPage else { -// return -// } -// -// var targetAnchor: InstantPageTextAnchorItem? -// for (name, (line, _)) in item.anchors { -// if name == referenceAnchor { -// let anchors = item.lines[line].anchorItems -// for anchor in anchors { -// if anchor.name == referenceAnchor { -// targetAnchor = anchor -// break -// } -// } -// } -// } -// -// guard let anchorText = targetAnchor?.anchorText else { -// return -// } -// -// let controller = InstantPageReferenceController(context: self.context, sourceLocation: self.sourceLocation, theme: theme, webPage: webPage, anchorText: anchorText, openUrl: { [weak self] url in -// self?.openUrl(url) -// }, openUrlIn: { [weak self] url in -// self?.openUrlIn(url) -// }, present: { [weak self] c, a in -// self?.present(c, a) -// }) -// self.present(controller, nil) + guard let webPage = self.webPage else { + return + } + + var targetAnchor: InstantPageTextAnchorItem? + for (name, (line, _)) in item.anchors { + if name == referenceAnchor { + let anchors = item.lines[line].anchorItems + for anchor in anchors { + if anchor.name == referenceAnchor { + targetAnchor = anchor + break + } + } + } + } + + guard let anchorText = targetAnchor?.anchorText else { + return + } + + let controller = InstantPageReferenceController(context: self.context, sourceLocation: self.sourceLocation, theme: theme, webPage: webPage, anchorText: anchorText, openUrl: { [weak self] url in + self?.openUrl(url) + }, openUrlIn: { [weak self] url in + self?.openUrlIn(url) + }, present: { [weak self] c, a in + self?.present(c, a) + }) + self.present(controller, nil) } private func scrollToAnchor(_ anchor: String) { diff --git a/submodules/BrowserUI/Sources/BrowserWebContent.swift b/submodules/BrowserUI/Sources/BrowserWebContent.swift index 2611f92fb9..51f7e365d1 100644 --- a/submodules/BrowserUI/Sources/BrowserWebContent.swift +++ b/submodules/BrowserUI/Sources/BrowserWebContent.swift @@ -251,6 +251,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU self.backgroundColor = presentationData.theme.list.plainBackgroundColor self.webView.backgroundColor = presentationData.theme.list.plainBackgroundColor + self.webView.isOpaque = false self.webView.allowsBackForwardNavigationGestures = true self.webView.scrollView.delegate = self diff --git a/submodules/InstantPageUI/Sources/InstantPageReferenceController.swift b/submodules/InstantPageUI/Sources/InstantPageReferenceController.swift index e08a437250..318ecae4ef 100644 --- a/submodules/InstantPageUI/Sources/InstantPageReferenceController.swift +++ b/submodules/InstantPageUI/Sources/InstantPageReferenceController.swift @@ -7,7 +7,7 @@ import SwiftSignalKit import AccountContext import TelegramUIPreferences -final class InstantPageReferenceController: ViewController { +public final class InstantPageReferenceController: ViewController { private var controllerNode: InstantPageReferenceControllerNode { return self.displayNode as! InstantPageReferenceControllerNode } @@ -23,7 +23,7 @@ final class InstantPageReferenceController: ViewController { private let openUrlIn: (InstantPageUrlItem) -> Void private let present: (ViewController, Any?) -> Void - init(context: AccountContext, sourceLocation: InstantPageSourceLocation, theme: InstantPageTheme, webPage: TelegramMediaWebpage, anchorText: NSAttributedString, openUrl: @escaping (InstantPageUrlItem) -> Void, openUrlIn: @escaping (InstantPageUrlItem) -> Void, present: @escaping (ViewController, Any?) -> Void) { + public init(context: AccountContext, sourceLocation: InstantPageSourceLocation, theme: InstantPageTheme, webPage: TelegramMediaWebpage, anchorText: NSAttributedString, openUrl: @escaping (InstantPageUrlItem) -> Void, openUrlIn: @escaping (InstantPageUrlItem) -> Void, present: @escaping (ViewController, Any?) -> Void) { self.context = context self.sourceLocation = sourceLocation self.theme = theme diff --git a/submodules/InstantPageUI/Sources/InstantPageTextItem.swift b/submodules/InstantPageUI/Sources/InstantPageTextItem.swift index d0865f7fdd..af427754de 100644 --- a/submodules/InstantPageUI/Sources/InstantPageTextItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageTextItem.swift @@ -38,10 +38,10 @@ struct InstantPageTextImageItem { let id: EngineMedia.Id } -struct InstantPageTextAnchorItem { - let name: String - let anchorText: NSAttributedString? - let empty: Bool +public struct InstantPageTextAnchorItem { + public let name: String + public let anchorText: NSAttributedString? + public let empty: Bool } public struct InstantPageTextRangeRectEdge: Equatable { @@ -63,7 +63,7 @@ public final class InstantPageTextLine { let strikethroughItems: [InstantPageTextStrikethroughItem] let markedItems: [InstantPageTextMarkedItem] let imageItems: [InstantPageTextImageItem] - let anchorItems: [InstantPageTextAnchorItem] + public let anchorItems: [InstantPageTextAnchorItem] let isRTL: Bool init(line: CTLine, range: NSRange, frame: CGRect, strikethroughItems: [InstantPageTextStrikethroughItem], markedItems: [InstantPageTextMarkedItem], imageItems: [InstantPageTextImageItem], anchorItems: [InstantPageTextAnchorItem], isRTL: Bool) { diff --git a/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/CodableDrawingEntity.swift b/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/CodableDrawingEntity.swift index b930925be4..811350c9c9 100644 --- a/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/CodableDrawingEntity.swift +++ b/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/CodableDrawingEntity.swift @@ -1,5 +1,6 @@ import Foundation import TelegramCore +import UrlEscaping public func decodeCodableDrawingEntities(data: Data) -> [CodableDrawingEntity] { if let codableEntities = try? JSONDecoder().decode([CodableDrawingEntity].self, from: data) { @@ -183,13 +184,9 @@ public enum CodableDrawingEntity: Equatable { return nil } case let .link(entity): - var url = entity.url - if !url.hasPrefix("http://") && !url.hasPrefix("https://") { - url = "https://\(url)" - } return .link( coordinates: coordinates, - url: url + url: explicitUrl(entity.url) ) case let .weather(entity): let color: UInt32