Skip to content

Commit 48e6bcc

Browse files
Merge pull request #1263 from wordpress-mobile/release/1.15.0
Prepare Release 1.15.0
2 parents 363a303 + b556546 commit 48e6bcc

36 files changed

Lines changed: 945 additions & 630 deletions

Aztec.xcodeproj/project.pbxproj

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/* Begin PBXBuildFile section */
1010
1A830346228583B200798076 /* NSBundle+AztecBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A830345228583B200798076 /* NSBundle+AztecBundle.swift */; };
11-
1EDDEBA5239A68320000A957 /* XCodeVersion.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */; };
1211
40359F261FD88A5F00B1C1D2 /* HRElementConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40359F251FD88A5F00B1C1D2 /* HRElementConverter.swift */; };
1312
40359F281FD88A7900B1C1D2 /* BRElementConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40359F271FD88A7900B1C1D2 /* BRElementConverter.swift */; };
1413
40A2986D1FD61B0C00AEDF3B /* ElementConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40A2986C1FD61B0C00AEDF3B /* ElementConverter.swift */; };
@@ -36,7 +35,7 @@
3635
599F25531D8BC9A1002871D6 /* TextStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 599F25311D8BC9A1002871D6 /* TextStorage.swift */; };
3736
599F25541D8BC9A1002871D6 /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 599F25321D8BC9A1002871D6 /* TextView.swift */; };
3837
74EEC71B1FAB6EC900B989E3 /* UIImage+Resize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74EEC71A1FAB6EC900B989E3 /* UIImage+Resize.swift */; };
39-
914CD9E72200B2D200DDD5C9 /* BoldFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914CD9E62200B2D200DDD5C9 /* BoldFormatter.swift */; };
38+
914CD9E72200B2D200DDD5C9 /* BoldWithShadowForHeadingFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914CD9E62200B2D200DDD5C9 /* BoldWithShadowForHeadingFormatter.swift */; };
4039
917E22132201D2A5008AC826 /* BoldFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 917E22122201D2A5008AC826 /* BoldFormatterTests.swift */; };
4140
B52220D31F86A05400D7E092 /* TextViewStubDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52220D21F86A05400D7E092 /* TextViewStubDelegate.swift */; };
4241
B524228D1F30C039002E7C6C /* HTMLDiv.swift in Sources */ = {isa = PBXBuildFile; fileRef = B524228C1F30C039002E7C6C /* HTMLDiv.swift */; };
@@ -247,6 +246,8 @@
247246
FFD3C1712344DB4E00AE8DA0 /* ForegroundColorCSSAttributeMatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD3C1702344DB4E00AE8DA0 /* ForegroundColorCSSAttributeMatcher.swift */; };
248247
FFD3C1732344DCA900AE8DA0 /* ForegroundColorElementAttributeConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD3C1722344DCA900AE8DA0 /* ForegroundColorElementAttributeConverter.swift */; };
249248
FFD436981E3180A500A0E26F /* FontFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFD436971E3180A500A0E26F /* FontFormatterTests.swift */; };
249+
FFFA53E523C6277700829A43 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFFA53E423C6277700829A43 /* Configuration.swift */; };
250+
FFFA53E723C628E700829A43 /* BoldFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFFA53E623C628E700829A43 /* BoldFormatter.swift */; };
250251
FFFEC7DB1EA7698900F4210F /* VideoAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFFEC7DA1EA7698900F4210F /* VideoAttachment.swift */; };
251252
/* End PBXBuildFile section */
252253

@@ -282,7 +283,6 @@
282283

