Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2bdd78d
Remove unused style code.
SergioEstevao Oct 2, 2019
30f661e
Add color converter and tests
SergioEstevao Oct 2, 2019
246ccf1
Merge pull request #1215 from wordpress-mobile/issue/703_fix_color_st…
SergioEstevao Oct 4, 2019
73d74f1
CircleCI: Publish pods when the repo is tagged
jtreanor Oct 4, 2019
f9ff2d3
Merge pull request #1219 from wordpress-mobile/circleci-publish
jtreanor Oct 7, 2019
1f47ac8
Allow dynamic change of default font.
SergioEstevao Oct 7, 2019
ae81f1c
CircleCI: Use --include-podspecs when validating WordPress-Editor-iOS…
jtreanor Oct 8, 2019
efc0760
Remove unused code.
SergioEstevao Oct 8, 2019
cdb2814
Use font provider class to provide default fonts
SergioEstevao Oct 8, 2019
b155e7d
Make font properties public
SergioEstevao Oct 8, 2019
1994a24
Update code for iOS 11
SergioEstevao Oct 8, 2019
4aa260a
Use published Orb
jtreanor Oct 9, 2019
7f998f4
Improve and generalize code for replacement of fonts in attributed st…
SergioEstevao Oct 9, 2019
31e70a0
Make font provider shared instance public
SergioEstevao Oct 9, 2019
3d0c2e8
Improve replaceFont code and add some documentation.
SergioEstevao Oct 9, 2019
1b53a74
Merge pull request #1220 from wordpress-mobile/circleci-validate
jtreanor Oct 9, 2019
7eddd37
Fix possible issues were font is not available.
SergioEstevao Oct 9, 2019
dcf6ec9
Merge branch 'issue/allow_change_of_default_font' into issue/update_x…
SergioEstevao Oct 9, 2019
f7561ef
Convert to let variables.
SergioEstevao Oct 9, 2019
46ac801
Add documentation.
SergioEstevao Oct 9, 2019
fa4c640
Fix test
SergioEstevao Oct 9, 2019
dfb037f
Merge branch 'issue/allow_change_of_default_font' into issue/update_x…
SergioEstevao Oct 9, 2019
181ebc7
Merge pull request #1221 from wordpress-mobile/issue/allow_change_of_…
SergioEstevao Oct 9, 2019
7035a6a
Merge branch 'develop' into issue/update_xcode_ios_version
SergioEstevao Oct 9, 2019
81e1e1b
Merge pull request #1222 from wordpress-mobile/issue/update_xcode_ios…
SergioEstevao Oct 10, 2019
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
29 changes: 26 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1

orbs:
# This uses the iOS Orb located at https://github.com/wordpress-mobile/circleci-orbs
ios: wordpress-mobile/ios@0.0.32
ios: wordpress-mobile/ios@0.0.36

workflows:
test_and_validate:
Expand All @@ -28,5 +28,28 @@ workflows:
name: Validate WordPress-Editor-iOS.podspec
xcode-version: "11.0"
podspec-path: WordPress-Editor-iOS.podspec
# Updating specs is needed since WordPress-Editor-iOS depends on WordPress-Aztec-iOS
update-specs-repo: true
# Reference WordPress-Aztec-iOS.podspec locally so we don't have to get it from the specs repo
additional-parameters: --include-podspecs=WordPress-Aztec-iOS.podspec

- ios/publish-podspec:
name: Publish WordPress-Aztec-iOS to Trunk
xcode-version: "11.0"
podspec-path: WordPress-Aztec-iOS.podspec
post-to-slack: true
filters:
tags:
only: /.*/
branches:
ignore: /.*/

