Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2.1

orbs:
# This uses the iOS Orb located at https://github.com/wordpress-mobile/circleci-orbs
ios: wordpress-mobile/ios@0.0.36
# Using 1.0 of our Orbs means it will use the latest 1.0.x version from https://github.com/wordpress-mobile/circleci-orbs
ios: wordpress-mobile/ios@1.0

workflows:
test_and_validate:
Expand Down
24 changes: 16 additions & 8 deletions Aztec/Classes/TextKit/LayoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class LayoutManager: NSLayoutManager {

/// Blockquote's Left Border Color
///
var blockquoteBorderColor = UIColor(red: 0.52, green: 0.65, blue: 0.73, alpha: 1.0)
var blockquoteBorderColor: UIColor? = UIColor(red: 0.52, green: 0.65, blue: 0.73, alpha: 1.0)

/// Blockquote's Background Color
///
var blockquoteBackgroundColor = UIColor(red: 0.91, green: 0.94, blue: 0.95, alpha: 1.0)
var blockquoteBackgroundColor: UIColor? = UIColor(red: 0.91, green: 0.94, blue: 0.95, alpha: 1.0)

/// HTML Pre Background Color
///
var preBackgroundColor = UIColor(red: 243.0/255.0, green: 246.0/255.0, blue: 248.0/255.0, alpha: 1.0)
var preBackgroundColor: UIColor? = UIColor(red: 243.0/255.0, green: 246.0/255.0, blue: 248.0/255.0, alpha: 1.0)

/// Closure that is expected to return the TypingAttributes associated to the Extra Line Fragment
///
Expand Down Expand Up @@ -126,12 +126,17 @@ private extension LayoutManager {
/// Draws a single Blockquote Line Fragment, in the specified Rectangle, using a given Graphics Context.
///
private func drawBlockquote(in rect: CGRect, with context: CGContext) {
blockquoteBackgroundColor.setFill()
context.fill(rect)
if let blockquoteBackgroundColor = blockquoteBackgroundColor {
blockquoteBackgroundColor.setFill()
context.fill(rect)

}

let borderRect = CGRect(origin: rect.origin, size: CGSize(width: blockquoteBorderWidth, height: rect.height))
blockquoteBorderColor.setFill()
context.fill(borderRect)
if let blockquoteBorderColor = blockquoteBorderColor {
let borderRect = CGRect(origin: rect.origin, size: CGSize(width: blockquoteBorderWidth, height: rect.height))
blockquoteBorderColor.setFill()
context.fill(borderRect)
}
}
}

Expand Down Expand Up @@ -172,6 +177,9 @@ private extension LayoutManager {
/// Draws a single HTML Pre Line Fragment, in the specified Rectangle, using a given Graphics Context.
///
private func drawHTMLPre(in rect: CGRect, with context: CGContext) {
guard let preBackgroundColor = preBackgroundColor else {
return
}
preBackgroundColor.setFill()
context.fill(rect)
}
Expand Down
14 changes: 11 additions & 3 deletions Aztec/Classes/TextKit/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ open class TextView: UITextView {

/// Blockquote Blocks Border Color.
///
@objc dynamic public var blockquoteBorderColor: UIColor {
@objc dynamic public var blockquoteBorderColor: UIColor? {
get {
return layout.blockquoteBorderColor
}
Expand All @@ -286,7 +286,7 @@ open class TextView: UITextView {

/// Blockquote Blocks Background Color.
///
@objc dynamic public var blockquoteBackgroundColor: UIColor {
@objc dynamic public var blockquoteBackgroundColor: UIColor? {
get {
return layout.blockquoteBackgroundColor
}
Expand All @@ -309,7 +309,7 @@ open class TextView: UITextView {

/// Pre Blocks Background Color.
///
@objc dynamic public var preBackgroundColor: UIColor {
@objc dynamic public var preBackgroundColor: UIColor? {
get {
return layout.preBackgroundColor
}
Expand Down Expand Up @@ -339,6 +339,14 @@ open class TextView: UITextView {
}
}

override open var textAlignment: NSTextAlignment {
didSet {
if (textAlignment != oldValue) {
recalculateTypingAttributes()
}
}
}


/// This property returns the Attributes associated to the Extra Line Fragment.
///
Expand Down
38 changes: 22 additions & 16 deletions Example/Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Xa3-wA-iyT">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15400" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Xa3-wA-iyT">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15404"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -11,16 +12,21 @@
<objects>
<tableViewController id="dLa-XM-tnL" customClass="ViewController" customModule="AztecExample" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="aCg-qL-Bjp">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" systemColor="systemGroupedBackgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" systemColor="systemBlueColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="separatorColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="sectionIndexColor" systemColor="secondaryLabelColor" red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color key="sectionIndexBackgroundColor" systemColor="systemGroupedBackgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="CellIdentifier" id="qo0-pV-osF">
<rect key="frame" x="0.0" y="119.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="55.5" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="qo0-pV-osF" id="8JQ-dS-Cdh">
<frame key="frameInset" width="375" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" cocoaTouchSystemColor="tableCellGroupedBackgroundColor"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
Expand All @@ -44,16 +50,16 @@
<viewControllerLayoutGuide type="bottom" id="ZEP-a0-JgH"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="TWZ-yb-CMI">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="w8z-is-5FM">
<frame key="frameInset" minX="180" minY="236" width="3" height="20"/>
<rect key="frame" x="180" y="236" width="3" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yFc-rm-m3C">
<frame key="frameInset" minX="73" width="600" height="600"/>
<rect key="frame" x="73" y="0.0" width="600" height="600"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<attributedString key="attributedText"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
Expand Down Expand Up @@ -85,11 +91,11 @@
<viewControllerLayoutGuide type="bottom" id="tZp-mZ-BM8"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="pyu-jY-ESw">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yCI-Vs-ZmB">
<frame key="frameInset" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<attributedString key="attributedText"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
Expand Down Expand Up @@ -123,11 +129,11 @@
<viewControllerLayoutGuide type="bottom" id="6EB-tz-iNk"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="sdZ-dG-t9p">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZEK-ad-Hg3">
<frame key="frameInset" minY="20" width="600" height="44"/>
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
<items>
<barButtonItem title="B" id="fPu-Uf-Zs9">
<connections>
Expand Down Expand Up @@ -157,7 +163,7 @@
</items>
</toolbar>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DeM-yw-u6b">
<frame key="frameInset" minY="64" width="600" height="536"/>
<rect key="frame" x="0.0" y="64" width="600" height="536"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<attributedString key="attributedText"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
Expand Down Expand Up @@ -188,7 +194,7 @@
<objects>
<navigationController id="Xa3-wA-iyT" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="JtR-gB-2vV">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand Down
45 changes: 37 additions & 8 deletions Example/Example/EditorDemoController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,24 @@ class EditorDemoController: UIViewController {

edgesForExtendedLayout = UIRectEdge()
navigationController?.navigationBar.isTranslucent = false

view.backgroundColor = .white
view.addSubview(editorView)
view.addSubview(titleTextView)
view.addSubview(titlePlaceholderLabel)
view.addSubview(separatorView)
// color setup
if #available(iOS 13.0, *) {
view.backgroundColor = UIColor.systemBackground
titleTextView.textColor = UIColor.label
editorView.htmlTextView.textColor = UIColor.label
editorView.richTextView.textColor = UIColor.label
editorView.richTextView.blockquoteBackgroundColor = UIColor.secondarySystemBackground
editorView.richTextView.preBackgroundColor = UIColor.secondarySystemBackground
editorView.richTextView.blockquoteBorderColor = UIColor.secondarySystemFill
var attributes = editorView.richTextView.linkTextAttributes
attributes?[.foregroundColor] = UIColor.link
} else {
view.backgroundColor = UIColor.white
}
//Don't allow scroll while the constraints are being setup and text set
editorView.isScrollEnabled = false
configureConstraints()
Expand Down Expand Up @@ -317,7 +329,15 @@ class EditorDemoController: UIViewController {
textView.accessibilityLabel = accessibilityLabel
textView.font = Constants.defaultContentFont
textView.keyboardDismissMode = .interactive
textView.textColor = UIColor(red: 0x1A/255.0, green: 0x1A/255.0, blue: 0x1A/255.0, alpha: 1)
if #available(iOS 13.0, *) {
textView.textColor = UIColor.label
if let htmlStorage = textView.textStorage as? HTMLStorage {
htmlStorage.textColor = UIColor.label
}
} else {
// Fallback on earlier versions
textView.textColor = UIColor(red: 0x1A/255.0, green: 0x1A/255.0, blue: 0x1A/255.0, alpha: 1)
}
textView.linkTextAttributes = [.foregroundColor: UIColor(red: 0x01 / 255.0, green: 0x60 / 255.0, blue: 0x87 / 255.0, alpha: 1), NSAttributedString.Key.underlineStyle: NSNumber(value: NSUnderlineStyle.single.rawValue)]
}

Expand Down Expand Up @@ -940,11 +960,20 @@ extension EditorDemoController {

let toolbar = Aztec.FormatBar()

toolbar.tintColor = .gray
toolbar.highlightedTintColor = .blue
toolbar.selectedTintColor = view.tintColor
toolbar.disabledTintColor = .lightGray
toolbar.dividerTintColor = .gray
if #available(iOS 13.0, *) {
toolbar.backgroundColor = UIColor.systemGroupedBackground
toolbar.tintColor = UIColor.secondaryLabel
toolbar.highlightedTintColor = UIColor.systemBlue
toolbar.selectedTintColor = UIColor.systemBlue
toolbar.disabledTintColor = .systemGray4
toolbar.dividerTintColor = UIColor.separator
} else {
toolbar.tintColor = .gray
toolbar.highlightedTintColor = .blue
toolbar.selectedTintColor = view.tintColor
toolbar.disabledTintColor = .lightGray
toolbar.dividerTintColor = .gray
}

toolbar.overflowToggleIcon = Gridicon.iconOfType(.ellipsis)
toolbar.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 44.0)
Expand Down
17 changes: 4 additions & 13 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ViewController: UITableViewController
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)!
cell.accessoryType = .disclosureIndicator

//cell.backgroundColor = UIColor.
let row = sections[indexPath.section].rows[indexPath.row]
cell.textLabel?.text = row.title

Expand All @@ -87,19 +87,10 @@ class ViewController: UITableViewController
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 40
}

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let textView = UITextView()

textView.font = UIFont.boldSystemFont(ofSize: 14)
textView.textAlignment = .center
textView.isEditable = false
textView.text = sections[section].title
textView.backgroundColor = UIColor.lightGray

return textView
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return sections[section].title
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
Expand Down
2 changes: 1 addition & 1 deletion WordPress-Aztec-iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'WordPress-Aztec-iOS'
s.version = '1.11.0'
s.version = '1.12.0'
s.summary = 'The native HTML Editor.'

# This description is used to generate tags and improve search results.
Expand Down
2 changes: 1 addition & 1 deletion WordPress-Editor-iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'WordPress-Editor-iOS'
s.version = '1.11.0'
s.version = '1.12.0'
s.summary = 'The WordPress HTML Editor.'

# This description is used to generate tags and improve search results.
Expand Down
Loading