Skip to content

Commit 87a1bcb

Browse files
committed
Merge branch develop into fix/more-button-accessibility
2 parents 396045d + c376a3a commit 87a1bcb

15 files changed

Lines changed: 106 additions & 7 deletions

File tree

Aztec.xcodeproj/project.pbxproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
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 */; };
1112
40359F261FD88A5F00B1C1D2 /* HRElementConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40359F251FD88A5F00B1C1D2 /* HRElementConverter.swift */; };
1213
40359F281FD88A7900B1C1D2 /* BRElementConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40359F271FD88A7900B1C1D2 /* BRElementConverter.swift */; };
1314
40A2986D1FD61B0C00AEDF3B /* ElementConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40A2986C1FD61B0C00AEDF3B /* ElementConverter.swift */; };
@@ -281,6 +282,7 @@
281282

282283
/* Begin PBXFileReference section */
283284
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>"; };
284286
40359F251FD88A5F00B1C1D2 /* HRElementConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HRElementConverter.swift; sourceTree = "<group>"; };
285287
40359F271FD88A7900B1C1D2 /* BRElementConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRElementConverter.swift; sourceTree = "<group>"; };
286288
40A2986C1FD61B0C00AEDF3B /* ElementConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElementConverter.swift; sourceTree = "<group>"; };
@@ -551,6 +553,14 @@
551553
/* End PBXFrameworksBuildPhase section */
552554

553555
/* Begin PBXGroup section */
556+
1EDDEBA3239A68090000A957 /* config */ = {
557+
isa = PBXGroup;
558+
children = (
559+
1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */,
560+
);
561+
path = config;
562+
sourceTree = "<group>";
563+
};
554564
40A2986F1FD61B1C00AEDF3B /* Implementations */ = {
555565
isa = PBXGroup;
556566
children = (
@@ -597,6 +607,7 @@
597607
FF5B98E21DC29D0C00571CA4 /* README.md */,
598608
FF7A1C4A1E51F05700C4C7C8 /* CONTRIBUTING.md */,
599609
FFC2BBF81F2A25CF00E404FB /* CHANGELOG.md */,
610+
1EDDEBA3239A68090000A957 /* config */,
600611
5951CB901D8BC93600E1866F /* Aztec */,
601612
5951CB9B1D8BC93600E1866F /* AztecTests */,
602613
599F255A1D8BCD97002871D6 /* Frameworks */,
@@ -1492,6 +1503,7 @@
14921503
isa = PBXResourcesBuildPhase;
14931504
buildActionMask = 2147483647;
14941505
files = (
1506+
1EDDEBA5239A68320000A957 /* XCodeVersion.xcconfig in Resources */,
14951507
FF1F56A3239562B900E93A30 /* html_colors.json in Resources */,
14961508
FF0714021EFD78AF00E50713 /* Media.xcassets in Resources */,
14971509
);
@@ -1901,6 +1913,7 @@
19011913
};
19021914
5951CBA31D8BC93600E1866F /* Debug */ = {
19031915
isa = XCBuildConfiguration;
1916+
baseConfigurationReference = 1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */;
19041917
buildSettings = {
19051918
CLANG_ENABLE_MODULES = YES;
19061919
CODE_SIGN_IDENTITY = "";

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/TextKit/ColorProvider.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ public class ColorProvider {
4646
}
4747

4848
public lazy var codeBackgroungColor: UIColor = {
49+
#if XCODE11
4950
if #available(iOS 13.0, *) {
5051
return .secondarySystemBackground
5152
} else {
5253
return .lightGray
5354
}
55+
#endif
56+
return .lightGray
5457
}()
5558
}

Aztec/Classes/TextKit/MediaAttachment.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@ open class MediaAttachment: NSTextAttachment {
186186
needsNewAsset = refreshAsset
187187
}
188188

189+
/// Invalidates the attachment and forces an update of the attachment image
190+
open func refresh() {
191+
needsNewAsset = true
192+
retryCount = 0
193+
image = nil
194+
glyphImage = nil
195+
}
196+
189197
/// Refresh attachment identifier
190198
///
191199
/// - Parameter identifier: new identifier

Aztec/Classes/TextKit/TextView.swift

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,27 @@ open class TextView: UITextView {
249249
}
250250

251251
open lazy var defaultTextColor: UIColor? = {
252+
#if XCODE11
252253
if #available(iOS 13.0, *) {
253254
return UIColor.label
254255
} else {
255256
return UIColor.darkText
256-
}
257+
}
258+
#endif
259+
return UIColor.darkText
257260
}()
258261