- ios/publish-podspec:
name: Publish WordPress-Editor-iOS to Trunk
requires: [ "Publish WordPress-Aztec-iOS to Trunk" ]
xcode-version: "11.0"
podspec-path: WordPress-Editor-iOS.podspec
post-to-slack: true
filters:
tags:
only: /.*/
branches:
ignore: /.*/
28 changes: 24 additions & 4 deletions Aztec.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,18 @@
FF24AC991F0146AF003CA91D /* Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF24AC981F0146AF003CA91D /* Assets.swift */; };
FF437B6420D7CB2D000D9666 /* HTMLLi.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF437B6320D7CB2D000D9666 /* HTMLLi.swift */; };
FF437B6620D7CB83000D9666 /* LiFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF437B6520D7CB83000D9666 /* LiFormatter.swift */; };
FF48CAC8234DD5D3007FFC79 /* NSMutableAttributedString+ReplaceAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF48CAC7234DD5D3007FFC79 /* NSMutableAttributedString+ReplaceAttributes.swift */; };
FF4E26601EA8DF1E005E8E42 /* ImageAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF4E265F1EA8DF1E005E8E42 /* ImageAttachment.swift */; };
FF61909E202481F4004BCD0A /* CodeFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF61909D202481F4004BCD0A /* CodeFormatter.swift */; };
FF7A1C511E5651EA00C4C7C8 /* LineAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF7A1C501E5651EA00C4C7C8 /* LineAttachment.swift */; };
FF7C89B01E3BC52F000472A8 /* NSAttributedString+FontTraits.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF7C89AF1E3BC52F000472A8 /* NSAttributedString+FontTraits.swift */; };
FF7EAEC4234D253B007A26E0 /* FontProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF7EAEC3234D253B007A26E0 /* FontProvider.swift */; };
FFA61E891DF18F3D00B71BF6 /* ParagraphStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFA61E881DF18F3D00B71BF6 /* ParagraphStyle.swift */; };
FFA61EC21DF6C1C900B71BF6 /* NSAttributedString+Archive.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFA61EC11DF6C1C900B71BF6 /* NSAttributedString+Archive.swift */; };
FFB5D29720BEB21A0038DCFB /* CiteFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFB5D29620BEB21A0038DCFB /* CiteFormatter.swift */; };
FFD0FEB71DAE59A700430586 /* NSLayoutManager+Attachments.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD0FEB61DAE59A700430586 /* NSLayoutManager+Attachments.swift */; };
FFD3C1712344DB4E00AE8DA0 /* ForegroundColorCSSAttributeMatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD3C1702344DB4E00AE8DA0 /* ForegroundColorCSSAttributeMatcher.swift */; };
FFD3C1732344DCA900AE8DA0 /* ForegroundColorElementAttributeConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD3C1722344DCA900AE8DA0 /* ForegroundColorElementAttributeConverter.swift */; };
FFD436981E3180A500A0E26F /* FontFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD436971E3180A500A0E26F /* FontFormatterTests.swift */; };
FFFEC7DB1EA7698900F4210F /* VideoAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFFEC7DA1EA7698900F4210F /* VideoAttachment.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -503,6 +507,7 @@
FF24AC981F0146AF003CA91D /* Assets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Assets.swift; sourceTree = "<group>"; };
FF437B6320D7CB2D000D9666 /* HTMLLi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTMLLi.swift; sourceTree = "<group>"; };
FF437B6520D7CB83000D9666 /* LiFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LiFormatter.swift; sourceTree = "<group>"; };
FF48CAC7234DD5D3007FFC79 /* NSMutableAttributedString+ReplaceAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSMutableAttributedString+ReplaceAttributes.swift"; sourceTree = "<group>"; };
FF4E265F1EA8DF1E005E8E42 /* ImageAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageAttachment.swift; sourceTree = "<group>"; };
FF5B98E21DC29D0C00571CA4 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; };
FF5B98E41DC355B400571CA4 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = SOURCE_ROOT; };
Expand All @@ -511,11 +516,14 @@
FF7A1C4A1E51F05700C4C7C8 /* CONTRIBUTING.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CONTRIBUTING.md; sourceTree = "<group>"; };
FF7A1C501E5651EA00C4C7C8 /* LineAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LineAttachment.swift; sourceTree = "<group>"; };
FF7C89AF1E3BC52F000472A8 /* NSAttributedString+FontTraits.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSAttributedString+FontTraits.swift"; sourceTree = "<group>"; };
FF7EAEC3234D253B007A26E0 /* FontProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontProvider.swift; sourceTree = "<group>"; };
FFA61E881DF18F3D00B71BF6 /* ParagraphStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParagraphStyle.swift; sourceTree = "<group>"; };
FFA61EC11DF6C1C900B71BF6 /* NSAttributedString+Archive.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSAttributedString+Archive.swift"; sourceTree = "<group>"; };
FFB5D29620BEB21A0038DCFB /* CiteFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CiteFormatter.swift; sourceTree = "<group>"; };
FFC2BBF81F2A25CF00E404FB /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
FFD0FEB61DAE59A700430586 /* NSLayoutManager+Attachments.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSLayoutManager+Attachments.swift"; sourceTree = "<group>"; };
FFD3C1702344DB4E00AE8DA0 /* ForegroundColorCSSAttributeMatcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForegroundColorCSSAttributeMatcher.swift; sourceTree = "<group>"; };
FFD3C1722344DCA900AE8DA0 /* ForegroundColorElementAttributeConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForegroundColorElementAttributeConverter.swift; sourceTree = "<group>"; };
FFD436971E3180A500A0E26F /* FontFormatterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FontFormatterTests.swift; sourceTree = "<group>"; };
FFFEC7DA1EA7698900F4210F /* VideoAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoAttachment.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -742,6 +750,7 @@
FFD0FEB61DAE59A700430586 /* NSLayoutManager+Attachments.swift */,
F1584795203C9B4C00EE05A1 /* NSMutableAttributedString+ParagraphProperty.swift */,
F10BE6171EA7ADA6002E4625 /* NSMutableAttributedString+ReplaceOcurrences.swift */,
FF48CAC7234DD5D3007FFC79 /* NSMutableAttributedString+ReplaceAttributes.swift */,
F18733C41DA096EE005AEB80 /* NSRange+Helpers.swift */,
FF20D6431EDC395E00294B78 /* NSTextingResult+Helpers.swift */,
F1C05B9C1E37FA77007510EA /* String+CharacterName.swift */,
Expand Down Expand Up @@ -800,6 +809,7 @@
FFA61E881DF18F3D00B71BF6 /* ParagraphStyle.swift */,
B5A99D831EBA073D00DED081 /* HTMLStorage.swift */,
F9982CF521877663001E606B /* TextViewPasteboardDelegate.swift */,
FF7EAEC3234D253B007A26E0 /* FontProvider.swift */,
);
path = TextKit;
sourceTree = "<group>";
Expand Down Expand Up @@ -898,6 +908,7 @@
F1098740214FF55F00983B6A /* BoldElementAttributeConverter.swift */,
F109874421501A2F00983B6A /* ItalicElementAttributeConverter.swift */,
F109874821501C8B00983B6A /* UnderlineElementAttributeConverter.swift */,
FFD3C1722344DCA900AE8DA0 /* ForegroundColorElementAttributeConverter.swift */,
);
path = Implementations;
sourceTree = "<group>";
Expand Down Expand Up @@ -1087,6 +1098,7 @@
F15BA610215167D200424120 /* CSSAttributeMatcher.swift */,
F1F5C9DA21516E4B00F67990 /* ItalicCSSAttributeMatcher.swift */,
F1F5C9DC2151702600F67990 /* UnderlineCSSAttributeMatcher.swift */,
FFD3C1702344DB4E00AE8DA0 /* ForegroundColorCSSAttributeMatcher.swift */,
);
path = CSS;
sourceTree = "<group>";
Expand Down Expand Up @@ -1524,6 +1536,8 @@
B572AC281E817CFE008948C2 /* CommentAttachment.swift in Sources */,
F1E1D5881FEC52EE0086B339 /* GenericElementConverter.swift in Sources */,
F1FA0E861E6EF514009D98EE /* Node.swift in Sources */,
FFD3C1712344DB4E00AE8DA0 /* ForegroundColorCSSAttributeMatcher.swift in Sources */,
FFD3C1732344DCA900AE8DA0 /* ForegroundColorElementAttributeConverter.swift in Sources */,
F1656FDE2152A6A6009C7E3A /* CiteStringAttributeConverter.swift in Sources */,
599F254B1D8BC9A1002871D6 /* String+RangeConversion.swift in Sources */,
599F25481D8BC9A1002871D6 /* Metrics.swift in Sources */,
Expand Down Expand Up @@ -1565,6 +1579,7 @@
F165D92A20C72EF500EAA6B0 /* Array+ShortcodeAttribute.swift in Sources */,
F165D92420C72C1000EAA6B0 /* ShortcodeAttributeSerializer.swift in Sources */,
F177FF751FB6404D00CBBE35 /* UILayoutPriority+Swift4.swift in Sources */,
FF7EAEC4234D253B007A26E0 /* FontProvider.swift in Sources */,
F1C05B9D1E37FA77007510EA /* String+CharacterName.swift in Sources */,
F1FF7D9F201A1D24007B0B32 /* Figcaption.swift in Sources */,
FF17B2D2227A589F0022AECE /* LIElementConverter.swift in Sources */,
Expand Down Expand Up @@ -1631,6 +1646,7 @@
599F25381D8BC9A1002871D6 /* InAttributesConverter.swift in Sources */,
B551A4A01E770B3800EE3A7F /* UIFont+Emoji.swift in Sources */,
F13E8AD820B71BAA007C9F8A /* PluginManager.swift in Sources */,
FF48CAC8234DD5D3007FFC79 /* NSMutableAttributedString+ReplaceAttributes.swift in Sources */,
F12F586E1EF20394008AE298 /* LinkFormatter.swift in Sources */,
F1584796203C9B4C00EE05A1 /* NSMutableAttributedString+ParagraphProperty.swift in Sources */,
F15BA6092151501300424120 /* BoldStringAttributeConverter.swift in Sources */,
Expand Down Expand Up @@ -1800,7 +1816,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lxml2";
Expand Down Expand Up @@ -1861,7 +1877,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_LDFLAGS = "-lxml2";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1893,6 +1909,7 @@
);
INFOPLIST_FILE = Aztec/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -1922,6 +1939,7 @@
);
INFOPLIST_FILE = Aztec/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2063,7 +2081,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lxml2";
Expand Down Expand Up @@ -2095,6 +2113,7 @@
);
INFOPLIST_FILE = Aztec/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2175,7 +2194,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lxml2";
Expand Down Expand Up @@ -2208,6 +2227,7 @@
);
INFOPLIST_FILE = Aztec/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Foundation
import UIKit

