From e3ca30f66e484e92cb9b3a564a3f7571edbb367b Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 30 Oct 2017 15:47:58 -0300 Subject: [PATCH 1/4] LayoutManager: New blockquoteBorderWidth property --- Aztec/Classes/TextKit/LayoutManager.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Aztec/Classes/TextKit/LayoutManager.swift b/Aztec/Classes/TextKit/LayoutManager.swift index b544697a4..1602eb121 100644 --- a/Aztec/Classes/TextKit/LayoutManager.swift +++ b/Aztec/Classes/TextKit/LayoutManager.swift @@ -23,6 +23,10 @@ class LayoutManager: NSLayoutManager { /// var extraLineFragmentTypingAttributes: (() -> [String: Any])? + /// Blockquote's Left Border width + /// + var blockquoteBorderWidth: CGFloat = 2 + /// Draws the background, associated to a given Text Range /// @@ -125,7 +129,7 @@ private extension LayoutManager { blockquoteBackgroundColor.setFill() context.fill(rect) - let borderRect = CGRect(origin: rect.origin, size: CGSize(width: 2, height: rect.height)) + let borderRect = CGRect(origin: rect.origin, size: CGSize(width: blockquoteBorderWidth, height: rect.height)) blockquoteBorderColor.setFill() context.fill(borderRect) } From 17a85858b924f43fe1fd1661df63d52fc2035fd8 Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 30 Oct 2017 15:54:38 -0300 Subject: [PATCH 2/4] TextView: Spacing Cleanup --- Aztec/Classes/TextKit/TextView.swift | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift index b0e28566a..ea9e05086 100644 --- a/Aztec/Classes/TextKit/TextView.swift +++ b/Aztec/Classes/TextKit/TextView.swift @@ -124,7 +124,7 @@ public protocol TextViewFormattingDelegate: class { // open class TextView: UITextView { - // MARK: - Properties: Attachments & Media + // MARK: - Aztec Delegates /// The media delegate takes care of providing remote media when requested by the `TextView`. /// If this is not set, all remove images will be left blank. @@ -135,14 +135,16 @@ open class TextView: UITextView { /// fileprivate var textAttachmentImageProvider = [TextViewAttachmentImageProvider]() - // MARK: - Properties: Formatting - + /// Formatting Delegate: to be used by the Edition's Format Bar. + /// open weak var formattingDelegate: TextViewFormattingDelegate? + // MARK: - Properties: Text Lists var maximumListIndentationLevels = 7 + // MARK: - Properties: UI Defaults open let defaultFont: UIFont @@ -154,6 +156,7 @@ open class TextView: UITextView { NSParagraphStyleAttributeName: defaultParagraphStyle] } + // MARK: - Properties: Processors /// This processor will be executed on any HTML you provide to the method `setHTML()` and @@ -165,7 +168,8 @@ open class TextView: UITextView { /// public var outputProcessor: Processor? - // MARK: - Properties: Text Storage + + // MARK: - TextKit Aztec Subclass'ess var storage: TextStorage { return textStorage as! TextStorage @@ -206,6 +210,7 @@ open class TextView: UITextView { } + // MARK: - Init & deinit public init( @@ -1126,9 +1131,6 @@ open class TextView: UITextView { toggle(formatter: formatter, atRange: range) } - - - /// Removes the link, if any, at the specified range /// /// - Parameter range: range that contains the link to be removed. @@ -1288,10 +1290,12 @@ open class TextView: UITextView { } - /// // Check if there is an attachment at the location we are moving. If there is one check if we want to move before or after the attachment based on the margins. + /// Check if there is an attachment at the location we are moving. If there is one check if we want to move before or after the + /// attachment based on the margins. /// /// - Parameter point: the point to check. /// - Returns: true if the point fall inside an attachment margin + /// open func isPointInsideAttachmentMargin(point: CGPoint) -> Bool { let index = layoutManager.characterIndex(for: point, in: textContainer, fractionOfDistanceBetweenInsertionPoints: nil) From 3836eb1eff0bf936c76da6b30e65a45b6b816463 Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 30 Oct 2017 15:55:17 -0300 Subject: [PATCH 3/4] TextView: Blockquote Properties --- Aztec/Classes/TextKit/TextView.swift | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift index ea9e05086..62543e593 100644 --- a/Aztec/Classes/TextKit/TextView.swift +++ b/Aztec/Classes/TextKit/TextView.swift @@ -175,6 +175,47 @@ open class TextView: UITextView { return textStorage as! TextStorage } + var layout: LayoutManager { + return layoutManager as! LayoutManager + } + + + // MARK: - Apparance Properties + + /// Blockquote Blocks Border COlor. + /// + dynamic public var blockquoteBorderColor: UIColor { + get { + return layout.blockquoteBorderColor + } + set { + layout.blockquoteBorderColor = newValue + } + } + + /// Blockquote Blocks Background Color. + /// + dynamic public var blockquoteBackgroundColor: UIColor { + get { + return layout.blockquoteBackgroundColor + } + set { + layout.blockquoteBackgroundColor = newValue + } + } + + /// Pre Blocks Background Color. + /// + dynamic public var preBackgroundColor: UIColor { + get { + return layout.preBackgroundColor + } + set { + layout.preBackgroundColor = newValue + } + } + + // MARK: - Overwritten Properties /// Overwrites Typing Attributes: From 7081abdbf02a14d0acbcc6e19bcf49ee7cd34848 Mon Sep 17 00:00:00 2001 From: Jorge Leandro Perez Date: Mon, 30 Oct 2017 16:56:30 -0300 Subject: [PATCH 4/4] TextView: Addressing comments --- Aztec/Classes/TextKit/TextView.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift index 62543e593..bb3760e61 100644 --- a/Aztec/Classes/TextKit/TextView.swift +++ b/Aztec/Classes/TextKit/TextView.swift @@ -169,7 +169,7 @@ open class TextView: UITextView { public var outputProcessor: Processor? - // MARK: - TextKit Aztec Subclass'ess + // MARK: - TextKit Aztec Subclasses var storage: TextStorage { return textStorage as! TextStorage @@ -251,7 +251,6 @@ open class TextView: UITextView { } - // MARK: - Init & deinit public init(