262+
open override var textColor: UIColor? {
263+
set {
264+
super.textColor = newValue
265+
defaultTextColor = newValue
266+
}
267+
268+
get {
269+
return super.textColor
270+
}
271+
}
272+
259273
// MARK: - Plugin Loading
260274

261275
var pluginManager: PluginManager {
@@ -303,7 +317,13 @@ open class TextView: UITextView {
303317
}
304318
}
305319

306-
320+
public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
321+
if #available(iOS 13.0, *) {
322+
if let previous = previousTraitCollection, previous.hasDifferentColorAppearance(comparedTo: traitCollection) {
323+
self.refreshMediaAttachments()
324+
}
325+
}
326+
}
307327
/// Blockquote Blocks Background Width.
308328
///
309329
@objc dynamic public var blockquoteBorderWidth: CGFloat {
@@ -1383,6 +1403,14 @@ open class TextView: UITextView {
13831403
notifyTextViewDidChange()
13841404
}
13851405

1406+
/// Forces a Refresh of all media attachment in the text view
1407+
open func refreshMediaAttachments() {
1408+
storage.enumerateAttachmentsOfType(MediaAttachment.self) { (attachment, range, _) in
1409+
attachment.refresh()
1410+
self.refresh(attachment, overlayUpdateOnly: false)
1411+
}
1412+
}
1413+
13861414
/// Replaces a Video attachment at the specified range
13871415
///
13881416
/// - Parameters:

Aztec/Classes/TextKit/TextViewPasteboardDelegate.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ open class AztecTextViewPasteboardDelegate: TextViewPasteboardDelegate {
8181
}
8282

8383
private func fixColors(in string: NSAttributedString, using baseColor: UIColor?) -> NSAttributedString {
84+
#if XCODE11
8485
guard #available(iOS 13.0, *) else {
8586
return string
8687
}
88+
8789
let colorToUse = baseColor ?? UIColor.label
8890

8991
let newString = NSMutableAttributedString(attributedString: string)
@@ -93,6 +95,9 @@ open class AztecTextViewPasteboardDelegate: TextViewPasteboardDelegate {
9395
}
9496
}
9597
return newString
98+
#else
99+
return string
100+
#endif
96101
}
97102

98103
/// Tries to paste raw text from the clipboard, replacing the selected range.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.14.1
2+
-----
3+
* Support for xcode 10.
4+
15
1.14.0
26
-----
37
* Support standard HTML colors by name.