class ForegroundColorElementAttributesConverter: ElementAttributeConverter {

let cssAttributeMatcher = ForegroundColorCSSAttributeMatcher()

func convert(
_ attribute: Attribute,
inheriting attributes: [NSAttributedString.Key: Any]) -> [NSAttributedString.Key: Any] {

guard let cssColor = attribute.firstCSSAttribute(ofType: .foregroundColor),
let colorValue = cssColor.value,
let color = UIColor(hexString: colorValue) else {
return attributes
}

var attributes = attributes

attributes[.foregroundColor] = color

return attributes
}
}
20 changes: 8 additions & 12 deletions Aztec/Classes/EditorView/EditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@ public class EditorView: UIView {

self.htmlTextView = htmlTextView
self.richTextView = richTextView

if #available(iOS 11, *) {
htmlTextView.smartInsertDeleteType = .no
htmlTextView.smartDashesType = .no
htmlTextView.smartQuotesType = .no
}

htmlTextView.smartInsertDeleteType = .no
htmlTextView.smartDashesType = .no
htmlTextView.smartQuotesType = .no

super.init(coder: aDecoder)

Expand All @@ -129,12 +127,10 @@ public class EditorView: UIView {

self.htmlTextView = UITextView(frame: .zero, textContainer: container)
self.richTextView = TextView(defaultFont: defaultFont, defaultParagraphStyle: defaultParagraphStyle, defaultMissingImage: defaultMissingImage)

if #available(iOS 11, *) {
htmlTextView.smartInsertDeleteType = .no
htmlTextView.smartDashesType = .no
htmlTextView.smartQuotesType = .no
}

