Skip to content

Commit

Permalink
Apply strikethrough selection state to input view
Browse files Browse the repository at this point in the history
  • Loading branch information
tonisevener committed Dec 15, 2023
1 parent e5eaf5f commit b76de52
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ class WKEditorToolbarGroupedView: WKEditorToolbarView {
strikethroughButton.setImage(WKSFSymbolIcon.for(symbol: .strikethrough), for: .normal)
strikethroughButton.addTarget(self, action: #selector(tappedStrikethrough), for: .touchUpInside)
strikethroughButton.accessibilityLabel = WKSourceEditorLocalizedStrings.current?.accessibilityLabelButtonStrikethrough

NotificationCenter.default.addObserver(self, selector: #selector(updateButtonSelectionState(_:)), name: Notification.WKSourceEditorSelectionState, object: nil)
}

// MARK: - Notifications

@objc private func updateButtonSelectionState(_ notification: NSNotification) {
guard let selectionState = notification.userInfo?[Notification.WKSourceEditorSelectionStateKey] as? WKSourceEditorSelectionState else {
return
}

strikethroughButton.isSelected = selectionState.isStrikethrough
}

// MARK: - Button Actions
Expand Down

0 comments on commit b76de52

Please sign in to comment.