Example/AztecExample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
F1D3610B20929F0200B4E7A5 /* WordPressEditor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1D3610420929E6D00B4E7A5 /* WordPressEditor.framework */; };
4040
FF149F4A20E3C49A0070FECB /* imagesOverlays.html in Resources */ = {isa = PBXBuildFile; fileRef = FF149F4920E3C49A0070FECB /* imagesOverlays.html */; };
4141
FF1FD05C20932EDE00186384 /* gutenberg.html in Resources */ = {isa = PBXBuildFile; fileRef = FF1FD05B20932EDE00186384 /* gutenberg.html */; };
42+
FF5CDACD239E78B200CF235B /* failedMedia.html in Resources */ = {isa = PBXBuildFile; fileRef = FF5CDACC239E78B200CF235B /* failedMedia.html */; };
4243
FF629DC9223BC418004C4106 /* videoShortcodes.html in Resources */ = {isa = PBXBuildFile; fileRef = FF629DC8223BC418004C4106 /* videoShortcodes.html */; };
4344
FF9AF5481DB0E4E200C42ED3 /* AttachmentDetailsViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FF9AF5471DB0E4E200C42ED3 /* AttachmentDetailsViewController.storyboard */; };
4445
FFC41BDE20DBC7BA004DFB4D /* video.html in Resources */ = {isa = PBXBuildFile; fileRef = FFC41BDD20DBC7BA004DFB4D /* video.html */; };
@@ -155,6 +156,7 @@
155156
F1D360FC20929E6D00B4E7A5 /* WordPressEditor.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = WordPressEditor.xcodeproj; path = ../WordPressEditor/WordPressEditor.xcodeproj; sourceTree = "<group>"; };
156157
FF149F4920E3C49A0070FECB /* imagesOverlays.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = imagesOverlays.html; sourceTree = "<group>"; };
157158
FF1FD05B20932EDE00186384 /* gutenberg.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = gutenberg.html; sourceTree = "<group>"; };
159+
FF5CDACC239E78B200CF235B /* failedMedia.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = failedMedia.html; sourceTree = "<group>"; };
158160
FF629DC8223BC418004C4106 /* videoShortcodes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = videoShortcodes.html; sourceTree = "<group>"; };
159161
FF9AF5471DB0E4E200C42ED3 /* AttachmentDetailsViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = AttachmentDetailsViewController.storyboard; sourceTree = "<group>"; };
160162
FFC41BDD20DBC7BA004DFB4D /* video.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = video.html; sourceTree = "<group>"; };
@@ -202,6 +204,7 @@
202204
FF1FD05B20932EDE00186384 /* gutenberg.html */,
203205
FFC41BDD20DBC7BA004DFB4D /* video.html */,
204206
FF629DC8223BC418004C4106 /* videoShortcodes.html */,
207+
FF5CDACC239E78B200CF235B /* failedMedia.html */,
205208
);
206209
path = SampleContent;
207210
sourceTree = "<group>";
@@ -443,6 +446,7 @@
443446
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */,
444447
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */,
445448
59280F2A1D47CAF40083FB59 /* content.html in Resources */,
449+
FF5CDACD239E78B200CF235B /* failedMedia.html in Resources */,
446450
B5FB212A1FEC38470067D597 /* captions.html in Resources */,
447451
FF1FD05C20932EDE00186384 /* gutenberg.html in Resources */,
448452
59280F2B1D47CAF40083FB59 /* SampleText.rtf in Resources */,

Example/Example/EditorDemoController.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,7 @@ extension EditorDemoController {
10551055

10561056
}
10571057

1058+
// MARK: - TextViewAttachmentDelegate
10581059

10591060
extension EditorDemoController: TextViewAttachmentDelegate {
10601061

@@ -1087,7 +1088,7 @@ extension EditorDemoController: TextViewAttachmentDelegate {
10871088

10881089
func placeholderImage(for attachment: NSTextAttachment) -> UIImage {
10891090
let imageSize = CGSize(width:64, height:64)
1090-
let placeholderImage: UIImage
1091+
var placeholderImage: UIImage
10911092
switch attachment {
10921093
case _ as ImageAttachment:
10931094
placeholderImage = Gridicon.iconOfType(.image, withSize: imageSize)
@@ -1096,7 +1097,9 @@ extension EditorDemoController: TextViewAttachmentDelegate {
10961097
default:
10971098
placeholderImage = Gridicon.iconOfType(.attachment, withSize: imageSize)
10981099
}
1099-
1100+
if #available(iOS 13.0, *) {
1101+
placeholderImage = placeholderImage.withTintColor(.label)
1102+
}
11001103
return placeholderImage
11011104
}
11021105

@@ -1501,10 +1504,19 @@ private extension EditorDemoController
15011504

15021505
extension EditorDemoController {
15031506

1507+
static var tintedMissingImage: UIImage = {
1508+
if #available(iOS 13.0, *) {
1509+
return Gridicon.iconOfType(.image).withTintColor(.label)
1510+
} else {
1511+
// Fallback on earlier versions
1512+
return Gridicon.iconOfType(.image)
1513+
}
1514+
}()
1515+
15041516
struct Constants {
15051517
static let defaultContentFont = UIFont.systemFont(ofSize: 14)
15061518
static let defaultHtmlFont = UIFont.systemFont(ofSize: 24)
1507-
static let defaultMissingImage = Gridicon.iconOfType(.image)
1519+
static let defaultMissingImage = tintedMissingImage
15081520
static let formatBarIconSize = CGSize(width: 20.0, height: 20.0)
15091521
static let headers = [Header.HeaderType.none, .h1, .h2, .h3, .h4, .h5, .h6]
15101522
static let lists = [TextList.Style.unordered, .ordered]

0 commit comments

Comments
 (0)