htmlTextView.smartInsertDeleteType = .no
htmlTextView.smartDashesType = .no
htmlTextView.smartQuotesType = .no

super.init(frame: .zero)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation
import UIKit

public extension NSMutableAttributedString {

/// Replace all instances of the .font attribute that belong to the same family for the new font, trying to keep the same symbolic traits
/// - Parameter font: the original font to be replaced
/// - Parameter newFont: the new font to use.
func replace(font: UIFont, with newFont: UIFont) {
let fullRange = NSRange(location: 0, length: length)

beginEditing()
enumerateAttributes(in: fullRange, options: []) { (attributes, subrange, stop) in
guard let currentFont = attributes[.font] as? UIFont, currentFont.familyName == font.familyName else {
return
}
var replacementFont = newFont
if let fontDescriptor = newFont.fontDescriptor.withSymbolicTraits(currentFont.fontDescriptor.symbolicTraits) {
replacementFont = UIFont(descriptor: fontDescriptor, size: currentFont.pointSize)
}
addAttribute(.font, value: replacementFont, range: subrange)
}
endEditing()
}
}
11 changes: 2 additions & 9 deletions Aztec/Classes/Formatters/Implementations/CodeFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@ class CodeFormatter: AttributeFormatter {

// MARK: - Init

init(monospaceFont: UIFont = UIFont(descriptor:UIFontDescriptor(name: "Courier", size: 12), size:12), backgroundColor: UIColor = UIColor.lightGray) {
let font: UIFont

if #available(iOS 11.0, *) {
font = UIFontMetrics.default.scaledFont(for: monospaceFont)
} else {
font = monospaceFont
}
self.monospaceFont = font
init(monospaceFont: UIFont = FontProvider.shared.monospaceFont, backgroundColor: UIColor = UIColor.lightGray) {
self.monospaceFont = monospaceFont
self.backgroundColor = backgroundColor
self.htmlRepresentationKey = .codeHtmlRepresentation
}
Expand Down
13 changes: 2 additions & 11 deletions Aztec/Classes/Formatters/Implementations/PreFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ open class PreFormatter: ParagraphAttributeFormatter {
///
let placeholderAttributes: [NSAttributedString.Key: Any]?


/// Designated Initializer
///
init(monospaceFont: UIFont = UIFont(descriptor:UIFontDescriptor(name: "Courier", size: 12), size:12), placeholderAttributes: [NSAttributedString.Key : Any]? = nil) {
let font: UIFont

if #available(iOS 11.0, *) {
font = UIFontMetrics.default.scaledFont(for: monospaceFont)
} else {
font = monospaceFont
}

self.monospaceFont = font
init(monospaceFont: UIFont = FontProvider.shared.monospaceFont, placeholderAttributes: [NSAttributedString.Key : Any]? = nil) {
self.monospaceFont = monospaceFont
self.placeholderAttributes = placeholderAttributes
}

Expand Down
13 changes: 3 additions & 10 deletions Aztec/Classes/GUI/FormatBar/FormatBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@ open class FormatBar: UIView {
open override func didMoveToWindow() {
super.didMoveToWindow()

if #available(iOS 11.0, *) {
updateForSafeAreaInsets()
}
updateForSafeAreaInsets()
}

open override func layoutSubviews() {
Expand Down Expand Up @@ -683,13 +681,8 @@ private extension FormatBar {
/// Sets up the Constraints
///
func configureConstraints() {
var leadingAnchor = self.leadingAnchor
var trailingAnchor = self.trailingAnchor

if #available(iOS 11.0, *) {
leadingAnchor = safeAreaLayoutGuide.leadingAnchor
trailingAnchor = safeAreaLayoutGuide.trailingAnchor
}
let leadingAnchor = safeAreaLayoutGuide.leadingAnchor
let trailingAnchor = safeAreaLayoutGuide.trailingAnchor

///Overflow toggle item

Expand Down
1 change: 1 addition & 0 deletions Aztec/Classes/Libxml2/DOM/Data/CSSAttributeType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extension CSSAttributeType {
public static let fontStyle = CSSAttributeType("font-style")
public static let fontWeight = CSSAttributeType("font-weight")
public static let textDecoration = CSSAttributeType("text-decoration")
public static let foregroundColor = CSSAttributeType("color")

}

Expand Down
Loading