Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions Aztec/Classes/TextKit/LayoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class LayoutManager: NSLayoutManager {

/// Blockquote's Left Border Color
///
var blockquoteBorderColor = UIColor(red: 0.52, green: 0.65, blue: 0.73, alpha: 1.0)
var blockquoteBorderColor: UIColor? = UIColor(red: 0.52, green: 0.65, blue: 0.73, alpha: 1.0)

/// Blockquote's Background Color
///
var blockquoteBackgroundColor = UIColor(red: 0.91, green: 0.94, blue: 0.95, alpha: 1.0)
var blockquoteBackgroundColor: UIColor? = UIColor(red: 0.91, green: 0.94, blue: 0.95, alpha: 1.0)

/// HTML Pre Background Color
///
var preBackgroundColor = UIColor(red: 243.0/255.0, green: 246.0/255.0, blue: 248.0/255.0, alpha: 1.0)
var preBackgroundColor: UIColor? = UIColor(red: 243.0/255.0, green: 246.0/255.0, blue: 248.0/255.0, alpha: 1.0)

/// Closure that is expected to return the TypingAttributes associated to the Extra Line Fragment
///
Expand Down Expand Up @@ -126,12 +126,17 @@ private extension LayoutManager {
/// Draws a single Blockquote Line Fragment, in the specified Rectangle, using a given Graphics Context.
///
private func drawBlockquote(in rect: CGRect, with context: CGContext) {
blockquoteBackgroundColor.setFill()
context.fill(rect)
if let blockquoteBackgroundColor = blockquoteBackgroundColor {
blockquoteBackgroundColor.setFill()
context.fill(rect)

}

let borderRect = CGRect(origin: rect.origin, size: CGSize(width: blockquoteBorderWidth, height: rect.height))
blockquoteBorderColor.setFill()
context.fill(borderRect)
if let blockquoteBorderColor = blockquoteBorderColor {
let borderRect = CGRect(origin: rect.origin, size: CGSize(width: blockquoteBorderWidth, height: rect.height))
blockquoteBorderColor.setFill()
context.fill(borderRect)
}
}
}

Expand Down Expand Up @@ -172,6 +177,9 @@ private extension LayoutManager {
/// Draws a single HTML Pre Line Fragment, in the specified Rectangle, using a given Graphics Context.
///
private func drawHTMLPre(in rect: CGRect, with context: CGContext) {
guard let preBackgroundColor = preBackgroundColor else {
return
}
preBackgroundColor.setFill()
context.fill(rect)
}
Expand Down
6 changes: 3 additions & 3 deletions Aztec/Classes/TextKit/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ open class TextView: UITextView {

/// Blockquote Blocks Border Color.
///
@objc dynamic public var blockquoteBorderColor: UIColor {
@objc dynamic public var blockquoteBorderColor: UIColor? {
get {
return layout.blockquoteBorderColor
}
Expand All @@ -286,7 +286,7 @@ open class TextView: UITextView {

/// Blockquote Blocks Background Color.
///
@objc dynamic public var blockquoteBackgroundColor: UIColor {
@objc dynamic public var blockquoteBackgroundColor: UIColor? {
get {
return layout.blockquoteBackgroundColor
}
Expand All @@ -309,7 +309,7 @@ open class TextView: UITextView {

/// Pre Blocks Background Color.
///
@objc dynamic public var preBackgroundColor: UIColor {
@objc dynamic public var preBackgroundColor: UIColor? {
get {
return layout.preBackgroundColor
}
Expand Down
5 changes: 3 additions & 2 deletions Example/Example/EditorDemoController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ class EditorDemoController: UIViewController {
titleTextView.textColor = UIColor.label
editorView.htmlTextView.textColor = UIColor.label
editorView.richTextView.textColor = UIColor.label
editorView.richTextView.blockquoteBackgroundColor = UIColor.tertiarySystemBackground
editorView.richTextView.preBackgroundColor = UIColor.tertiarySystemBackground
editorView.richTextView.blockquoteBackgroundColor = UIColor.secondarySystemBackground
editorView.richTextView.preBackgroundColor = UIColor.secondarySystemBackground
editorView.richTextView.blockquoteBorderColor = UIColor.secondarySystemFill
var attributes = editorView.richTextView.linkTextAttributes
attributes?[.foregroundColor] = UIColor.link
} else {
Expand Down