-
Notifications
You must be signed in to change notification settings - Fork 75
Conversation
…e passed on the creation of the RTV
@@ -12,6 +12,7 @@ let package = Package( | |||
.package(name: "Down", url: "https://github.com/johnxnguyen/Down", .upToNextMajor(from: "0.11.0")), | |||
.package(name: "SnapKit", url: "https://github.com/SnapKit/SnapKit", .upToNextMajor(from: "5.0.1")), | |||
.package(name: "iosMath", url: "https://github.com/tophatmonocle/iosMath", .upToNextMajor(from: "1.1.1")), | |||
.package(name: "SwiftRichString", url: "https://github.com/tophatmonocle/SwiftRichString", .branch("master")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pointing to our fork given that we'll need to fix some bugs on the RichString lib
import UIKit | ||
import SwiftRichString | ||
|
||
class DynamicAttributesResolver: XMLDynamicAttributesResolver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is a delegate that handles unknown tags and custom attributes.
* Renders an HTML string into a NSAttributedString by using the SwiftRichString dependency | ||
*/ | ||
|
||
class HTMLRenderer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core class responsible for the rendering; it generates the styles if needed and then call the SwiftRichString set:style method
|
||
// This class is responsible to create the styles that are using to style the HTML tags | ||
|
||
struct HTMLStyleBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This builds the styles. Not all required styles are here - will work on it on a follow up ticket.
@@ -41,6 +41,8 @@ public class RichTextView: UIView { | |||
textViewDelegate: RichTextViewDelegate? = nil, | |||
customAdditionalAttributes: [String: [NSAttributedString.Key: Any]]? = nil, | |||
frame: CGRect, | |||
shouldUseOptimizedHTMLParsing: Bool = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameters to control the version of rendering we should be using
@@ -127,7 +135,7 @@ class RichTextParser { | |||
if attributes.isEmpty || attributes[.attachment] != nil { | |||
return | |||
} | |||
let specialDataSubstring = specialDataTypesString.string[ | |||
let specialDataSubstring: String = specialDataTypesString.string[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To disambiguate
@@ -220,6 +231,27 @@ class RichTextParser { | |||
return (finalOutputString, nil) | |||
} | |||
|
|||
private func getRichTextWithHTMLAndMarkdownHandledV2( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V2 shorter method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments/questions
finalStyleToApply.color = Color(hexString: value) | ||
case "style": | ||
// THIS IS ALL HORRIBLE AND SHOULD BE REFACTOR USING A STRING SCANNER OR REGEX!!! | ||
if value.starts(with: "color: rgb(") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this be changed later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will change it later on follow up tickets.
} | ||
|
||
let codeStyle = baseStyle.byAdding { | ||
$0.backColor = Color(red: 249/255, green: 249/255, blue: 249/255, alpha: 1.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should be using tokens probably? which means they'd need to be passed in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is true. The PR really captures work in progress, and we will complete it on follow up tickets.
But you are right - we probably should add color parameters to the HTMLStyleParams
struct.
Or move the responsibility of build styles to the application instead of the framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
There are still things that we'll be done in follow up tickets:
DevQA
DevQA Prep
pod install
RichTextView
to ensure that it passes (unit and UI tests)Example
project in the rootExample
folder and run the appExample
app looks visually correctDevQA Steps
Comments