diff --git a/Components/Sources/Components/Assets.xcassets/editor/clear.imageset/Contents.json b/Components/Sources/Components/Assets.xcassets/editor/clear.imageset/Contents.json deleted file mode 100644 index 1bf1acc8577..00000000000 --- a/Components/Sources/Components/Assets.xcassets/editor/clear.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "clear.pdf", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "template" - } -} diff --git a/Components/Sources/Components/Assets.xcassets/editor/clear.imageset/clear.pdf b/Components/Sources/Components/Assets.xcassets/editor/clear.imageset/clear.pdf deleted file mode 100644 index 561d583a832..00000000000 Binary files a/Components/Sources/Components/Assets.xcassets/editor/clear.imageset/clear.pdf and /dev/null differ diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Expanding/WKEditorToolbarExpandingView.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Expanding/WKEditorToolbarExpandingView.swift index 900041210cf..2e44efbe64c 100644 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Expanding/WKEditorToolbarExpandingView.swift +++ b/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Expanding/WKEditorToolbarExpandingView.swift @@ -3,7 +3,6 @@ import UIKit protocol WKEditorToolbarExpandingViewDelegate: AnyObject { func toolbarExpandingViewDidTapFind(toolbarView: WKEditorToolbarExpandingView) func toolbarExpandingViewDidTapFormatText(toolbarView: WKEditorToolbarExpandingView) - func toolbarExpandingViewDidTapFormatHeading(toolbarView: WKEditorToolbarExpandingView) func toolbarExpandingViewDidTapTemplate(toolbarView: WKEditorToolbarExpandingView, isSelected: Bool) func toolbarExpandingViewDidTapUnorderedList(toolbarView: WKEditorToolbarExpandingView, isSelected: Bool) func toolbarExpandingViewDidTapOrderedList(toolbarView: WKEditorToolbarExpandingView, isSelected: Bool) @@ -44,7 +43,6 @@ class WKEditorToolbarExpandingView: WKEditorToolbarView { @IBOutlet weak var secondaryContainerView: UIView! @IBOutlet private weak var formatTextButton: WKEditorToolbarButton! - @IBOutlet private weak var formatHeadingButton: WKEditorToolbarButton! @IBOutlet private weak var citationButton: WKEditorToolbarButton! @IBOutlet private weak var linkButton: WKEditorToolbarButton! @IBOutlet private weak var templateButton: WKEditorToolbarButton! @@ -86,11 +84,6 @@ class WKEditorToolbarExpandingView: WKEditorToolbarView { formatTextButton.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.formatTextButton formatTextButton.accessibilityLabel = WKSourceEditorLocalizedStrings.current.accessibilityLabelButtonFormatText - formatHeadingButton.setImage(WKIcon.formatHeading, for: .normal) - formatHeadingButton.addTarget(self, action: #selector(tappedFormatHeading), for: .touchUpInside) - formatHeadingButton.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.formatHeadingButton - formatHeadingButton.accessibilityLabel = WKSourceEditorLocalizedStrings.current.accessibilityLabelButtonFormatHeading - citationButton.setImage(WKSFSymbolIcon.for(symbol: .quoteOpening), for: .normal) citationButton.addTarget(self, action: #selector(tappedCitation), for: .touchUpInside) citationButton.accessibilityLabel = WKSourceEditorLocalizedStrings.current.accessibilityLabelButtonCitation @@ -224,7 +217,6 @@ class WKEditorToolbarExpandingView: WKEditorToolbarView { } @objc private func tappedFormatHeading() { - delegate?.toolbarExpandingViewDidTapFormatHeading(toolbarView: self) } @objc private func tappedCitation() { diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Expanding/WKEditorToolbarExpandingView.xib b/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Expanding/WKEditorToolbarExpandingView.xib index a303c68443c..4cc6c4a20fd 100644 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Expanding/WKEditorToolbarExpandingView.xib +++ b/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Expanding/WKEditorToolbarExpandingView.xib @@ -1,9 +1,9 @@ - + - + @@ -35,31 +35,27 @@ - - - - - + - + - + - + - + - + @@ -279,13 +275,12 @@ - - + @@ -296,7 +291,6 @@ - diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Highlight/WKEditorToolbarHighlightView.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Highlight/WKEditorToolbarHighlightView.swift index 7003ab32d0c..4dde0cacc3e 100644 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Highlight/WKEditorToolbarHighlightView.swift +++ b/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Highlight/WKEditorToolbarHighlightView.swift @@ -5,7 +5,6 @@ protocol WKEditorToolbarHighlightViewDelegate: AnyObject { func toolbarHighlightViewDidTapItalics(toolbarView: WKEditorToolbarHighlightView, isSelected: Bool) func toolbarHighlightViewDidTapTemplate(toolbarView: WKEditorToolbarHighlightView, isSelected: Bool) func toolbarHighlightViewDidTapShowMore(toolbarView: WKEditorToolbarHighlightView) - func toolbarHighlightViewDidTapFormatHeading(toolbarView: WKEditorToolbarHighlightView) } class WKEditorToolbarHighlightView: WKEditorToolbarView { @@ -16,11 +15,9 @@ class WKEditorToolbarHighlightView: WKEditorToolbarView { @IBOutlet private weak var boldButton: WKEditorToolbarButton! @IBOutlet private weak var italicsButton: WKEditorToolbarButton! - @IBOutlet private weak var formatHeadingButton: WKEditorToolbarButton! @IBOutlet private weak var citationButton: WKEditorToolbarButton! @IBOutlet private weak var linkButton: WKEditorToolbarButton! @IBOutlet private weak var templateButton: WKEditorToolbarButton! - @IBOutlet private weak var clearMarkupButton: WKEditorToolbarButton! @IBOutlet private weak var showMoreButton: WKEditorToolbarNavigatorButton! weak var delegate: WKEditorToolbarHighlightViewDelegate? @@ -41,11 +38,6 @@ class WKEditorToolbarHighlightView: WKEditorToolbarView { italicsButton.addTarget(self, action: #selector(tappedItalics), for: .touchUpInside) italicsButton.accessibilityLabel = WKSourceEditorLocalizedStrings.current?.accessibilityLabelButtonItalics - formatHeadingButton.setImage(WKIcon.formatHeading, for: .normal) - formatHeadingButton.addTarget(self, action: #selector(tappedFormatHeading), for: .touchUpInside) - formatHeadingButton.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.formatHeadingButton - formatHeadingButton.accessibilityLabel = WKSourceEditorLocalizedStrings.current?.accessibilityLabelButtonFormatHeading - citationButton.setImage(WKSFSymbolIcon.for(symbol: .quoteOpening), for: .normal) citationButton.addTarget(self, action: #selector(tappedCitation), for: .touchUpInside) citationButton.accessibilityLabel = WKSourceEditorLocalizedStrings.current?.accessibilityLabelButtonCitation @@ -57,11 +49,6 @@ class WKEditorToolbarHighlightView: WKEditorToolbarView { templateButton.setImage(WKSFSymbolIcon.for(symbol: .curlybraces), for: .normal) templateButton.addTarget(self, action: #selector(tappedTemplate), for: .touchUpInside) templateButton.accessibilityLabel = WKSourceEditorLocalizedStrings.current?.accessibilityLabelButtonTemplate - - clearMarkupButton.setImage(WKIcon.clear, for: .normal) - clearMarkupButton.addTarget(self, action: #selector(tappedClearMarkup), for: .touchUpInside) - clearMarkupButton.accessibilityLabel = WKSourceEditorLocalizedStrings.current?.accessibilityLabelButtonClearFormatting - showMoreButton.setImage(WKSFSymbolIcon.for(symbol: .plusCircleFill), for: .normal) showMoreButton.addTarget(self, action: #selector(tappedShowMore), for: .touchUpInside) showMoreButton.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.showMoreButton @@ -93,7 +80,6 @@ class WKEditorToolbarHighlightView: WKEditorToolbarView { } @objc private func tappedFormatHeading() { - delegate?.toolbarHighlightViewDidTapFormatHeading(toolbarView: self) } @objc private func tappedCitation() { diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Highlight/WKEditorToolbarHighlightView.xib b/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Highlight/WKEditorToolbarHighlightView.xib index ece76adee38..78e7480b361 100644 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Highlight/WKEditorToolbarHighlightView.xib +++ b/Components/Sources/Components/Components/Editors/Common Views/Input Accessory Views/Highlight/WKEditorToolbarHighlightView.xib @@ -1,9 +1,9 @@ - + - + @@ -29,35 +29,27 @@ - - - - - + - + - + - + - + - - - - - + @@ -99,8 +91,6 @@ - - @@ -110,18 +100,14 @@ - - - - diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorHeaderSelectCell.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorHeaderSelectCell.swift deleted file mode 100644 index 87fef28b24a..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorHeaderSelectCell.swift +++ /dev/null @@ -1,40 +0,0 @@ -import Foundation -import UIKit - -class WKEditorHeaderSelectCell: UITableViewCell { - - // MARK: Properties - - private lazy var componentView: WKEditorHeaderSelectView = { - let view = WKEditorHeaderSelectView() - view.translatesAutoresizingMaskIntoConstraints = false - return view - }() - - // MARK: Lifecycle - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - setup() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setup() { - contentView.addSubview(componentView) - NSLayoutConstraint.activate([ - contentView.leadingAnchor.constraint(equalTo: componentView.leadingAnchor), - contentView.trailingAnchor.constraint(equalTo: componentView.trailingAnchor), - contentView.topAnchor.constraint(equalTo: componentView.topAnchor), - contentView.bottomAnchor.constraint(equalTo: componentView.bottomAnchor) - ]) - } - - // MARK: Internal - - func configure(viewModel: WKEditorHeaderSelectViewModel) { - componentView.configure(viewModel: viewModel) - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorHeaderSelectView.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorHeaderSelectView.swift deleted file mode 100644 index fc3ac021d45..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorHeaderSelectView.swift +++ /dev/null @@ -1,85 +0,0 @@ -import Foundation -import UIKit - -class WKEditorHeaderSelectView: WKComponentView { - - // MARK: Properties - - private lazy var label: UILabel = { - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.adjustsFontForContentSizeCategory = true - label.font = WKFont.for(.body, compatibleWith: appEnvironment.traitCollection) - return label - }() - - private lazy var imageView: UIImageView = { - let image = WKIcon.checkmark - let imageView = UIImageView(image: image) - imageView.translatesAutoresizingMaskIntoConstraints = false - return imageView - }() - - // MARK: Lifecycle - - required init() { - super.init(frame: .zero) - setup() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setup() { - - directionalLayoutMargins = NSDirectionalEdgeInsets(top: 8, leading: 22, bottom: 8, trailing: 22) - - addSubview(label) - addSubview(imageView) - NSLayoutConstraint.activate([ - layoutMarginsGuide.leadingAnchor.constraint(equalTo: label.leadingAnchor), - layoutMarginsGuide.trailingAnchor.constraint(equalTo: imageView.trailingAnchor), - layoutMarginsGuide.topAnchor.constraint(equalTo: label.topAnchor), - layoutMarginsGuide.bottomAnchor.constraint(equalTo: label.bottomAnchor), - label.trailingAnchor.constraint(equalTo: imageView.leadingAnchor), - label.centerYAnchor.constraint(equalTo: imageView.centerYAnchor) - ]) - - updateColors() - } - - // MARK: Internal - - func configure(viewModel: WKEditorHeaderSelectViewModel) { - imageView.isHidden = !viewModel.isSelected - switch viewModel.configuration { - case .paragraph: - label.text = WKSourceEditorLocalizedStrings.current.inputViewParagraph - case .heading: - label.text = WKSourceEditorLocalizedStrings.current.inputViewHeading - case .subheading1: - label.text = WKSourceEditorLocalizedStrings.current.inputViewSubheading1 - case .subheading2: - label.text = WKSourceEditorLocalizedStrings.current.inputViewSubheading2 - case .subheading3: - label.text = WKSourceEditorLocalizedStrings.current.inputViewSubheading3 - case .subheading4: - label.text = WKSourceEditorLocalizedStrings.current.inputViewSubheading4 - } - } - - // MARK: Overrides - - override func appEnvironmentDidChange() { - updateColors() - } - - // MARK: Private Helpers - - func updateColors() { - backgroundColor = WKAppEnvironment.current.theme.accessoryBackground - label.textColor = WKAppEnvironment.current.theme.text - imageView.tintColor = WKAppEnvironment.current.theme.link - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorHeaderSelectViewModel.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorHeaderSelectViewModel.swift deleted file mode 100644 index 33314676d26..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorHeaderSelectViewModel.swift +++ /dev/null @@ -1,20 +0,0 @@ -import Foundation - -class WKEditorHeaderSelectViewModel { - enum Configuration { - case paragraph - case heading - case subheading1 - case subheading2 - case subheading3 - case subheading4 - } - - let configuration: Configuration - var isSelected: Bool - - init(configuration: Configuration, isSelected: Bool) { - self.configuration = configuration - self.isSelected = isSelected - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorInputHeaderSelectViewController.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorInputHeaderSelectViewController.swift deleted file mode 100644 index 9dc6a88819b..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Header Selection/WKEditorInputHeaderSelectViewController.swift +++ /dev/null @@ -1,154 +0,0 @@ -import Foundation -import UIKit - -class WKEditorInputHeaderSelectViewController: WKComponentViewController { - - // MARK: Nested Types - - enum Configuration { - case leftTitleNav - case standard - } - - // MARK: Properties - - private lazy var titleLabel: UILabel = { - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.adjustsFontForContentSizeCategory = true - label.font = WKFont.for(.headline, compatibleWith: appEnvironment.traitCollection) - label.text = WKSourceEditorLocalizedStrings.current.inputViewStyle - return label - }() - - private lazy var tableView: UITableView = { - let tableView = UITableView() - tableView.translatesAutoresizingMaskIntoConstraints = false - tableView.dataSource = self - tableView.delegate = self - return tableView - }() - - private lazy var closeButton: UIBarButtonItem = { - let button = UIBarButtonItem(image: WKSFSymbolIcon.for(symbol: .multiplyCircleFill), style: .plain, target: self, action: #selector(close(_:))) - button.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.closeButton - button.accessibilityLabel = WKSourceEditorLocalizedStrings.current.accessibilityLabelButtonCloseHeaderSelectInputView - return button - }() - - private weak var delegate: WKEditorInputViewDelegate? - private let configuration: Configuration - - private let reuseIdentifier = String(describing: WKEditorHeaderSelectCell.self) - private let viewModels = [WKEditorHeaderSelectViewModel(configuration: .paragraph, isSelected: false), - WKEditorHeaderSelectViewModel(configuration: .heading, isSelected: false), - WKEditorHeaderSelectViewModel(configuration: .subheading1, isSelected: false), - WKEditorHeaderSelectViewModel(configuration: .subheading2, isSelected: false), - WKEditorHeaderSelectViewModel(configuration: .subheading3, isSelected: false), - WKEditorHeaderSelectViewModel(configuration: .subheading4, isSelected: false)] - - // MARK: Lifecycle - - init(configuration: Configuration, delegate: WKEditorInputViewDelegate?) { - self.configuration = configuration - self.delegate = delegate - super.init() - setupNavigationBar() - } - - public required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - override func viewDidLoad() { - super.viewDidLoad() - - view.addSubview(tableView) - view.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.headerSelectInputView - NSLayoutConstraint.activate([ - view.leadingAnchor.constraint(equalTo: tableView.leadingAnchor), - view.trailingAnchor.constraint(equalTo: tableView.trailingAnchor), - view.topAnchor.constraint(equalTo: tableView.topAnchor), - view.bottomAnchor.constraint(equalTo: tableView.bottomAnchor) - ]) - - tableView.register(WKEditorHeaderSelectCell.self, forCellReuseIdentifier: reuseIdentifier) - } - - // MARK: Overrides - - override func appEnvironmentDidChange() { - updateColors() - } - - // MARK: Button Actions - - @objc private func close(_ sender: UIBarButtonItem) { - delegate?.didTapClose() - } - - // MARK: Private Helpers - - private func setupNavigationBar() { - switch configuration { - case .standard: - break - case .leftTitleNav: - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: titleLabel) - } - navigationItem.rightBarButtonItem = closeButton - } - - private func updateColors() { - view.backgroundColor = WKAppEnvironment.current.theme.accessoryBackground - tableView.backgroundColor = WKAppEnvironment.current.theme.accessoryBackground - } -} - -// MARK: UITableViewDataSource - -extension WKEditorInputHeaderSelectViewController: UITableViewDataSource { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 6 - } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) - - if let headerCell = cell as? WKEditorHeaderSelectCell { - let viewModel = viewModels[indexPath.row] - switch indexPath.row { - case 0: - headerCell.configure(viewModel: viewModel) - case 1: - headerCell.configure( viewModel: viewModel) - case 2: - headerCell.configure(viewModel: viewModel) - case 3: - headerCell.configure(viewModel: viewModel) - case 4: - headerCell.configure(viewModel: viewModel) - case 5: - headerCell.configure(viewModel: viewModel) - default: - break - } - headerCell.accessibilityTraits = viewModel.isSelected ? [.button, .selected] : [.button] - - } - - return cell - } -} - -// MARK: UITableViewDelegate - -extension WKEditorInputHeaderSelectViewController: UITableViewDelegate { - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - - for (index, viewModel) in viewModels.enumerated() { - viewModel.isSelected = index == indexPath.row - } - tableView.reloadData() - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Destructive Table Item/WKEditorDestructiveCell.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Destructive Table Item/WKEditorDestructiveCell.swift deleted file mode 100644 index 29259b4738b..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Destructive Table Item/WKEditorDestructiveCell.swift +++ /dev/null @@ -1,40 +0,0 @@ -import Foundation -import UIKit - -class WKEditorDestructiveCell: UITableViewCell { - - // MARK: - Properties - - private lazy var componentView: WKEditorDestructiveView = { - let view = WKEditorDestructiveView() - view.translatesAutoresizingMaskIntoConstraints = false - return view - }() - - // MARK: - Lifecycle - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - setup() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setup() { - contentView.addSubview(componentView) - NSLayoutConstraint.activate([ - contentView.leadingAnchor.constraint(equalTo: componentView.leadingAnchor), - contentView.trailingAnchor.constraint(equalTo: componentView.trailingAnchor), - contentView.topAnchor.constraint(equalTo: componentView.topAnchor), - contentView.bottomAnchor.constraint(equalTo: componentView.bottomAnchor) - ]) - } - - // MARK: - Internal - - func configure(viewModel: WKEditorDestructiveViewModel) { - componentView.configure(viewModel: viewModel) - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Destructive Table Item/WKEditorDestructiveView.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Destructive Table Item/WKEditorDestructiveView.swift deleted file mode 100644 index c08be601ab0..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Destructive Table Item/WKEditorDestructiveView.swift +++ /dev/null @@ -1,60 +0,0 @@ -import Foundation -import UIKit - -class WKEditorDestructiveView: WKComponentView { - - // MARK: Properties - - private lazy var label: UILabel = { - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.adjustsFontForContentSizeCategory = true - label.font = WKFont.for(.body, compatibleWith: appEnvironment.traitCollection) - return label - }() - - // MARK: Lifecycle - - required init() { - super.init(frame: .zero) - setup() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setup() { - - directionalLayoutMargins = NSDirectionalEdgeInsets(top: 8, leading: 22, bottom: 8, trailing: 22) - - addSubview(label) - NSLayoutConstraint.activate([ - layoutMarginsGuide.leadingAnchor.constraint(equalTo: label.leadingAnchor), - layoutMarginsGuide.trailingAnchor.constraint(equalTo: label.trailingAnchor), - layoutMarginsGuide.topAnchor.constraint(equalTo: label.topAnchor), - layoutMarginsGuide.bottomAnchor.constraint(equalTo: label.bottomAnchor) - ]) - - updateColors() - } - - // MARK: Internal - - func configure(viewModel: WKEditorDestructiveViewModel) { - label.text = viewModel.text - } - - // MARK: Overrides - - override func appEnvironmentDidChange() { - updateColors() - } - - // MARK: Private Helpers - - private func updateColors() { - backgroundColor = WKAppEnvironment.current.theme.accessoryBackground - label.textColor = WKAppEnvironment.current.theme.destructive - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Destructive Table Item/WKEditorDestructiveViewModel.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Destructive Table Item/WKEditorDestructiveViewModel.swift deleted file mode 100644 index d792839ee80..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Destructive Table Item/WKEditorDestructiveViewModel.swift +++ /dev/null @@ -1,5 +0,0 @@ -import Foundation - -struct WKEditorDestructiveViewModel { - let text: String -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Detail Table Item/WKEditorSelectionDetailCell.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Detail Table Item/WKEditorSelectionDetailCell.swift deleted file mode 100644 index 17cdfb5fc96..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Detail Table Item/WKEditorSelectionDetailCell.swift +++ /dev/null @@ -1,42 +0,0 @@ -import Foundation -import UIKit - -class WKEditorSelectionDetailCell: UITableViewCell { - - // MARK: - Properties - - private lazy var componentView: WKEditorSelectionDetailView = { - let view = WKEditorSelectionDetailView() - view.translatesAutoresizingMaskIntoConstraints = false - return view - }() - - // MARK: - Lifecycle - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - setup() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setup() { - contentView.addSubview(componentView) - NSLayoutConstraint.activate([ - contentView.leadingAnchor.constraint(equalTo: componentView.leadingAnchor), - contentView.trailingAnchor.constraint(equalTo: componentView.trailingAnchor), - contentView.topAnchor.constraint(equalTo: componentView.topAnchor), - contentView.bottomAnchor.constraint(equalTo: componentView.bottomAnchor) - ]) - - selectedBackgroundView?.backgroundColor = .clear - } - - // MARK: - Internal - - func configure(viewModel: WKEditorSelectionDetailViewModel) { - componentView.configure(viewModel: viewModel) - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Detail Table Item/WKEditorSelectionDetailView.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Detail Table Item/WKEditorSelectionDetailView.swift deleted file mode 100644 index 70ac124065d..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Detail Table Item/WKEditorSelectionDetailView.swift +++ /dev/null @@ -1,88 +0,0 @@ -import Foundation -import UIKit - -class WKEditorSelectionDetailView: WKComponentView { - - // MARK: - Properties - - private lazy var typeLabel: UILabel = { - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.setContentHuggingPriority(.defaultLow, for: .horizontal) - label.adjustsFontForContentSizeCategory = true - label.font = WKFont.for(.body, compatibleWith: appEnvironment.traitCollection) - return label - }() - - private lazy var selectionLabel: UILabel = { - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.adjustsFontForContentSizeCategory = true - label.font = WKFont.for(.body, compatibleWith: appEnvironment.traitCollection) - label.textAlignment = .right - return label - }() - - private lazy var disclosureImageView: UIImageView = { - let imageView = UIImageView() - imageView.translatesAutoresizingMaskIntoConstraints = false - imageView.image = WKIcon.chevronRight - return imageView - }() - - private var viewModel: WKEditorSelectionDetailViewModel? - - // MARK: - Lifecycle - - required init() { - super.init(frame: .zero) - setup() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setup() { - - directionalLayoutMargins = NSDirectionalEdgeInsets(top: 8, leading: 22, bottom: 8, trailing: 22) - - addSubview(typeLabel) - addSubview(selectionLabel) - addSubview(disclosureImageView) - NSLayoutConstraint.activate([ - layoutMarginsGuide.leadingAnchor.constraint(equalTo: typeLabel.leadingAnchor), - layoutMarginsGuide.trailingAnchor.constraint(equalTo: disclosureImageView.trailingAnchor), - layoutMarginsGuide.topAnchor.constraint(equalTo: typeLabel.topAnchor), - layoutMarginsGuide.bottomAnchor.constraint(equalTo: typeLabel.bottomAnchor), - typeLabel.trailingAnchor.constraint(equalTo: selectionLabel.leadingAnchor), - selectionLabel.trailingAnchor.constraint(equalTo: disclosureImageView.leadingAnchor, constant: -8), - selectionLabel.centerYAnchor.constraint(equalTo: disclosureImageView.centerYAnchor), - selectionLabel.centerYAnchor.constraint(equalTo: typeLabel.centerYAnchor) - ]) - - updateColors() - } - - // MARK: - Internal - - func configure(viewModel: WKEditorSelectionDetailViewModel) { - typeLabel.text = viewModel.typeText - selectionLabel.text = viewModel.selectionText - } - - // MARK: - Overrides - - override func appEnvironmentDidChange() { - updateColors() - } - - // MARK: - Private Helpers - - private func updateColors() { - backgroundColor = WKAppEnvironment.current.theme.accessoryBackground - disclosureImageView.tintColor = WKAppEnvironment.current.theme.inputAccessoryButtonTint - typeLabel.textColor = WKAppEnvironment.current.theme.text - selectionLabel.textColor = WKAppEnvironment.current.theme.text - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Detail Table Item/WKEditorSelectionDetailViewModel.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Detail Table Item/WKEditorSelectionDetailViewModel.swift deleted file mode 100644 index 6ad53cd739d..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Detail Table Item/WKEditorSelectionDetailViewModel.swift +++ /dev/null @@ -1,6 +0,0 @@ -import Foundation - -struct WKEditorSelectionDetailViewModel { - let typeText: String - let selectionText: String -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Grouped Toolbar Table Item/WKEditorToolbarGroupedCell.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Grouped Toolbar Table Item/WKEditorToolbarGroupedCell.swift deleted file mode 100644 index 5f48bbd0aa6..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Grouped Toolbar Table Item/WKEditorToolbarGroupedCell.swift +++ /dev/null @@ -1,43 +0,0 @@ -import Foundation -import UIKit - -class WKEditorToolbarGroupedCell: UITableViewCell { - - // MARK: - Properties - - private lazy var componentView: WKEditorToolbarGroupedView = { - let view = UINib(nibName: String(describing: WKEditorToolbarGroupedView.self), bundle: Bundle.module).instantiate(withOwner: nil).first as! WKEditorToolbarGroupedView - - return view - }() - - var delegate: WKEditorInputViewDelegate? { - get { - return componentView.delegate - } - set { - componentView.delegate = newValue - } - } - - // MARK: - Lifecycle - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - setup() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setup() { - contentView.addSubview(componentView) - NSLayoutConstraint.activate([ - contentView.leadingAnchor.constraint(equalTo: componentView.leadingAnchor), - contentView.trailingAnchor.constraint(equalTo: componentView.trailingAnchor), - contentView.topAnchor.constraint(equalTo: componentView.topAnchor), - contentView.bottomAnchor.constraint(equalTo: componentView.bottomAnchor) - ]) - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Plain Toolbar Table Item/WKEditorToolbarPlainCell.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Plain Toolbar Table Item/WKEditorToolbarPlainCell.swift deleted file mode 100644 index f65c37e94ef..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Plain Toolbar Table Item/WKEditorToolbarPlainCell.swift +++ /dev/null @@ -1,43 +0,0 @@ -import Foundation -import UIKit - -class WKEditorToolbarPlainCell: UITableViewCell { - - // MARK: - Properties - - private lazy var componentView: WKEditorToolbarPlainView = { - let view = UINib(nibName: String(describing: WKEditorToolbarPlainView.self), bundle: Bundle.module).instantiate(withOwner: nil).first as! WKEditorToolbarPlainView - - return view - }() - - var delegate: WKEditorInputViewDelegate? { - get { - return componentView.delegate - } - set { - componentView.delegate = newValue - } - } - - // MARK: - Lifecycle - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - setup() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private func setup() { - contentView.addSubview(componentView) - NSLayoutConstraint.activate([ - contentView.leadingAnchor.constraint(equalTo: componentView.leadingAnchor), - contentView.trailingAnchor.constraint(equalTo: componentView.trailingAnchor), - contentView.topAnchor.constraint(equalTo: componentView.topAnchor), - contentView.bottomAnchor.constraint(equalTo: componentView.bottomAnchor) - ]) - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/WKEditorInputMainViewController.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/WKEditorInputMainViewController.swift deleted file mode 100644 index 5673f3df806..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/WKEditorInputMainViewController.swift +++ /dev/null @@ -1,148 +0,0 @@ -import Foundation -import UIKit - -class WKEditorInputMainViewController: WKComponentViewController { - - // MARK: - Properties - - private lazy var tableView: UITableView = { - let tableView = UITableView() - tableView.translatesAutoresizingMaskIntoConstraints = false - tableView.dataSource = self - tableView.delegate = self - return tableView - }() - - private lazy var titleLabel: UILabel = { - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.adjustsFontForContentSizeCategory = true - label.font = WKFont.for(.headline, compatibleWith: appEnvironment.traitCollection) - label.text = WKSourceEditorLocalizedStrings.current.inputViewTextFormatting - return label - }() - - private lazy var closeButton: UIBarButtonItem = { - let button = UIBarButtonItem(image: WKSFSymbolIcon.for(symbol: .multiplyCircleFill), style: .plain, target: self, action: #selector(close(_:))) - button.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.closeButton - button.accessibilityLabel = WKSourceEditorLocalizedStrings.current.accessibilityLabelButtonCloseMainInputView - return button - }() - - private let plainReuseIdentifier = String(describing: WKEditorToolbarPlainCell.self) - private let groupedReuseIdentifier = String(describing: WKEditorToolbarGroupedCell.self) - private let detailReuseIdentifier = String(describing: WKEditorSelectionDetailCell.self) - private let destructiveReuseIdentifier = String(describing: WKEditorDestructiveCell.self) - - weak var delegate: WKEditorInputViewDelegate? - - // MARK: - Lifecycle - - override func viewDidLoad() { - super.viewDidLoad() - - view.addSubview(tableView) - view.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.mainInputView - NSLayoutConstraint.activate([ - view.leadingAnchor.constraint(equalTo: tableView.leadingAnchor), - view.trailingAnchor.constraint(equalTo: tableView.trailingAnchor), - view.topAnchor.constraint(equalTo: tableView.topAnchor), - view.bottomAnchor.constraint(equalTo: tableView.bottomAnchor) - ]) - - tableView.register(WKEditorToolbarPlainCell.self, forCellReuseIdentifier: plainReuseIdentifier) - tableView.register(WKEditorToolbarGroupedCell.self, forCellReuseIdentifier: groupedReuseIdentifier) - tableView.register(WKEditorSelectionDetailCell.self, forCellReuseIdentifier: detailReuseIdentifier) - tableView.register(WKEditorDestructiveCell.self, forCellReuseIdentifier: destructiveReuseIdentifier) - - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: titleLabel) - navigationItem.rightBarButtonItem = closeButton - - updateColors() - } - - // MARK: - Overrides - - override func appEnvironmentDidChange() { - updateColors() - } - - // MARK: - Button Actions - - @objc private func close(_ sender: UIBarButtonItem) { - delegate?.didTapClose() - } - - // MARK: - Private Helpers - - private func updateColors() { - view.backgroundColor = WKAppEnvironment.current.theme.accessoryBackground - tableView.backgroundColor = WKAppEnvironment.current.theme.accessoryBackground - titleLabel.textColor = WKAppEnvironment.current.theme.text - } -} - -// MARK: - UITableViewDataSource - -extension WKEditorInputMainViewController: UITableViewDataSource { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 4 - } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell: UITableViewCell - switch indexPath.row { - case 0: - cell = tableView.dequeueReusableCell(withIdentifier: plainReuseIdentifier, for: indexPath) - - if let plainCell = cell as? WKEditorToolbarPlainCell { - plainCell.delegate = delegate - } - - cell.selectionStyle = .none - case 1: - cell = tableView.dequeueReusableCell(withIdentifier: groupedReuseIdentifier, for: indexPath) - - if let groupedCell = cell as? WKEditorToolbarGroupedCell { - groupedCell.delegate = delegate - } - - cell.selectionStyle = .none - case 2: - - cell = tableView.dequeueReusableCell(withIdentifier: detailReuseIdentifier, for: indexPath) - - if let detailCell = cell as? WKEditorSelectionDetailCell { - detailCell.configure(viewModel: WKEditorSelectionDetailViewModel(typeText: WKSourceEditorLocalizedStrings.current.inputViewStyle, selectionText: WKSourceEditorLocalizedStrings.current.inputViewParagraph)) - detailCell.accessibilityTraits = [.button] - } - case 3: - cell = tableView.dequeueReusableCell(withIdentifier: destructiveReuseIdentifier, for: indexPath) - - if let destructiveCell = cell as? WKEditorDestructiveCell { - destructiveCell.configure(viewModel: WKEditorDestructiveViewModel(text: WKSourceEditorLocalizedStrings.current.inputViewClearFormatting)) - destructiveCell.accessibilityTraits = [.button] - } - default: - fatalError() - } - - return cell - } -} - -// MARK: - UITableViewDelegate - -extension WKEditorInputMainViewController: UITableViewDelegate { - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - - let cell = tableView.cellForRow(at: indexPath) - cell?.isSelected = false - - if indexPath.row == 2 { - navigationItem.backButtonTitle = WKSourceEditorLocalizedStrings.current.inputViewTextFormatting - let headerVC = WKEditorInputHeaderSelectViewController(configuration: .standard, delegate: delegate) - navigationController?.pushViewController(headerVC, animated: true) - } - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorInputView.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorInputView.swift new file mode 100644 index 00000000000..9e6fead4fc2 --- /dev/null +++ b/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorInputView.swift @@ -0,0 +1,302 @@ +import Foundation +import UIKit + +protocol WKEditorInputViewDelegate: AnyObject { + func didTapClose() + func didTapBold(isSelected: Bool) + func didTapItalics(isSelected: Bool) + func didTapTemplate(isSelected: Bool) + func didTapStrikethrough(isSelected: Bool) +} + +class WKEditorInputView: WKComponentView { + + // MARK: - Nested Types + + enum HeadingButtonType { + case paragraph + case heading + case subheading1 + case subheading2 + case subheading3 + case subheading4 + + var title: String { + switch self { + case .paragraph: return WKSourceEditorLocalizedStrings.current.inputViewParagraph + case .heading: return WKSourceEditorLocalizedStrings.current.inputViewHeading + case .subheading1: return WKSourceEditorLocalizedStrings.current.inputViewSubheading1 + case .subheading2: return WKSourceEditorLocalizedStrings.current.inputViewSubheading2 + case .subheading3: return WKSourceEditorLocalizedStrings.current.inputViewSubheading3 + case .subheading4: return WKSourceEditorLocalizedStrings.current.inputViewSubheading4 + } + } + } + + // MARK: - Properties + + private lazy var navigationStackView: UIStackView = { + let stackView = UIStackView() + stackView.translatesAutoresizingMaskIntoConstraints = false + stackView.axis = .horizontal + stackView.distribution = .fill + stackView.alignment = .fill + return stackView + }() + + private lazy var titleLabel: UILabel = { + let label = UILabel() + label.translatesAutoresizingMaskIntoConstraints = false + label.adjustsFontForContentSizeCategory = true + label.font = WKFont.for(.headline, compatibleWith: appEnvironment.traitCollection) + label.text = WKSourceEditorLocalizedStrings.current.inputViewTextFormatting + label.setContentHuggingPriority(.defaultLow, for: .horizontal) + return label + }() + + private lazy var closeButton: UIButton = { + let button = UIButton() + button.translatesAutoresizingMaskIntoConstraints = false + button.setImage(WKSFSymbolIcon.for(symbol: .multiplyCircleFill), for: .normal) + button.addTarget(self, action: #selector(close(_:)), for: .touchUpInside) + button.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.closeButton + button.accessibilityLabel = WKSourceEditorLocalizedStrings.current.accessibilityLabelButtonCloseMainInputView + return button + }() + + private lazy var containerScrollView: UIScrollView = { + let scrollView = UIScrollView() + scrollView.translatesAutoresizingMaskIntoConstraints = false + return scrollView + }() + + private lazy var containerStackView: UIStackView = { + let stackView = UIStackView() + stackView.translatesAutoresizingMaskIntoConstraints = false + stackView.axis = .vertical + stackView.distribution = .fill + stackView.alignment = .fill + return stackView + }() + + private lazy var headingScrollView: UIScrollView = { + let scrollView = UIScrollView() + scrollView.translatesAutoresizingMaskIntoConstraints = false + return scrollView + }() + + private lazy var headingStackView: UIStackView = { + let stackView = UIStackView() + stackView.translatesAutoresizingMaskIntoConstraints = false + stackView.axis = .horizontal + stackView.distribution = .fill + stackView.alignment = .fill + return stackView + }() + + private lazy var plainToolbarView: WKEditorToolbarPlainView = { + let view = UINib(nibName: String(describing: WKEditorToolbarPlainView.self), bundle: Bundle.module).instantiate(withOwner: nil).first as! WKEditorToolbarPlainView + view.delegate = delegate + view.translatesAutoresizingMaskIntoConstraints = false + return view + }() + + private lazy var groupedToolbarView: WKEditorToolbarGroupedView = { + let view = UINib(nibName: String(describing: WKEditorToolbarGroupedView.self), bundle: Bundle.module).instantiate(withOwner: nil).first as! WKEditorToolbarGroupedView + view.delegate = delegate + view.translatesAutoresizingMaskIntoConstraints = false + return view + }() + + // Heading Buttons + private var paragraphButton: UIButton! + private var headerButton: UIButton! + private var subheader1Button: UIButton! + private var subheader2Button: UIButton! + private var subheader3Button: UIButton! + private var subheader4Button: UIButton! + + var headingButtons: [UIButton] { + return [paragraphButton, headerButton, subheader1Button, subheader2Button, subheader3Button, subheader4Button] + } + + private var divViews: [UIView] = [] + + private weak var delegate: WKEditorInputViewDelegate? + + // MARK: - Lifecycle + + init(delegate: WKEditorInputViewDelegate) { + self.delegate = delegate + super.init(frame: .zero) + setup() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setup() { + + addSubview(navigationStackView) + navigationStackView.addArrangedSubview(titleLabel) + navigationStackView.addArrangedSubview(closeButton) + + // pin navigation stack view to top + NSLayoutConstraint.activate([ + navigationStackView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor, constant: 12), + navigationStackView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 16), + safeAreaLayoutGuide.trailingAnchor.constraint(equalTo: navigationStackView.trailingAnchor, constant: 16) + ]) + + // ---- Headings ---- + + self.paragraphButton = headingButton(type: .paragraph) + self.paragraphButton.isSelected = true + self.headerButton = headingButton(type: .heading) + self.subheader1Button = headingButton(type: .subheading1) + self.subheader2Button = headingButton(type: .subheading2) + self.subheader3Button = headingButton(type: .subheading3) + self.subheader4Button = headingButton(type: .subheading4) + + headingStackView.addArrangedSubview(paragraphButton) + headingStackView.addArrangedSubview(headerButton) + headingStackView.addArrangedSubview(subheader1Button) + headingStackView.addArrangedSubview(subheader2Button) + headingStackView.addArrangedSubview(subheader3Button) + headingStackView.addArrangedSubview(subheader4Button) + + headingScrollView.addSubview(headingStackView) + + let headerButtonSize = headerButton.sizeThatFits(bounds.size) + + // pin heading stack to heading scroll view content guide + // ensure it only scrolls horizontally + // set heading scroll view height to largest button height + NSLayoutConstraint.activate([ + headingScrollView.contentLayoutGuide.topAnchor.constraint(equalTo: headingStackView.topAnchor), + headingStackView.leadingAnchor.constraint(equalTo: headingScrollView.contentLayoutGuide.leadingAnchor, constant: 16), + headingScrollView.contentLayoutGuide.trailingAnchor.constraint(equalTo: headingStackView.trailingAnchor, constant: 16), + headingScrollView.contentLayoutGuide.bottomAnchor.constraint(equalTo: headingStackView.bottomAnchor), + headingScrollView.contentLayoutGuide.heightAnchor.constraint(equalTo: headingScrollView.frameLayoutGuide.heightAnchor), + headingScrollView.heightAnchor.constraint(equalToConstant: headerButtonSize.height) + ]) + + // ---- Container ---- + + containerStackView.addArrangedSubview(headingScrollView) + let divView1 = divView() + containerStackView.addArrangedSubview(divView1) + containerStackView.addArrangedSubview(plainToolbarView) + let divView2 = divView() + containerStackView.addArrangedSubview(divView1) + containerStackView.addArrangedSubview(groupedToolbarView) + let divView3 = divView() + containerStackView.addArrangedSubview(divView3) + containerScrollView.addSubview(containerStackView) + + self.divViews = [divView1, divView2, divView3] + + // pin container stack view to container scroll view content guide + NSLayoutConstraint.activate([ + containerScrollView.contentLayoutGuide.topAnchor.constraint(equalTo: containerStackView.topAnchor), + containerScrollView.contentLayoutGuide.leadingAnchor.constraint(equalTo: containerStackView.leadingAnchor), + containerScrollView.contentLayoutGuide.trailingAnchor.constraint(equalTo: containerStackView.trailingAnchor), + containerScrollView.contentLayoutGuide.bottomAnchor.constraint(equalTo: containerStackView.bottomAnchor) + ]) + + addSubview(containerScrollView) + + // pin scroll view frame guide to outer views + NSLayoutConstraint.activate([ + containerScrollView.frameLayoutGuide.topAnchor.constraint(equalTo: navigationStackView.bottomAnchor, constant: 18), + containerScrollView.frameLayoutGuide.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor), + containerScrollView.frameLayoutGuide.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor), + containerScrollView.frameLayoutGuide.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor) + ]) + + // Ensure it only scrolls vertically + NSLayoutConstraint.activate([ + containerScrollView.contentLayoutGuide.widthAnchor.constraint(equalTo: containerScrollView.frameLayoutGuide.widthAnchor) + ]) + + updateColors() + } + + // MARK: - Overrides + + override func appEnvironmentDidChange() { + updateColors() + } + + // MARK: - Button Actions + + @objc private func close(_ sender: UIBarButtonItem) { + delegate?.didTapClose() + } + + // MARK: - Private Helpers + + private func updateColors() { + backgroundColor = WKAppEnvironment.current.theme.accessoryBackground + titleLabel.textColor = WKAppEnvironment.current.theme.text + closeButton.tintColor = WKAppEnvironment.current.theme.inputAccessoryButtonTint + divViews.forEach { view in + view.backgroundColor = WKAppEnvironment.current.theme.border + } + } + + private func divView() -> UIView { + let view = UIView() + view.translatesAutoresizingMaskIntoConstraints = false + view.heightAnchor.constraint(equalToConstant: 0.5).isActive = true + return view + } + + private func headingButton(type: HeadingButtonType) -> UIButton { + + let font: UIFont + switch type { + case .paragraph: font = WKFont.for(.body, compatibleWith: traitCollection) + case .heading: font = WKFont.for(.headline, compatibleWith: traitCollection) + default: font = WKFont.for(.subheadline, compatibleWith: traitCollection) + } + + var configuration = UIButton.Configuration.plain() + configuration.titleTextAttributesTransformer = + UIConfigurationTextAttributesTransformer { incoming in + var outgoing = incoming + outgoing.font = font + outgoing.foregroundColor = WKAppEnvironment.current.theme.text + return outgoing + } + configuration.contentInsets = NSDirectionalEdgeInsets(top: 19, leading: 12, bottom: 19, trailing: 12) + let action = UIAction(title: type.title, handler: { [weak self] _ in + + guard let self else { + return + } + + self.headingButtons.forEach { button in + button.isSelected = false + } + + switch type { + case .paragraph: + paragraphButton.isSelected.toggle() + case .heading: + headerButton.isSelected.toggle() + case .subheading1: + subheader1Button.isSelected.toggle() + case .subheading2: + subheader2Button.isSelected.toggle() + case .subheading3: + subheader3Button.isSelected.toggle() + case .subheading4: + subheader4Button.isSelected.toggle() + } + }) + + return UIButton(configuration: configuration, primaryAction: action) + } +} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorInputViewController.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorInputViewController.swift deleted file mode 100644 index 29ecd3d211a..00000000000 --- a/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorInputViewController.swift +++ /dev/null @@ -1,123 +0,0 @@ -import Foundation -import UIKit - -protocol WKEditorInputViewDelegate: AnyObject { - func didTapClose() - func didTapBold(isSelected: Bool) - func didTapItalics(isSelected: Bool) - func didTapTemplate(isSelected: Bool) - func didTapBulletList(isSelected: Bool) - func didTapNumberList(isSelected: Bool) - func didTapIncreaseIndent() - func didTapDecreaseIndent() - func didTapStrikethrough(isSelected: Bool) -} - -class WKEditorInputViewController: WKComponentViewController { - - // MARK: - Nested Types - - enum Configuration { - case rootMain - case rootHeaderSelect - } - - // MARK: - Properties - - private lazy var containerView: UIView = { - let view = UIView() - view.translatesAutoresizingMaskIntoConstraints = false - return view - }() - - private lazy var embeddedNavigationController: UINavigationController = { - let viewController = rootViewController(for: configuration) - let navigationController = UINavigationController(rootViewController: viewController) - return navigationController - }() - - private lazy var headerSelectViewController: WKEditorInputHeaderSelectViewController = { - let vc = WKEditorInputHeaderSelectViewController(configuration: .leftTitleNav, delegate: delegate) - return vc - }() - - private lazy var mainViewController: WKEditorInputMainViewController = { - let vc = WKEditorInputMainViewController() - vc.delegate = delegate - return vc - }() - - private let configuration: Configuration - private weak var delegate: WKEditorInputViewDelegate? - - // MARK: - Lifecycle - - init(configuration: Configuration, delegate: WKEditorInputViewDelegate) { - self.configuration = configuration - self.delegate = delegate - super.init() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - override func viewDidLoad() { - - super.viewDidLoad() - - view.addSubview(containerView) - NSLayoutConstraint.activate([ - view.leadingAnchor.constraint(equalTo: containerView.leadingAnchor), - view.trailingAnchor.constraint(equalTo: containerView.trailingAnchor), - view.topAnchor.constraint(equalTo: containerView.topAnchor), - view.bottomAnchor.constraint(equalTo: containerView.bottomAnchor) - ]) - - embedNavigationController() - - updateColors() - } - - // MARK: - Overrides - - override func appEnvironmentDidChange() { - updateColors() - } - - // MARK: - Private Helpers - - private func embedNavigationController() { - addChild(embeddedNavigationController) - embeddedNavigationController.view.translatesAutoresizingMaskIntoConstraints = false - containerView.addSubview(embeddedNavigationController.view) - - NSLayoutConstraint.activate([ - containerView.leadingAnchor.constraint(equalTo: embeddedNavigationController.view.leadingAnchor), - containerView.trailingAnchor.constraint(equalTo: embeddedNavigationController.view.trailingAnchor), - containerView.topAnchor.constraint(equalTo: embeddedNavigationController.view.topAnchor), - containerView.bottomAnchor.constraint(equalTo: embeddedNavigationController.view.bottomAnchor) - ]) - - embeddedNavigationController.didMove(toParent: self) - } - - private func rootViewController(for configuration: Configuration) -> UIViewController { - var viewController: UIViewController - - switch configuration { - case .rootMain: - viewController = mainViewController - case .rootHeaderSelect: - viewController = headerSelectViewController - } - return viewController - } - - private func updateColors() { - view.backgroundColor = WKAppEnvironment.current.theme.accessoryBackground - embeddedNavigationController.navigationBar.isTranslucent = false - embeddedNavigationController.navigationBar.tintColor = WKAppEnvironment.current.theme.inputAccessoryButtonTint - embeddedNavigationController.navigationBar.backgroundColor = WKAppEnvironment.current.theme.accessoryBackground - } -} diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Grouped Toolbar Table Item/WKEditorToolbarGroupedView.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorToolbarGroupedView.swift similarity index 100% rename from Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Grouped Toolbar Table Item/WKEditorToolbarGroupedView.swift rename to Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorToolbarGroupedView.swift diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Grouped Toolbar Table Item/WKEditorToolbarGroupedView.xib b/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorToolbarGroupedView.xib similarity index 100% rename from Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Grouped Toolbar Table Item/WKEditorToolbarGroupedView.xib rename to Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorToolbarGroupedView.xib diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Plain Toolbar Table Item/WKEditorToolbarPlainView.swift b/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorToolbarPlainView.swift similarity index 100% rename from Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Plain Toolbar Table Item/WKEditorToolbarPlainView.swift rename to Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorToolbarPlainView.swift diff --git a/Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Plain Toolbar Table Item/WKEditorToolbarPlainView.xib b/Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorToolbarPlainView.xib similarity index 100% rename from Components/Sources/Components/Components/Editors/Common Views/Input Views/Main/Plain Toolbar Table Item/WKEditorToolbarPlainView.xib rename to Components/Sources/Components/Components/Editors/Common Views/Input Views/WKEditorToolbarPlainView.xib diff --git a/Components/Sources/Components/Components/Editors/Source Editor/Formatter Extensions/WKSourceEditorFormatter+ButtonActions.swift b/Components/Sources/Components/Components/Editors/Source Editor/Formatter Extensions/WKSourceEditorFormatter+ButtonActions.swift index e0e70e9d2f6..2095711d9fa 100644 --- a/Components/Sources/Components/Components/Editors/Source Editor/Formatter Extensions/WKSourceEditorFormatter+ButtonActions.swift +++ b/Components/Sources/Components/Components/Editors/Source Editor/Formatter Extensions/WKSourceEditorFormatter+ButtonActions.swift @@ -16,19 +16,63 @@ extension WKSourceEditorFormatter { func toggleFormatting(startingFormattingString: String, endingFormattingString: String, action: WKSourceEditorFormatterButtonAction, in textView: UITextView) { - switch action { - case .remove: - expandSelectedRangeUpToNearestFormattingStrings(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) - - if selectedRangeIsSurroundedByFormattingStrings(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) { - removeSurroundingFormattingStringsFromSelectedRange(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) + if textView.selectedRange.length == 0 { + switch action { + case .remove: + expandSelectedRangeUpToNearestFormattingStrings(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) + + if selectedRangeIsSurroundedByFormattingStrings(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) { + removeSurroundingFormattingStringsFromSelectedRange(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) + } + case .add: + if selectedRangeIsSurroundedByFormattingStrings(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) { + removeSurroundingFormattingStringsFromSelectedRange(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) + } else { + addStringFormattingCharacters(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) + } } - case .add: - if textView.selectedRange.length == 0 && - selectedRangeIsSurroundedByFormattingStrings(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) { - removeSurroundingFormattingStringsFromSelectedRange(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) - } else { - addStringFormattingCharacters(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) + } else { + + switch action { + case .remove: + + if selectedRangeIsSurroundedByFormattingStrings(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) { + removeSurroundingFormattingStringsFromSelectedRange(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) + } else { + + // Note the flipped formatting string params. + // For example, this takes selected 'text' from: + // Testing Strikethrough text here + // To: + // Testing Strikethrough text here + // We have to add formatters in reverse order to remove formatting from 'text' + + addStringFormattingCharacters(startingFormattingString: endingFormattingString, endingFormattingString: startingFormattingString, in: textView) + } + + case .add: + + // Note: gross workaround to prevent italics misfire from continuing below + if startingFormattingString == "''" && endingFormattingString == "''" { + if selectedRangeIsSurroundedByFormattingString(formattingString: "''", in: textView) && + selectedRangeIsSurroundedByFormattingString(formattingString: "'''", in: textView) { + addStringFormattingCharacters(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) + return + } + } + + // Note the flipped formatting string params. + // For example, this takes selected 'text' from: + // Testing Strikethrough text here + // To: + // Testing Strikethrough text here + // We have to check and remove formatters in reverse order to add formatting to 'text' + + if selectedRangeIsSurroundedByFormattingStrings(startingFormattingString: endingFormattingString, endingFormattingString: startingFormattingString, in: textView) { + removeSurroundingFormattingStringsFromSelectedRange(startingFormattingString: endingFormattingString, endingFormattingString: startingFormattingString, in: textView) + } else { + addStringFormattingCharacters(startingFormattingString: startingFormattingString, endingFormattingString: endingFormattingString, in: textView) + } } } } diff --git a/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorAccessibilityIdentifiers.swift b/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorAccessibilityIdentifiers.swift index 4d8f3244671..5135692b8e8 100644 --- a/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorAccessibilityIdentifiers.swift +++ b/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorAccessibilityIdentifiers.swift @@ -4,18 +4,16 @@ public struct WKSourceEditorAccessibilityIdentifiers { static var current: WKSourceEditorAccessibilityIdentifiers? - public init(textView: String, findButton: String, showMoreButton: String, closeButton: String, formatTextButton: String, formatHeadingButton: String, expandingToolbar: String, highlightToolbar: String, findToolbar: String, mainInputView: String, headerSelectInputView: String) { + public init(textView: String, findButton: String, showMoreButton: String, closeButton: String, formatTextButton: String, expandingToolbar: String, highlightToolbar: String, findToolbar: String, inputView: String) { self.textView = textView self.findButton = findButton self.showMoreButton = showMoreButton self.closeButton = closeButton self.formatTextButton = formatTextButton - self.formatHeadingButton = formatHeadingButton self.expandingToolbar = expandingToolbar self.highlightToolbar = highlightToolbar self.findToolbar = findToolbar - self.mainInputView = mainInputView - self.headerSelectInputView = headerSelectInputView + self.inputView = inputView } let textView: String @@ -23,10 +21,8 @@ public struct WKSourceEditorAccessibilityIdentifiers { let showMoreButton: String let closeButton: String let formatTextButton: String - let formatHeadingButton: String let expandingToolbar: String let highlightToolbar: String let findToolbar: String - let mainInputView: String - let headerSelectInputView: String + let inputView: String } diff --git a/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorLocalizedStrings.swift b/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorLocalizedStrings.swift index 074d2eb8c74..226b2883adf 100644 --- a/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorLocalizedStrings.swift +++ b/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorLocalizedStrings.swift @@ -17,7 +17,6 @@ public struct WKSourceEditorLocalizedStrings { let findReplaceWith: String let accessibilityLabelButtonFormatText: String - let accessibilityLabelButtonFormatHeading: String let accessibilityLabelButtonCitation: String let accessibilityLabelButtonCitationSelected: String let accessibilityLabelButtonLink: String @@ -41,7 +40,6 @@ public struct WKSourceEditorLocalizedStrings { let accessibilityLabelButtonBoldSelected: String let accessibilityLabelButtonItalics: String let accessibilityLabelButtonItalicsSelected: String - let accessibilityLabelButtonClearFormatting: String let accessibilityLabelButtonShowMore: String let accessibilityLabelButtonComment: String @@ -70,7 +68,7 @@ public struct WKSourceEditorLocalizedStrings { let accessibilityLabelReplaceTypeSingle: String let accessibilityLabelReplaceTypeAll: String - public init(inputViewTextFormatting: String, inputViewStyle: String, inputViewClearFormatting: String, inputViewParagraph: String, inputViewHeading: String, inputViewSubheading1: String, inputViewSubheading2: String, inputViewSubheading3: String, inputViewSubheading4: String, findReplaceTypeSingle: String, findReplaceTypeAll: String, findReplaceWith: String, accessibilityLabelButtonFormatText: String, accessibilityLabelButtonFormatHeading: String, accessibilityLabelButtonCitation: String, accessibilityLabelButtonCitationSelected: String, accessibilityLabelButtonLink: String, accessibilityLabelButtonLinkSelected: String, accessibilityLabelButtonTemplate: String, accessibilityLabelButtonTemplateSelected: String, accessibilityLabelButtonMedia: String, accessibilityLabelButtonFind: String, accessibilityLabelButtonListUnordered: String, accessibilityLabelButtonListUnorderedSelected: String, accessibilityLabelButtonListOrdered: String, accessibilityLabelButtonListOrderedSelected: String, accessibilityLabelButtonInceaseIndent: String, accessibilityLabelButtonDecreaseIndent: String, accessibilityLabelButtonCursorUp: String, accessibilityLabelButtonCursorDown: String, accessibilityLabelButtonCursorLeft: String, accessibilityLabelButtonCursorRight: String, accessibilityLabelButtonBold: String, accessibilityLabelButtonBoldSelected: String, accessibilityLabelButtonItalics: String, accessibilityLabelButtonItalicsSelected: String, accessibilityLabelButtonClearFormatting: String, accessibilityLabelButtonShowMore: String, accessibilityLabelButtonComment: String, accessibilityLabelButtonCommentSelected: String, accessibilityLabelButtonSuperscript: String, accessibilityLabelButtonSuperscriptSelected: String, accessibilityLabelButtonSubscript: String, accessibilityLabelButtonSubscriptSelected: String, accessibilityLabelButtonUnderline: String, accessibilityLabelButtonUnderlineSelected: String, accessibilityLabelButtonStrikethrough: String, accessibilityLabelButtonStrikethroughSelected: String, accessibilityLabelButtonCloseMainInputView: String, accessibilityLabelButtonCloseHeaderSelectInputView: String, accessibilityLabelFindTextField: String, accessibilityLabelFindButtonClear: String, accessibilityLabelFindButtonClose: String, accessibilityLabelFindButtonNext: String, accessibilityLabelFindButtonPrevious: String, accessibilityLabelReplaceTextField: String, accessibilityLabelReplaceButtonClear: String, accessibilityLabelReplaceButtonPerformFormat: String, accessibilityLabelReplaceButtonSwitchFormat: String, accessibilityLabelReplaceTypeSingle: String, accessibilityLabelReplaceTypeAll: String) { + public init(inputViewTextFormatting: String, inputViewStyle: String, inputViewClearFormatting: String, inputViewParagraph: String, inputViewHeading: String, inputViewSubheading1: String, inputViewSubheading2: String, inputViewSubheading3: String, inputViewSubheading4: String, findReplaceTypeSingle: String, findReplaceTypeAll: String, findReplaceWith: String, accessibilityLabelButtonFormatText: String, accessibilityLabelButtonCitation: String, accessibilityLabelButtonCitationSelected: String, accessibilityLabelButtonLink: String, accessibilityLabelButtonLinkSelected: String, accessibilityLabelButtonTemplate: String, accessibilityLabelButtonTemplateSelected: String, accessibilityLabelButtonMedia: String, accessibilityLabelButtonFind: String, accessibilityLabelButtonListUnordered: String, accessibilityLabelButtonListUnorderedSelected: String, accessibilityLabelButtonListOrdered: String, accessibilityLabelButtonListOrderedSelected: String, accessibilityLabelButtonInceaseIndent: String, accessibilityLabelButtonDecreaseIndent: String, accessibilityLabelButtonCursorUp: String, accessibilityLabelButtonCursorDown: String, accessibilityLabelButtonCursorLeft: String, accessibilityLabelButtonCursorRight: String, accessibilityLabelButtonBold: String, accessibilityLabelButtonBoldSelected: String, accessibilityLabelButtonItalics: String, accessibilityLabelButtonItalicsSelected: String, accessibilityLabelButtonShowMore: String, accessibilityLabelButtonComment: String, accessibilityLabelButtonCommentSelected: String, accessibilityLabelButtonSuperscript: String, accessibilityLabelButtonSuperscriptSelected: String, accessibilityLabelButtonSubscript: String, accessibilityLabelButtonSubscriptSelected: String, accessibilityLabelButtonUnderline: String, accessibilityLabelButtonUnderlineSelected: String, accessibilityLabelButtonStrikethrough: String, accessibilityLabelButtonStrikethroughSelected: String, accessibilityLabelButtonCloseMainInputView: String, accessibilityLabelButtonCloseHeaderSelectInputView: String, accessibilityLabelFindTextField: String, accessibilityLabelFindButtonClear: String, accessibilityLabelFindButtonClose: String, accessibilityLabelFindButtonNext: String, accessibilityLabelFindButtonPrevious: String, accessibilityLabelReplaceTextField: String, accessibilityLabelReplaceButtonClear: String, accessibilityLabelReplaceButtonPerformFormat: String, accessibilityLabelReplaceButtonSwitchFormat: String, accessibilityLabelReplaceTypeSingle: String, accessibilityLabelReplaceTypeAll: String) { self.inputViewTextFormatting = inputViewTextFormatting self.inputViewStyle = inputViewStyle self.inputViewClearFormatting = inputViewClearFormatting @@ -84,7 +82,6 @@ public struct WKSourceEditorLocalizedStrings { self.findReplaceTypeAll = findReplaceTypeAll self.findReplaceWith = findReplaceWith self.accessibilityLabelButtonFormatText = accessibilityLabelButtonFormatText - self.accessibilityLabelButtonFormatHeading = accessibilityLabelButtonFormatHeading self.accessibilityLabelButtonCitation = accessibilityLabelButtonCitation self.accessibilityLabelButtonCitationSelected = accessibilityLabelButtonCitationSelected self.accessibilityLabelButtonLink = accessibilityLabelButtonLink @@ -107,7 +104,6 @@ public struct WKSourceEditorLocalizedStrings { self.accessibilityLabelButtonBoldSelected = accessibilityLabelButtonBoldSelected self.accessibilityLabelButtonItalics = accessibilityLabelButtonItalics self.accessibilityLabelButtonItalicsSelected = accessibilityLabelButtonItalicsSelected - self.accessibilityLabelButtonClearFormatting = accessibilityLabelButtonClearFormatting self.accessibilityLabelButtonShowMore = accessibilityLabelButtonShowMore self.accessibilityLabelButtonComment = accessibilityLabelButtonComment self.accessibilityLabelButtonCommentSelected = accessibilityLabelButtonCommentSelected diff --git a/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorViewController.swift b/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorViewController.swift index ec420035e5a..fb0a28569e9 100644 --- a/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorViewController.swift +++ b/Components/Sources/Components/Components/Editors/Source Editor/WKSourceEditorViewController.swift @@ -20,12 +20,7 @@ extension Notification { public class WKSourceEditorViewController: WKComponentViewController { // MARK: Nested Types - - enum InputViewType { - case main - case headerSelect - } - + enum InputAccessoryViewType { case expanding case highlight @@ -68,64 +63,24 @@ public class WKSourceEditorViewController: WKComponentViewController { // Input Views - private var _mainInputView: UIView? - private var mainInputView: UIView? { - get { - guard _mainInputView == nil else { - return _mainInputView - } - - let inputViewController = WKEditorInputViewController(configuration: .rootMain, delegate: self) - inputViewController.loadViewIfNeeded() - - _mainInputView = inputViewController.view - - return inputViewController.view - } - set { - _mainInputView = newValue - } - } - - private var _headerSelectionInputView: UIView? - private var headerSelectionInputView: UIView? { - get { - guard _headerSelectionInputView == nil else { - return _headerSelectionInputView - } - - let inputViewController = WKEditorInputViewController(configuration: .rootHeaderSelect, delegate: self) - inputViewController.loadViewIfNeeded() - - _headerSelectionInputView = inputViewController.view - - return inputViewController.view - } - set { - _headerSelectionInputView = newValue - } - } + private lazy var editorInputView: UIView? = { + let inputView = WKEditorInputView(delegate: self) + inputView.accessibilityIdentifier = WKSourceEditorAccessibilityIdentifiers.current?.inputView + return inputView + }() - // Input Types + // Input Tracking Properties - var inputViewType: InputViewType? = nil { + var editorInputViewIsShowing: Bool? = false { didSet { - guard let inputViewType else { - mainInputView = nil - headerSelectionInputView = nil + guard editorInputViewIsShowing == true else { textView.inputView = nil textView.reloadInputViews() return } - switch inputViewType { - case .main: - textView.inputView = mainInputView - case .headerSelect: - textView.inputView = headerSelectionInputView - } - + textView.inputView = editorInputView textView.inputAccessoryView = nil textView.reloadInputViews() } @@ -278,7 +233,7 @@ private extension WKSourceEditorViewController { extension WKSourceEditorViewController: UITextViewDelegate { public func textViewDidChangeSelection(_ textView: UITextView) { - guard inputViewType == nil else { + guard editorInputViewIsShowing == false else { postUpdateButtonSelectionStatesNotification(withDelay: false) return } @@ -298,14 +253,10 @@ extension WKSourceEditorViewController: WKEditorToolbarExpandingViewDelegate { } func toolbarExpandingViewDidTapFormatText(toolbarView: WKEditorToolbarExpandingView) { - inputViewType = .main + editorInputViewIsShowing = true postUpdateButtonSelectionStatesNotification(withDelay: true) } - func toolbarExpandingViewDidTapFormatHeading(toolbarView: WKEditorToolbarExpandingView) { - inputViewType = .headerSelect - } - func toolbarExpandingViewDidTapTemplate(toolbarView: WKEditorToolbarExpandingView, isSelected: Bool) { let action: WKSourceEditorFormatterButtonAction = isSelected ? .remove : .add textFrameworkMediator.templateFormatter?.toggleTemplateFormatting(action: action, in: textView) @@ -350,13 +301,9 @@ extension WKSourceEditorViewController: WKEditorToolbarHighlightViewDelegate { } func toolbarHighlightViewDidTapShowMore(toolbarView: WKEditorToolbarHighlightView) { - inputViewType = .main + editorInputViewIsShowing = true postUpdateButtonSelectionStatesNotification(withDelay: true) } - - func toolbarHighlightViewDidTapFormatHeading(toolbarView: WKEditorToolbarHighlightView) { - inputViewType = .headerSelect - } } // MARK: - WKEditorInputViewDelegate @@ -402,7 +349,7 @@ extension WKSourceEditorViewController: WKEditorInputViewDelegate { } func didTapClose() { - inputViewType = nil + editorInputViewIsShowing = false let isRangeSelected = textView.selectedRange.length > 0 inputAccessoryViewType = isRangeSelected ? .highlight : .expanding } diff --git a/Components/Sources/Components/Style/WKIcon.swift b/Components/Sources/Components/Style/WKIcon.swift index 5f305d5ec66..7ce631d8501 100644 --- a/Components/Sources/Components/Style/WKIcon.swift +++ b/Components/Sources/Components/Style/WKIcon.swift @@ -25,7 +25,6 @@ public enum WKIcon { static let userContributions = UIImage(named: "user-contributions", in: .module, with: nil) // Editor-specific icons - static let clear = UIImage(named: "editor/clear", in: .module, with: nil) // static let formatText = UIImage(named: "editor/format-text", in: .module, with: nil)// static let formatHeading = UIImage(named: "editor/format-heading", in: .module, with: nil)// diff --git a/Components/Sources/ComponentsObjC/WKSourceEditorFormatterBoldItalics.m b/Components/Sources/ComponentsObjC/WKSourceEditorFormatterBoldItalics.m index 9699ebe0366..58b608816f0 100644 --- a/Components/Sources/ComponentsObjC/WKSourceEditorFormatterBoldItalics.m +++ b/Components/Sources/ComponentsObjC/WKSourceEditorFormatterBoldItalics.m @@ -277,7 +277,6 @@ - (void)updateFonts:(WKSourceEditorFonts *)fonts inAttributedString:(NSMutableAt - (BOOL)attributedString:(NSMutableAttributedString *)attributedString isBoldInRange:(NSRange)range { return [self attributedString:attributedString isFormattedInRange:range formattingKey:WKSourceEditorCustomKeyFontBold]; } - - (BOOL)attributedString:(NSMutableAttributedString *)attributedString isItalicsInRange:(NSRange)range { return [self attributedString:attributedString isFormattedInRange:range formattingKey:WKSourceEditorCustomKeyFontItalics]; } @@ -291,14 +290,13 @@ - (BOOL)attributedString:(NSMutableAttributedString *)attributedString isFormatt if (attributedString.length > range.location) { NSDictionary *attrs = [attributedString attributesAtIndex:range.location effectiveRange:nil]; - - if (attrs[WKSourceEditorCustomKeyFontBoldItalics] != nil || attrs[WKSourceEditorCustomKeyFontItalics] != nil) { + if (attrs[WKSourceEditorCustomKeyFontBoldItalics] != nil || attrs[formattingKey] != nil) { isFormatted = YES; } else { // Edge case, check previous character if we are up against a closing bold or italic if (attrs[WKSourceEditorCustomKeyColorOrange]) { attrs = [attributedString attributesAtIndex:range.location - 1 effectiveRange:nil]; - if (attrs[WKSourceEditorCustomKeyFontBold] != nil || attrs[WKSourceEditorCustomKeyFontItalics] != nil) { + if (attrs[WKSourceEditorCustomKeyFontBoldItalics] != nil || attrs[formattingKey] != nil) { isFormatted = YES; } } diff --git a/Components/Sources/ComponentsObjC/WKSourceEditorFormatterTemplate.m b/Components/Sources/ComponentsObjC/WKSourceEditorFormatterTemplate.m index 375d432ebeb..b2e5bc1e321 100644 --- a/Components/Sources/ComponentsObjC/WKSourceEditorFormatterTemplate.m +++ b/Components/Sources/ComponentsObjC/WKSourceEditorFormatterTemplate.m @@ -33,8 +33,8 @@ - (instancetype)initWithColors:(WKSourceEditorColors *)colors fonts:(WKSourceEdi WKSourceEditorCustomKeyVerticalTemplate: [NSNumber numberWithBool:YES] }; - _horizontalTemplateRegex = [[NSRegularExpression alloc] initWithPattern:@"\\{{2}[^\\{\\}\\n]*\\}{2}" options:0 error:nil]; - _verticalStartTemplateRegex = [[NSRegularExpression alloc] initWithPattern:@"^\\{{2}[^\\{\\}\\n]*$" options:NSRegularExpressionAnchorsMatchLines error:nil]; + _horizontalTemplateRegex = [[NSRegularExpression alloc] initWithPattern:@"\\{{2}[^\\{\\}\\n]*(?:\\{{2}[^\\{\\}\\n]*\\}{2})*[^\\{\\}\\n]*\\}{2}" options:0 error:nil]; + _verticalStartTemplateRegex = [[NSRegularExpression alloc] initWithPattern:@"^(?:.*)(\\{{2}[^\\{\\}\\n]*)$" options:NSRegularExpressionAnchorsMatchLines error:nil]; _verticalParameterTemplateRegex = [[NSRegularExpression alloc] initWithPattern:@"^\\s*\\|.*$" options:NSRegularExpressionAnchorsMatchLines error:nil]; _verticalEndTemplateRegex = [[NSRegularExpression alloc] initWithPattern:@"^([^\\{\\}\n]*\\}{2})(?:.)*$" options:NSRegularExpressionAnchorsMatchLines error:nil]; } @@ -64,11 +64,12 @@ - (void)addSyntaxHighlightingToAttributedString:(nonnull NSMutableAttributedStri options:0 range:range usingBlock:^(NSTextCheckingResult *_Nullable result, NSMatchingFlags flags, BOOL *_Nonnull stop) { - NSRange matchRange = [result rangeAtIndex:0]; + NSRange fullMatch = [result rangeAtIndex:0]; + NSRange openingTemplateRange = [result rangeAtIndex:1]; - if (matchRange.location != NSNotFound) { - [attributedString addAttributes:self.verticalTemplateAttributes range:matchRange]; - } + if (fullMatch.location != NSNotFound && openingTemplateRange.location != NSNotFound) { + [attributedString addAttributes:self.verticalTemplateAttributes range:openingTemplateRange]; + } }]; [self.verticalParameterTemplateRegex enumerateMatchesInString:attributedString.string @@ -86,12 +87,14 @@ - (void)addSyntaxHighlightingToAttributedString:(nonnull NSMutableAttributedStri options:0 range:range usingBlock:^(NSTextCheckingResult *_Nullable result, NSMatchingFlags flags, BOOL *_Nonnull stop) { + NSRange fullMatch = [result rangeAtIndex:0]; NSRange closingTemplateRange = [result rangeAtIndex:1]; - if (fullMatch.location != NSNotFound && closingTemplateRange.location != NSNotFound) { - [attributedString addAttributes:self.verticalTemplateAttributes range:closingTemplateRange]; - } + if (fullMatch.location != NSNotFound && closingTemplateRange.location != NSNotFound) { + [attributedString addAttributes:self.verticalTemplateAttributes range:closingTemplateRange]; + } + }]; } diff --git a/Components/Tests/ComponentsTests/WKSourceEditorFormatterButtonActionTests.swift b/Components/Tests/ComponentsTests/WKSourceEditorFormatterButtonActionTests.swift index ced191e28d0..391fb576903 100644 --- a/Components/Tests/ComponentsTests/WKSourceEditorFormatterButtonActionTests.swift +++ b/Components/Tests/ComponentsTests/WKSourceEditorFormatterButtonActionTests.swift @@ -42,7 +42,7 @@ final class WKSourceEditorFormatterButtonActionTests: XCTestCase { XCTAssertEqual(mediator.textView.attributedText.string, "One Two Three Four") } - func testSingleBoldRemove() throws { + func testCursorBoldRemove() throws { let text = "One '''Two''' Three Four" mediator.textView.attributedText = NSAttributedString(string: text) mediator.textView.selectedRange = NSRange(location: 8, length: 0) // Just a cursor inside Two @@ -50,7 +50,7 @@ final class WKSourceEditorFormatterButtonActionTests: XCTestCase { XCTAssertEqual(mediator.textView.attributedText.string, "One Two Three Four") } - func testSingleItalicsRemove() throws { + func testCursorItalicsRemove() throws { let text = "One Two '''Three''' Four" mediator.textView.attributedText = NSAttributedString(string: text) mediator.textView.selectedRange = NSRange(location: 14, length: 0) @@ -77,7 +77,7 @@ final class WKSourceEditorFormatterButtonActionTests: XCTestCase { XCTAssertEqual(mediator.textView.attributedText.string, "One Two Three Four") } - func testSingleBoldInsertAndRemove() throws { + func testCursorBoldInsertAndRemove() throws { let text = "One Two Three Four" mediator.textView.attributedText = NSAttributedString(string: text) mediator.textView.selectedRange = NSRange(location: 4, length: 0) // Just a cursor before Two @@ -87,7 +87,7 @@ final class WKSourceEditorFormatterButtonActionTests: XCTestCase { XCTAssertEqual(mediator.textView.attributedText.string, "One Two Three Four") } - func testSingleItalicsInsertAndRemove() throws { + func testCursorItalicsInsertAndRemove() throws { let text = "One Two Three Four" mediator.textView.attributedText = NSAttributedString(string: text) mediator.textView.selectedRange = NSRange(location: 4, length: 0) // Just a cursor before Two @@ -97,6 +97,46 @@ final class WKSourceEditorFormatterButtonActionTests: XCTestCase { XCTAssertEqual(mediator.textView.attributedText.string, "One Two Three Four") } + func testBoldInnerRemoveAndInsert() throws { + let text = "One '''Two Three Four''' Five" + mediator.textView.attributedText = NSAttributedString(string: text) + mediator.textView.selectedRange = NSRange(location: 11, length: 5) // Selected Three + mediator.boldItalicsFormatter?.toggleBoldFormatting(action: .remove, in: mediator.textView) + XCTAssertEqual(mediator.textView.attributedText.string, "One '''Two '''Three''' Four''' Five") + mediator.boldItalicsFormatter?.toggleBoldFormatting(action: .remove, in: mediator.textView) + XCTAssertEqual(mediator.textView.attributedText.string, "One '''Two Three Four''' Five") + } + + func testItalicsInnerRemoveAndInsert() throws { + let text = "One ''Two Three Four'' Five" + mediator.textView.attributedText = NSAttributedString(string: text) + mediator.textView.selectedRange = NSRange(location: 10, length: 5) // Selected Three + mediator.boldItalicsFormatter?.toggleItalicsFormatting(action: .remove, in: mediator.textView) + XCTAssertEqual(mediator.textView.attributedText.string, "One ''Two ''Three'' Four'' Five") + mediator.boldItalicsFormatter?.toggleItalicsFormatting(action: .remove, in: mediator.textView) + XCTAssertEqual(mediator.textView.attributedText.string, "One ''Two Three Four'' Five") + } + + func testBoldItalicsInnerRemoveBoldAndInsert() throws { + let text = "One '''''Two Three Four''''' Five" + mediator.textView.attributedText = NSAttributedString(string: text) + mediator.textView.selectedRange = NSRange(location: 13, length: 5) // Selected Three + mediator.boldItalicsFormatter?.toggleBoldFormatting(action: .remove, in: mediator.textView) + XCTAssertEqual(mediator.textView.attributedText.string, "One '''''Two '''Three''' Four''''' Five") + mediator.boldItalicsFormatter?.toggleBoldFormatting(action: .remove, in: mediator.textView) + XCTAssertEqual(mediator.textView.attributedText.string, "One '''''Two Three Four''''' Five") + } + + func testBoldItalicsInnerRemoveItalicsAndInsert() throws { + let text = "One '''''Two Three Four''''' Five" + mediator.textView.attributedText = NSAttributedString(string: text) + mediator.textView.selectedRange = NSRange(location: 13, length: 5) // Selected Three + mediator.boldItalicsFormatter?.toggleItalicsFormatting(action: .remove, in: mediator.textView) + XCTAssertEqual(mediator.textView.attributedText.string, "One '''''Two ''Three'' Four''''' Five") + mediator.boldItalicsFormatter?.toggleItalicsFormatting(action: .remove, in: mediator.textView) + XCTAssertEqual(mediator.textView.attributedText.string, "One '''''Two Three Four''''' Five") + } + func testTemplateInsert() throws { let text = "One Two Three Four" mediator.textView.attributedText = NSAttributedString(string: text) @@ -113,7 +153,7 @@ final class WKSourceEditorFormatterButtonActionTests: XCTestCase { XCTAssertEqual(mediator.textView.attributedText.string, "One Two Three Four") } - func testSingleTemplateInsertAndRemove() throws { + func testCursorTemplateInsertAndRemove() throws { let text = "One Two Three Four" mediator.textView.attributedText = NSAttributedString(string: text) mediator.textView.selectedRange = NSRange(location: 4, length: 0) // Just a cursor before Two diff --git a/Components/Tests/ComponentsTests/WKSourceEditorFormatterTests.swift b/Components/Tests/ComponentsTests/WKSourceEditorFormatterTests.swift index 189134c87c0..56c2a3ce9ce 100644 --- a/Components/Tests/ComponentsTests/WKSourceEditorFormatterTests.swift +++ b/Components/Tests/ComponentsTests/WKSourceEditorFormatterTests.swift @@ -635,7 +635,43 @@ final class WKSourceEditorFormatterTests: XCTestCase { XCTAssertEqual(refClosingAttributes[.foregroundColor] as! UIColor, colors.baseForegroundColor, "Incorrect ref formatting") } - func testVerticalStartTemplate() { + func testHorizontalNestedTemplate() { + let string = "Ford Island ({{lang-haw|Poka {{okina}}Ailana}}) is an" + let mutAttributedString = NSMutableAttributedString(string: string) + + for formatter in formatters { + formatter.addSyntaxHighlighting(to: mutAttributedString, in: NSRange(location: 0, length: string.count)) + } + + var base1Range = NSRange(location: 0, length: 0) + let base1Attributes = mutAttributedString.attributes(at: 0, effectiveRange: &base1Range) + + var templateRange = NSRange(location: 0, length: 0) + let templateAttributes = mutAttributedString.attributes(at: 13, effectiveRange: &templateRange) + + var base2Range = NSRange(location: 0, length: 0) + let base2Attributes = mutAttributedString.attributes(at: 46, effectiveRange: &base2Range) + + // "Ford Island (" + XCTAssertEqual(base1Range.location, 0, "Incorrect base formatting") + XCTAssertEqual(base1Range.length, 13, "Incorrect base formatting") + XCTAssertEqual(base1Attributes[.font] as! UIFont, fonts.baseFont, "Incorrect base formatting") + XCTAssertEqual(base1Attributes[.foregroundColor] as! UIColor, colors.baseForegroundColor, "Incorrect base formatting") + + // "{{lang-haw|Poka {{okina}}Ailana}}" + XCTAssertEqual(templateRange.location, 13, "Incorrect template formatting") + XCTAssertEqual(templateRange.length, 33, "Incorrect template formatting") + XCTAssertEqual(templateAttributes[.font] as! UIFont, fonts.baseFont, "Incorrect template formatting") + XCTAssertEqual(templateAttributes[.foregroundColor] as! UIColor, colors.purpleForegroundColor, "Incorrect template formatting") + + // ") is an" + XCTAssertEqual(base2Range.location, 46, "Incorrect base formatting") + XCTAssertEqual(base2Range.length, 7, "Incorrect base formatting") + XCTAssertEqual(base2Attributes[.font] as! UIFont, fonts.baseFont, "Incorrect base formatting") + XCTAssertEqual(base2Attributes[.foregroundColor] as! UIColor, colors.baseForegroundColor, "Incorrect base formatting") + } + + func testVerticalStartTemplate1() { let string = "{{Infobox officeholder" let mutAttributedString = NSMutableAttributedString(string: string) @@ -653,6 +689,33 @@ final class WKSourceEditorFormatterTests: XCTestCase { XCTAssertEqual(templateAttributes[.foregroundColor] as! UIColor, colors.purpleForegroundColor, "Incorrect template formatting") } + func testVerticalStartTemplate2() { + let string = "ending of previous sentence. {{cite web" + let mutAttributedString = NSMutableAttributedString(string: string) + + for formatter in formatters { + formatter.addSyntaxHighlighting(to: mutAttributedString, in: NSRange(location: 0, length: string.count)) + } + + var baseRange = NSRange(location: 0, length: 0) + let baseAttributes = mutAttributedString.attributes(at: 0, effectiveRange: &baseRange) + + var templateRange = NSRange(location: 0, length: 0) + let templateAttributes = mutAttributedString.attributes(at: 29, effectiveRange: &templateRange) + + // "ending of previous sentence. " + XCTAssertEqual(baseRange.location, 0, "Incorrect base formatting") + XCTAssertEqual(baseRange.length, 29, "Incorrect base formatting") + XCTAssertEqual(baseAttributes[.font] as! UIFont, fonts.baseFont, "Incorrect base formatting") + XCTAssertEqual(baseAttributes[.foregroundColor] as! UIColor, colors.baseForegroundColor, "Incorrect base formatting") + + // "ending of previous sentence. " + XCTAssertEqual(templateRange.location, 29, "Incorrect template formatting") + XCTAssertEqual(templateRange.length, 10, "Incorrect template formatting") + XCTAssertEqual(templateAttributes[.font] as! UIFont, fonts.baseFont, "Incorrect template formatting") + XCTAssertEqual(templateAttributes[.foregroundColor] as! UIColor, colors.purpleForegroundColor, "Incorrect base formatting") + } + func testVerticalParameterTemplate() { let string = "| genus = Felis" let mutAttributedString = NSMutableAttributedString(string: string) diff --git a/Components/Tests/ComponentsTests/WKSourceEditorTests.swift b/Components/Tests/ComponentsTests/WKSourceEditorTests.swift index 3e2af01ed72..a31a3cad7dc 100644 --- a/Components/Tests/ComponentsTests/WKSourceEditorTests.swift +++ b/Components/Tests/ComponentsTests/WKSourceEditorTests.swift @@ -59,7 +59,6 @@ extension WKSourceEditorLocalizedStrings { findReplaceTypeAll: "", findReplaceWith: "", accessibilityLabelButtonFormatText: "", - accessibilityLabelButtonFormatHeading: "", accessibilityLabelButtonCitation: "", accessibilityLabelButtonCitationSelected: "", accessibilityLabelButtonLink: "", @@ -82,7 +81,6 @@ extension WKSourceEditorLocalizedStrings { accessibilityLabelButtonBoldSelected: "", accessibilityLabelButtonItalics: "", accessibilityLabelButtonItalicsSelected: "", - accessibilityLabelButtonClearFormatting: "", accessibilityLabelButtonShowMore: "", accessibilityLabelButtonComment: "", accessibilityLabelButtonCommentSelected: "", diff --git a/WMF Framework/CommonStrings.swift b/WMF Framework/CommonStrings.swift index bf7c3cf4bfd..25da28b12a1 100644 --- a/WMF Framework/CommonStrings.swift +++ b/WMF Framework/CommonStrings.swift @@ -535,7 +535,6 @@ public class CommonStrings: NSObject { public static let findAndReplaceAll = WMFLocalizedString("source-editor-find-replace-all", value: "Replace all", comment: "Label for replace all ocurrences of a string on the page editor") public static let replaceWith = WMFLocalizedString("source-editor-find-replace-with", value: "Replace with...", comment: "Lable for replace with string button on page editor") public static let accessibilityLabelButtonFormatText = WMFLocalizedString("source-editor-accessibility-label-format-text", value: "Show text formatting menu", comment: "Accessibility label for text formatting menu button on the page editor") - public static let accessibilityLabelButtonFormatHeading = WMFLocalizedString("source-editor-accessibility-label-format-heading", value: "Show text style menu", comment: "Accessibility label for heading style formatting menu button on the page editor") public static let accessibilityLabelButtonCitation = WMFLocalizedString("source-editor-accessibility-label-citation", value: "Add reference syntax", comment: "Accessibility label for add reference syntax button on the page editor") public static let accessibilityLabelButtonCitationSelected = WMFLocalizedString("source-editor-accessibility-label-citation-selected", value: "Remove reference syntax", comment: "Accessibility label for remove reference syntax button on the page editor") public static let accessibilityLabelButtonLink = WMFLocalizedString("source-editor-accessibility-label-link", value: "Add link syntax", comment: "Accessibility label for the add link syntax button on the page editor") diff --git a/Wikipedia/Code/PageEditorViewController.swift b/Wikipedia/Code/PageEditorViewController.swift index be88b879715..e89fc8c9df6 100644 --- a/Wikipedia/Code/PageEditorViewController.swift +++ b/Wikipedia/Code/PageEditorViewController.swift @@ -116,7 +116,6 @@ final class PageEditorViewController: UIViewController { findReplaceTypeAll: CommonStrings.findAndReplaceAll, findReplaceWith: CommonStrings.replaceWith, accessibilityLabelButtonFormatText: CommonStrings.accessibilityLabelButtonFormatText, - accessibilityLabelButtonFormatHeading: CommonStrings.accessibilityLabelButtonFormatHeading, accessibilityLabelButtonCitation: CommonStrings.accessibilityLabelButtonCitation, accessibilityLabelButtonCitationSelected: CommonStrings.accessibilityLabelButtonCitationSelected, accessibilityLabelButtonLink: CommonStrings.accessibilityLabelButtonBold, @@ -139,7 +138,6 @@ final class PageEditorViewController: UIViewController { accessibilityLabelButtonBoldSelected: CommonStrings.accessibilityLabelButtonBoldSelected, accessibilityLabelButtonItalics: CommonStrings.accessibilityLabelButtonItalics, accessibilityLabelButtonItalicsSelected: CommonStrings.accessibilityLabelButtonItalicsSelected, - accessibilityLabelButtonClearFormatting: CommonStrings.accessibilityLabelButtonClearFormatting, accessibilityLabelButtonShowMore: CommonStrings.accessibilityLabelButtonShowMore, accessibilityLabelButtonComment: CommonStrings.accessibilityLabelButtonComment, accessibilityLabelButtonCommentSelected: CommonStrings.accessibilityLabelButtonCommentSelected, @@ -321,10 +319,8 @@ enum SourceEditorAccessibilityIdentifiers: String { case showMoreButton = "Source Editor Show More Button" case closeButton = "Source Editor Close Button" case formatTextButton = "Source Editor Format Text Button" - case formatHeadingButton = "Source Editor Format Heading Button" case expandingToolbar = "Source Editor Expanding Toolbar" case highlightToolbar = "Source Editor Highlight Toolbar" case findToolbar = "Source Editor Find Toolbar" - case mainInputView = "Source Editor Main Input View" - case headerSelectInputView = "Source Editor Header Select Input View" + case inputView = "Source Editor Input View" } diff --git a/Wikipedia/Localizations/en.lproj/Localizable.strings b/Wikipedia/Localizations/en.lproj/Localizable.strings index 55c4b77261c..6ed368c3bcc 100644 --- a/Wikipedia/Localizations/en.lproj/Localizable.strings +++ b/Wikipedia/Localizations/en.lproj/Localizable.strings @@ -1016,7 +1016,6 @@ "source-editor-accessibility-label-find-button-next" = "Next find result"; "source-editor-accessibility-label-find-button-prev" = "Previous find result"; "source-editor-accessibility-label-find-text-field" = "Find"; -"source-editor-accessibility-label-format-heading" = "Show text style menu"; "source-editor-accessibility-label-format-text" = "Show text formatting menu"; "source-editor-accessibility-label-format-text-show-more" = "Show text formatting menu"; "source-editor-accessibility-label-indent-decrease" = "Decrease indent depth"; diff --git a/Wikipedia/Localizations/qqq.lproj/Localizable.strings b/Wikipedia/Localizations/qqq.lproj/Localizable.strings index 83f677003b2..4c7b141f3a6 100644 --- a/Wikipedia/Localizations/qqq.lproj/Localizable.strings +++ b/Wikipedia/Localizations/qqq.lproj/Localizable.strings @@ -1016,7 +1016,6 @@ "source-editor-accessibility-label-find-button-next" = "Accessibility label for the find next result on the page editor"; "source-editor-accessibility-label-find-button-prev" = "Accessibility label for the find previous result button on the page editor"; "source-editor-accessibility-label-find-text-field" = "Accessibility label for the find text field on the page editor"; -"source-editor-accessibility-label-format-heading" = "Accessibility label for heading style formatting menu button on the page editor"; "source-editor-accessibility-label-format-text" = "Accessibility label for text formatting menu button on the page editor"; "source-editor-accessibility-label-format-text-show-more" = "Accessibility label for the show more button on the page editor"; "source-editor-accessibility-label-indent-decrease" = "Accessibility label for the decrease indent button on the page editor"; diff --git a/Wikipedia/iOS Native Localizations/en.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/en.lproj/Localizable.strings index bfb5c253979..345a8d92d79 100644 Binary files a/Wikipedia/iOS Native Localizations/en.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/en.lproj/Localizable.strings differ diff --git a/Wikipedia/iOS Native Localizations/he.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/he.lproj/Localizable.strings index fb90bd85718..41ce491d253 100644 Binary files a/Wikipedia/iOS Native Localizations/he.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/he.lproj/Localizable.strings differ diff --git a/Wikipedia/iOS Native Localizations/ia.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/ia.lproj/Localizable.strings index 1236b8bd7c1..1b283395206 100644 Binary files a/Wikipedia/iOS Native Localizations/ia.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/ia.lproj/Localizable.strings differ diff --git a/Wikipedia/iOS Native Localizations/it.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/it.lproj/Localizable.strings index ec3156c017f..5d3bc7337ea 100644 Binary files a/Wikipedia/iOS Native Localizations/it.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/it.lproj/Localizable.strings differ diff --git a/Wikipedia/iOS Native Localizations/mk.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/mk.lproj/Localizable.strings index 70c5f7949c9..40a35134468 100644 Binary files a/Wikipedia/iOS Native Localizations/mk.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/mk.lproj/Localizable.strings differ diff --git a/Wikipedia/iOS Native Localizations/pt.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/pt.lproj/Localizable.strings index 7d93c3a6044..28f3d5330ea 100644 Binary files a/Wikipedia/iOS Native Localizations/pt.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/pt.lproj/Localizable.strings differ diff --git a/Wikipedia/iOS Native Localizations/sl.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/sl.lproj/Localizable.strings index 75ce7e60ffa..20447217123 100644 Binary files a/Wikipedia/iOS Native Localizations/sl.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/sl.lproj/Localizable.strings differ diff --git a/Wikipedia/iOS Native Localizations/sv.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/sv.lproj/Localizable.strings index 2fbd790dcd7..6bd8880be7a 100644 Binary files a/Wikipedia/iOS Native Localizations/sv.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/sv.lproj/Localizable.strings differ diff --git a/Wikipedia/iOS Native Localizations/tr.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/tr.lproj/Localizable.strings index 6d2386dd534..648cc7ac3ca 100644 Binary files a/Wikipedia/iOS Native Localizations/tr.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/tr.lproj/Localizable.strings differ diff --git a/Wikipedia/iOS Native Localizations/zh-hant.lproj/Localizable.strings b/Wikipedia/iOS Native Localizations/zh-hant.lproj/Localizable.strings index 46cf90753c2..560bd496c0f 100644 Binary files a/Wikipedia/iOS Native Localizations/zh-hant.lproj/Localizable.strings and b/Wikipedia/iOS Native Localizations/zh-hant.lproj/Localizable.strings differ diff --git a/WikipediaUITests/UITestHelperViewController.swift b/WikipediaUITests/UITestHelperViewController.swift index e37203818af..7e78ec0431e 100644 --- a/WikipediaUITests/UITestHelperViewController.swift +++ b/WikipediaUITests/UITestHelperViewController.swift @@ -53,7 +53,6 @@ public class UITestHelperViewController: WKCanvasViewController { findReplaceTypeAll: CommonStrings.findAndReplaceAll, findReplaceWith: CommonStrings.replaceWith, accessibilityLabelButtonFormatText: CommonStrings.accessibilityLabelButtonFormatText, - accessibilityLabelButtonFormatHeading: CommonStrings.accessibilityLabelButtonFormatHeading, accessibilityLabelButtonCitation: CommonStrings.accessibilityLabelButtonCitation, accessibilityLabelButtonCitationSelected: CommonStrings.accessibilityLabelButtonCitationSelected, accessibilityLabelButtonLink: CommonStrings.accessibilityLabelButtonBold, @@ -76,7 +75,6 @@ public class UITestHelperViewController: WKCanvasViewController { accessibilityLabelButtonBoldSelected: CommonStrings.accessibilityLabelButtonBoldSelected, accessibilityLabelButtonItalics: CommonStrings.accessibilityLabelButtonItalics, accessibilityLabelButtonItalicsSelected: CommonStrings.accessibilityLabelButtonItalicsSelected, - accessibilityLabelButtonClearFormatting: CommonStrings.accessibilityLabelButtonClearFormatting, accessibilityLabelButtonShowMore: CommonStrings.accessibilityLabelButtonShowMore, accessibilityLabelButtonComment: CommonStrings.accessibilityLabelButtonComment, accessibilityLabelButtonCommentSelected: CommonStrings.accessibilityLabelButtonCommentSelected, @@ -108,12 +106,10 @@ public class UITestHelperViewController: WKCanvasViewController { showMoreButton: SourceEditorAccessibilityIdentifiers.showMoreButton.rawValue, closeButton: SourceEditorAccessibilityIdentifiers.closeButton.rawValue, formatTextButton: SourceEditorAccessibilityIdentifiers.formatTextButton.rawValue, - formatHeadingButton: SourceEditorAccessibilityIdentifiers.formatHeadingButton.rawValue, expandingToolbar: SourceEditorAccessibilityIdentifiers.expandingToolbar.rawValue, highlightToolbar: SourceEditorAccessibilityIdentifiers.highlightToolbar.rawValue, findToolbar: SourceEditorAccessibilityIdentifiers.findButton.rawValue, - mainInputView: SourceEditorAccessibilityIdentifiers.mainInputView.rawValue, - headerSelectInputView: SourceEditorAccessibilityIdentifiers.headerSelectInputView.rawValue + inputView: SourceEditorAccessibilityIdentifiers.inputView.rawValue ) let textAlignment: NSTextAlignment = UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft ? .right : .left diff --git a/WikipediaUITests/WKSourceEditorUITests.swift b/WikipediaUITests/WKSourceEditorUITests.swift index e426c1656e0..d0665794997 100644 --- a/WikipediaUITests/WKSourceEditorUITests.swift +++ b/WikipediaUITests/WKSourceEditorUITests.swift @@ -18,8 +18,7 @@ final class WKSourceEditorUITests: XCTestCase { textView.tap() textView.typeText("Hello World!") - XCTAssertFalse(app.isDisplayingMainInputView) - XCTAssertFalse(app.isDisplayingHeaderSelectView) + XCTAssertFalse(app.isDisplayingInputView) XCTAssertTrue(app.isDisplayingExpandingToolbar) XCTAssertFalse(app.isDisplayingHighlightingToolbar) XCTAssertFalse(app.isDisplayingFindAndReplaceToolbar) @@ -30,8 +29,7 @@ final class WKSourceEditorUITests: XCTestCase { textView.doubleTap() - XCTAssertFalse(app.isDisplayingMainInputView) - XCTAssertFalse(app.isDisplayingHeaderSelectView) + XCTAssertFalse(app.isDisplayingInputView) XCTAssertFalse(app.isDisplayingExpandingToolbar) XCTAssertTrue(app.isDisplayingHighlightingToolbar) XCTAssertFalse(app.isDisplayingFindAndReplaceToolbar) @@ -42,8 +40,7 @@ final class WKSourceEditorUITests: XCTestCase { app.buttons["Source Editor Show More Button"].tap() - XCTAssertTrue(app.isDisplayingMainInputView) - XCTAssertFalse(app.isDisplayingHeaderSelectView) + XCTAssertTrue(app.isDisplayingInputView) XCTAssertFalse(app.isDisplayingExpandingToolbar) XCTAssertFalse(app.isDisplayingHighlightingToolbar) XCTAssertFalse(app.isDisplayingFindAndReplaceToolbar) @@ -54,8 +51,7 @@ final class WKSourceEditorUITests: XCTestCase { app.buttons["Source Editor Format Text Button"].tap() - XCTAssertTrue(app.isDisplayingMainInputView) - XCTAssertFalse(app.isDisplayingHeaderSelectView) + XCTAssertTrue(app.isDisplayingInputView) XCTAssertFalse(app.isDisplayingExpandingToolbar) XCTAssertFalse(app.isDisplayingHighlightingToolbar) XCTAssertFalse(app.isDisplayingFindAndReplaceToolbar) @@ -64,36 +60,6 @@ final class WKSourceEditorUITests: XCTestCase { mainInputViewAttachment.name = ScreenshotNames.main.rawValue add(mainInputViewAttachment) - app.tables.element(boundBy: 0).cells.element(boundBy: 2).tap() - - XCTAssertFalse(app.isDisplayingMainInputView) - XCTAssertTrue(app.isDisplayingHeaderSelectView) - XCTAssertFalse(app.isDisplayingExpandingToolbar) - XCTAssertFalse(app.isDisplayingHighlightingToolbar) - XCTAssertFalse(app.isDisplayingFindAndReplaceToolbar) - - app.tables.element(boundBy: 0).cells.element(boundBy: 0).tap() - - let headerSelectInputView1Attachment = XCTAttachment(screenshot: app.screenshot()) - headerSelectInputView1Attachment.name = ScreenshotNames.headerSelect1.rawValue - add(headerSelectInputView1Attachment) - - app.buttons["Source Editor Close Button"].tap() - - app.buttons["Source Editor Format Heading Button"].tap() - - XCTAssertFalse(app.isDisplayingMainInputView) - XCTAssertTrue(app.isDisplayingHeaderSelectView) - XCTAssertFalse(app.isDisplayingExpandingToolbar) - XCTAssertFalse(app.isDisplayingHighlightingToolbar) - XCTAssertFalse(app.isDisplayingFindAndReplaceToolbar) - - app.tables.element(boundBy: 0).cells.element(boundBy: 2).tap() - - let headerSelectInputView2Attachment = XCTAttachment(screenshot: app.screenshot()) - headerSelectInputView2Attachment.name = ScreenshotNames.headerSelect2.rawValue - add(headerSelectInputView2Attachment) - app.buttons["Source Editor Close Button"].tap() app.buttons["Source Editor Find Button"].tap() @@ -117,12 +83,8 @@ extension XCUIApplication { return otherElements["Source Editor Find Toolbar"].exists } - var isDisplayingMainInputView: Bool { - return otherElements[ "Source Editor Main Input View"].exists - } - - var isDisplayingHeaderSelectView: Bool { - return otherElements["Source Editor Header Select Input View"].exists + var isDisplayingInputView: Bool { + return otherElements[ "Source Editor Input View"].exists } }