283284
/* Begin PBXFileReference section */
284285
1A830345228583B200798076 /* NSBundle+AztecBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSBundle+AztecBundle.swift"; sourceTree = "<group>"; };
285-
1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = XCodeVersion.xcconfig; sourceTree = "<group>"; };
286286
40359F251FD88A5F00B1C1D2 /* HRElementConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HRElementConverter.swift; sourceTree = "<group>"; };
287287
40359F271FD88A7900B1C1D2 /* BRElementConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRElementConverter.swift; sourceTree = "<group>"; };
288288
40A2986C1FD61B0C00AEDF3B /* ElementConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElementConverter.swift; sourceTree = "<group>"; };
@@ -312,7 +312,7 @@
312312
59FEA06B1D8BDFA700D138DF /* InAttributeConverterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InAttributeConverterTests.swift; sourceTree = "<group>"; };
313313
59FEA06D1D8BDFA700D138DF /* InNodeConverterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InNodeConverterTests.swift; sourceTree = "<group>"; };
314314
74EEC71A1FAB6EC900B989E3 /* UIImage+Resize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Resize.swift"; sourceTree = "<group>"; };
315-
914CD9E62200B2D200DDD5C9 /* BoldFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoldFormatter.swift; sourceTree = "<group>"; };
315+
914CD9E62200B2D200DDD5C9 /* BoldWithShadowForHeadingFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoldWithShadowForHeadingFormatter.swift; sourceTree = "<group>"; };
316316
917E22122201D2A5008AC826 /* BoldFormatterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoldFormatterTests.swift; sourceTree = "<group>"; };
317317
B52220D21F86A05400D7E092 /* TextViewStubDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextViewStubDelegate.swift; sourceTree = "<group>"; };
318318
B524228C1F30C039002E7C6C /* HTMLDiv.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTMLDiv.swift; sourceTree = "<group>"; };
@@ -531,6 +531,8 @@
531531
FFD3C1702344DB4E00AE8DA0 /* ForegroundColorCSSAttributeMatcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForegroundColorCSSAttributeMatcher.swift; sourceTree = "<group>"; };
532532
FFD3C1722344DCA900AE8DA0 /* ForegroundColorElementAttributeConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForegroundColorElementAttributeConverter.swift; sourceTree = "<group>"; };
533533
FFD436971E3180A500A0E26F /* FontFormatterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FontFormatterTests.swift; sourceTree = "<group>"; };
534+
FFFA53E423C6277700829A43 /* Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
535+
FFFA53E623C628E700829A43 /* BoldFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoldFormatter.swift; sourceTree = "<group>"; };
534536
FFFEC7DA1EA7698900F4210F /* VideoAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoAttachment.swift; sourceTree = "<group>"; };
535537
/* End PBXFileReference section */
536538

@@ -553,14 +555,6 @@
553555
/* End PBXFrameworksBuildPhase section */
554556

