From 36d5f26a1c8a728769810456ab51fefe6f37a7c4 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 29 Dec 2021 17:38:16 +0100 Subject: [PATCH 1/5] Add defaultFontSize configuration flag for Header and Pre Formatters --- .../Classes/Formatters/Implementations/HeaderFormatter.swift | 4 ++++ Aztec/Classes/Formatters/Implementations/PreFormatter.swift | 4 +++- Aztec/Classes/TextKit/Configuration.swift | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Aztec/Classes/Formatters/Implementations/HeaderFormatter.swift b/Aztec/Classes/Formatters/Implementations/HeaderFormatter.swift index d69bf3707..0f97f8621 100644 --- a/Aztec/Classes/Formatters/Implementations/HeaderFormatter.swift +++ b/Aztec/Classes/Formatters/Implementations/HeaderFormatter.swift @@ -114,6 +114,10 @@ private extension HeaderFormatter { } func headerFontSize(for type: Header.HeaderType, defaultSize: Float?) -> Float { + if Configuration.useDefaultFont { + return defaultSize! + } + guard type == .none, let defaultSize = defaultSize else { return type.fontSize } diff --git a/Aztec/Classes/Formatters/Implementations/PreFormatter.swift b/Aztec/Classes/Formatters/Implementations/PreFormatter.swift index cf6ecbbd4..a31c5ad09 100644 --- a/Aztec/Classes/Formatters/Implementations/PreFormatter.swift +++ b/Aztec/Classes/Formatters/Implementations/PreFormatter.swift @@ -30,8 +30,10 @@ open class PreFormatter: ParagraphAttributeFormatter { newParagraphStyle.appendProperty(HTMLPre(with: representation)) + let defaultFont = attributes[.font] + resultingAttributes[.paragraphStyle] = newParagraphStyle - resultingAttributes[.font] = monospaceFont + resultingAttributes[.font] = Configuration.useDefaultFont ? defaultFont : monospaceFont return resultingAttributes } diff --git a/Aztec/Classes/TextKit/Configuration.swift b/Aztec/Classes/TextKit/Configuration.swift index 898385828..116cef2a2 100644 --- a/Aztec/Classes/TextKit/Configuration.swift +++ b/Aztec/Classes/TextKit/Configuration.swift @@ -3,6 +3,7 @@ import Foundation public final class Configuration { public static var headersWithBoldTrait = false + public static var useDefaultFont = false static var defaultBoldFormatter: AttributeFormatter { get { From fcda8c9689e37b041c73c81a3a17af3be9cfeba5 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Fri, 31 Dec 2021 12:39:20 +0100 Subject: [PATCH 2/5] Add shouldRecalculateTypingAttributesOnDeleteBackward This variable allows to control whether typing attributes should be recalculated when deleting backward, by default it's enabled. --- Aztec/Classes/TextKit/TextView.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift index 186429c92..2d58ecbd6 100644 --- a/Aztec/Classes/TextKit/TextView.swift +++ b/Aztec/Classes/TextKit/TextView.swift @@ -177,7 +177,11 @@ open class TextView: UITextView { /// If this is true the text view will notify is delegate and notification system when changes happen by calls to methods like setHTML /// open var shouldNotifyOfNonUserChanges = true - + + /// If this is true the typing attributes will be recalculated when deleting backward + /// + open var shouldRecalculateTypingAttributesOnDeleteBackward = true + // MARK: - Customizable Input VC private var customInputViewController: UIInputViewController? @@ -738,7 +742,9 @@ open class TextView: UITextView { evaluateRemovalOfSingleLineParagraphAttributesAfterSelectionChange() ensureRemovalOfParagraphAttributesWhenPressingBackspaceAndEmptyingTheDocument() ensureCursorRedraw(afterEditing: deletedString.string) - recalculateTypingAttributes() + if(shouldRecalculateTypingAttributesOnDeleteBackward) { + recalculateTypingAttributes() + } notifyTextViewDidChange() } From d68c76ec8f01490c741077dccefc17b17ce19f2d Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Fri, 31 Dec 2021 12:52:46 +0100 Subject: [PATCH 3/5] Correct lint issues --- Aztec/Classes/TextKit/TextView.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift index 2d58ecbd6..b02ba55f3 100644 --- a/Aztec/Classes/TextKit/TextView.swift +++ b/Aztec/Classes/TextKit/TextView.swift @@ -177,11 +177,11 @@ open class TextView: UITextView { /// If this is true the text view will notify is delegate and notification system when changes happen by calls to methods like setHTML /// open var shouldNotifyOfNonUserChanges = true - + /// If this is true the typing attributes will be recalculated when deleting backward /// open var shouldRecalculateTypingAttributesOnDeleteBackward = true - + // MARK: - Customizable Input VC private var customInputViewController: UIInputViewController? @@ -742,7 +742,7 @@ open class TextView: UITextView { evaluateRemovalOfSingleLineParagraphAttributesAfterSelectionChange() ensureRemovalOfParagraphAttributesWhenPressingBackspaceAndEmptyingTheDocument() ensureCursorRedraw(afterEditing: deletedString.string) - if(shouldRecalculateTypingAttributesOnDeleteBackward) { + if shouldRecalculateTypingAttributesOnDeleteBackward { recalculateTypingAttributes() } notifyTextViewDidChange() From ecfa5dfc4b0c783df4f630802a392e59fb6b7910 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Wed, 5 Jan 2022 12:47:46 +0100 Subject: [PATCH 4/5] Update podspec files --- WordPress-Aztec-iOS.podspec | 2 +- WordPress-Editor-iOS.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress-Aztec-iOS.podspec b/WordPress-Aztec-iOS.podspec index 61899a38e..8eacfefaa 100644 --- a/WordPress-Aztec-iOS.podspec +++ b/WordPress-Aztec-iOS.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WordPress-Aztec-iOS' - s.version = '1.19.6' + s.version = '1.19.7' s.summary = 'The native HTML Editor.' s.description = <<-DESC diff --git a/WordPress-Editor-iOS.podspec b/WordPress-Editor-iOS.podspec index c0295ac96..729a5c3b1 100644 --- a/WordPress-Editor-iOS.podspec +++ b/WordPress-Editor-iOS.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WordPress-Editor-iOS' - s.version = '1.19.6' + s.version = '1.19.7' s.summary = 'The WordPress HTML Editor.' s.description = <<-DESC From 156cb9e733bf08406b15a82f702968d1ff8ec5ab Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Wed, 5 Jan 2022 12:47:52 +0100 Subject: [PATCH 5/5] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42e95d34f..f4c74771e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +1.19.7 +------- +* Add variable to control whether typing attributes should be recalculated when deleting backward. +* Allow using the default font for the PreFormatter/HeaderFormatter. + 1.19.6 ------- * Add support for Mark inline formatting.