555557
/* Begin PBXGroup section */
556-
1EDDEBA3239A68090000A957 /* config */ = {
557-
isa = PBXGroup;
558-
children = (
559-
1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */,
560-
);
561-
path = config;
562-
sourceTree = "<group>";
563-
};
564558
40A2986F1FD61B1C00AEDF3B /* Implementations */ = {
565559
isa = PBXGroup;
566560
children = (
@@ -607,7 +601,6 @@
607601
FF5B98E21DC29D0C00571CA4 /* README.md */,
608602
FF7A1C4A1E51F05700C4C7C8 /* CONTRIBUTING.md */,
609603
FFC2BBF81F2A25CF00E404FB /* CHANGELOG.md */,
610-
1EDDEBA3239A68090000A957 /* config */,
611604
5951CB901D8BC93600E1866F /* Aztec */,
612605
5951CB9B1D8BC93600E1866F /* AztecTests */,
613606
599F255A1D8BCD97002871D6 /* Frameworks */,
@@ -826,6 +819,7 @@
826819
F9982CF521877663001E606B /* TextViewPasteboardDelegate.swift */,
827820
FF7EAEC3234D253B007A26E0 /* FontProvider.swift */,
828821
FF1F56A023955EF600E93A30 /* ColorProvider.swift */,
822+
FFFA53E423C6277700829A43 /* Configuration.swift */,
829823
);
830824
path = TextKit;
831825
sourceTree = "<group>";
@@ -995,14 +989,15 @@
995989
isa = PBXGroup;
996990
children = (
997991
F12F58561EF20394008AE298 /* BlockquoteFormatter.swift */,
998-
914CD9E62200B2D200DDD5C9 /* BoldFormatter.swift */,
992+
914CD9E62200B2D200DDD5C9 /* BoldWithShadowForHeadingFormatter.swift */,
999993
F1BDDDE420603C18000714E1 /* FigcaptionFormatter.swift */,
1000994
F1BDDDE62060403B000714E1 /* FigureFormatter.swift */,
1001995
F12F58571EF20394008AE298 /* ColorFormatter.swift */,
1002996
F12F58591EF20394008AE298 /* HeaderFormatter.swift */,
1003997
B524228E1F30C098002E7C6C /* HTMLDivFormatter.swift */,
1004998
F12F585B1EF20394008AE298 /* HTMLParagraphFormatter.swift */,
1005999
F18986E41EF2043E0060EDBA /* ItalicFormatter.swift */,
1000+
FFFA53E623C628E700829A43 /* BoldFormatter.swift */,
10061001
F12F585D1EF20394008AE298 /* LinkFormatter.swift */,
10071002
F12F585E1EF20394008AE298 /* PreFormatter.swift */,
10081003
FF437B6520D7CB83000D9666 /* LiFormatter.swift */,
@@ -1503,7 +1498,6 @@
15031498
isa = PBXResourcesBuildPhase;
15041499
buildActionMask = 2147483647;
15051500
files = (
1506-
1EDDEBA5239A68320000A957 /* XCodeVersion.xcconfig in Resources */,
15071501
FF1F56A3239562B900E93A30 /* html_colors.json in Resources */,
15081502
FF0714021EFD78AF00E50713 /* Media.xcassets in Resources */,
15091503
);
@@ -1561,7 +1555,7 @@
15611555
599F254B1D8BC9A1002871D6 /* String+RangeConversion.swift in Sources */,
15621556
FF1F56A123955EF600E93A30 /* ColorProvider.swift in Sources */,
15631557
599F25481D8BC9A1002871D6 /* Metrics.swift in Sources */,
1564-
914CD9E72200B2D200DDD5C9 /* BoldFormatter.swift in Sources */,
1558+
914CD9E72200B2D200DDD5C9 /* BoldWithShadowForHeadingFormatter.swift in Sources */,
15651559
F1BDDDE72060403B000714E1 /* FigureFormatter.swift in Sources */,
15661560
B59C9F9F1DF74BB80073B1D6 /* UIFont+Traits.swift in Sources */,
15671561
F10BE61A1EA7AE9D002E4625 /* NSAttributedString+ReplaceOcurrences.swift in Sources */,
@@ -1589,6 +1583,7 @@
15891583
F18A1EBA21C0828700F1AA9E /* PluginInputCustomizer.swift in Sources */,
15901584
F15BA60F21515C0F00424120 /* UnderlineStringAttributeConverter.swift in Sources */,
15911585
F18B81ED1EA560B700885F43 /* StringUTF16+RangeConversion.swift in Sources */,
1586+
FFFA53E723C628E700829A43 /* BoldFormatter.swift in Sources */,
15921587
F16A2AD520CC437E00BF3A0A /* LineAttachmentToElementConverter.swift in Sources */,
15931588
B574F4A41FB0CF3B0048F355 /* NSAttributedStringKey+Conversion.swift in Sources */,
15941589
F12F58631EF20394008AE298 /* AttributeFormatter.swift in Sources */,
@@ -1668,6 +1663,7 @@
16681663
F13E8AD820B71BAA007C9F8A /* PluginManager.swift in Sources */,
16691664
FF48CAC8234DD5D3007FFC79 /* NSMutableAttributedString+ReplaceAttributes.swift in Sources */,
16701665
F12F586E1EF20394008AE298 /* LinkFormatter.swift in Sources */,
1666+
FFFA53E523C6277700829A43 /* Configuration.swift in Sources */,
16711667
F1584796203C9B4C00EE05A1 /* NSMutableAttributedString+ParagraphProperty.swift in Sources */,
16721668
F15BA6092151501300424120 /* BoldStringAttributeConverter.swift in Sources */,
16731669
F1AFD65820B45E5700CB0279 /* CommentAttachmentRenderer.swift in Sources */,
@@ -1913,12 +1909,11 @@
19131909
};
19141910
5951CBA31D8BC93600E1866F /* Debug */ = {
19151911
isa = XCBuildConfiguration;
1916-
baseConfigurationReference = 1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */;
19171912
buildSettings = {
19181913
CLANG_ENABLE_MODULES = YES;
19191914
CODE_SIGN_IDENTITY = "";
19201915
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
1921-
CURRENT_PROJECT_VERSION = "1.0.0-beta.18";
1916+
CURRENT_PROJECT_VERSION = 1.15.0;
19221917
DEFINES_MODULE = YES;
19231918
DEVELOPMENT_TEAM = PZYM8XX95Q;
19241919
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -1932,6 +1927,7 @@
19321927
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
19331928
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
19341929
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1930+
MARKETING_VERSION = 1.15.0;
19351931
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
19361932
PRODUCT_NAME = "$(TARGET_NAME)";
19371933
SKIP_INSTALL = YES;
@@ -1948,7 +1944,7 @@
19481944
CLANG_ENABLE_MODULES = YES;
19491945
CODE_SIGN_IDENTITY = "";
19501946
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
1951-
CURRENT_PROJECT_VERSION = "1.0.0-beta.18";
1947+
CURRENT_PROJECT_VERSION = 1.15.0;
19521948
DEFINES_MODULE = YES;
19531949
DEVELOPMENT_TEAM = PZYM8XX95Q;
19541950
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -1962,6 +1958,7 @@
19621958
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
19631959
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
19641960
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1961+
MARKETING_VERSION = 1.15.0;
19651962
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
19661963
PRODUCT_NAME = "$(TARGET_NAME)";
19671964
SKIP_INSTALL = YES;
@@ -2122,7 +2119,7 @@
21222119
CLANG_ENABLE_MODULES = YES;
21232120
CODE_SIGN_IDENTITY = "";
21242121
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
2125-
CURRENT_PROJECT_VERSION = "1.0.0-beta.18";
2122+
CURRENT_PROJECT_VERSION = 1.15.0;
21262123
DEFINES_MODULE = YES;
21272124
DEVELOPMENT_TEAM = PZYM8XX95Q;
21282125
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -2136,6 +2133,7 @@
21362133
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
21372134
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
21382135
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2136+
MARKETING_VERSION = 1.15.0;
21392137
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
21402138
PRODUCT_NAME = "$(TARGET_NAME)";
21412139
SKIP_INSTALL = YES;
@@ -2236,7 +2234,7 @@
22362234
CLANG_ENABLE_MODULES = YES;
22372235
CODE_SIGN_IDENTITY = "";
22382236
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
2239-
CURRENT_PROJECT_VERSION = "1.0.0-beta.18";
2237+
CURRENT_PROJECT_VERSION = 1.15.0;
22402238
DEFINES_MODULE = YES;
22412239
DEVELOPMENT_TEAM = 99KV9Z6BKV;
22422240
DYLIB_COMPATIBILITY_VERSION = 1;
@@ -2250,6 +2248,7 @@
22502248
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
22512249
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
22522250
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2251+
MARKETING_VERSION = 1.15.0;
22532252
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
22542253
PRODUCT_NAME = "$(TARGET_NAME)";
22552254
SKIP_INSTALL = YES;

Aztec/Assets/Media.xcassets/image.imageset/Contents.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
{
44
"idiom" : "universal",
55
"filename" : "gridicons-image.pdf"
6+
},
7+
{
8+
"idiom" : "universal",
9+
"filename" : "gridicons-image-dark.pdf",
10+
"appearances" : [
11+
{
12+
"appearance" : "luminosity",
13+
"value" : "dark"
14+
}
15+
]
616
}
717
],
818
"info" : {
Binary file not shown.

Aztec/Classes/Converters/ElementsToAttributedString/Implementations/GenericElementConverter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class GenericElementConverter: ElementConverter {
1515

1616
// MARK: - Built-in formatter instances
1717

18-
lazy var blockquoteFormatter = BlockquoteFormatter()
19-
lazy var boldFormatter = BoldFormatter()
18+
lazy var blockquoteFormatter = BlockquoteFormatter(increaseDepth: true)
19+
lazy var boldFormatter = Configuration.defaultBoldFormatter
2020
lazy var divFormatter = HTMLDivFormatter()
2121
lazy var h1Formatter = HeaderFormatter(headerLevel: .h1)
2222
lazy var h2Formatter = HeaderFormatter(headerLevel: .h2)

Aztec/Classes/Converters/StringAttributesToAttributes/Implementations/BoldStringAttributeConverter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ open class BoldStringAttributeConverter: StringAttributeConverter {
3232
// MARK: - Style Detection
3333

3434
func shouldEnableBoldElement(for attributes: [NSAttributedString.Key: Any]) -> Bool {
35-
if isHeading(for: attributes) {
35+
if isHeading(for: attributes) && Configuration.headersWithBoldTrait {
3636
// If this is a heading then shadow represents bold elements since
3737
// headings are bold by default
3838
return hasShadowTrait(for: attributes)

Aztec/Classes/Formatters/Base/ParagraphAttributeFormatter.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ extension ParagraphAttributeFormatter {
3737
let rangeToApply = applicationRange(for: range, in: text)
3838

3939
text.replaceOcurrences(of: String(.paragraphSeparator), with: String(.lineFeed), within: rangeToApply)
40-
41-
text.enumerateAttributes(in: rangeToApply, options: []) { (attributes, range, stop) in
42-
let currentAttributes = text.attributes(at: range.location, effectiveRange: nil)
40+
// We copy the string that gets update to avoid that removal of paragraph attributes, like NSParagraphStyle,
41+
// on a certain range affect all the paragraph and have side effects on the remaining removal
42+
let updatedText = text.mutableCopy() as! NSMutableAttributedString
43+
text.enumerateAttributes(in: rangeToApply, options: []) { (currentAttributes, range, stop) in
4344
let attributes = remove(from: currentAttributes)
44-
45-
text.setAttributes(attributes, range: range)
45+
updatedText.setAttributes(attributes, range: range)
4646
}
47-
47+
text.replaceCharacters(in: rangeToApply, with: updatedText.attributedSubstring(from: rangeToApply))
4848
return rangeToApply
4949
}
5050
}

Aztec/Classes/Formatters/Implementations/BlockquoteFormatter.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ class BlockquoteFormatter: ParagraphAttributeFormatter {
1010
///
1111
let placeholderAttributes: [NSAttributedString.Key: Any]?
1212

13+
/// Tells if the formatter is increasing the depth of a list or simple changing the current one if any
14+
let increaseDepth: Bool
15+
1316

1417
/// Designated Initializer
1518
///
16-
init(placeholderAttributes: [NSAttributedString.Key: Any]? = nil) {
19+
init(placeholderAttributes: [NSAttributedString.Key: Any]? = nil, increaseDepth: Bool = false) {
1720
self.placeholderAttributes = placeholderAttributes
21+
self.increaseDepth = increaseDepth
1822
}
1923

2024

@@ -26,11 +30,18 @@ class BlockquoteFormatter: ParagraphAttributeFormatter {
2630
if let paragraphStyle = attributes[.paragraphStyle] as? NSParagraphStyle {
2731
newParagraphStyle.setParagraphStyle(paragraphStyle)
2832
}
29-
30-
newParagraphStyle.appendProperty(Blockquote(with: representation))
33+
34+
let newQuote = Blockquote(with: representation)
35+
36+
if newParagraphStyle.blockquotes.isEmpty || increaseDepth {
37+
newParagraphStyle.insertProperty(newQuote, afterLastOfType: Blockquote.self)
38+
} else {
39+
newParagraphStyle.replaceProperty(ofType: Blockquote.self, with: newQuote)
40+
}
3141

3242
var resultingAttributes = attributes
3343
resultingAttributes[.paragraphStyle] = newParagraphStyle
44+
3445
return resultingAttributes
3546
}
3647

@@ -47,6 +58,7 @@ class BlockquoteFormatter: ParagraphAttributeFormatter {
4758

4859
var resultingAttributes = attributes
4960
resultingAttributes[.paragraphStyle] = newParagraphStyle
61+
5062
return resultingAttributes
5163
}
5264

@@ -56,4 +68,9 @@ class BlockquoteFormatter: ParagraphAttributeFormatter {
5668
}
5769
return !style.blockquotes.isEmpty
5870
}
71+
72+
static func blockquotes(in attributes: [NSAttributedString.Key: Any]) -> [Blockquote] {
73+
let style = attributes[.paragraphStyle] as? ParagraphStyle
74+
return style?.blockquotes ?? []
75+
}
5976
}

0 commit comments

Comments
 (0)