Skip to content

Commit

Permalink
Add delegate callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
tonisevener committed Dec 15, 2023
1 parent 9a26746 commit bfb1e46
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ protocol WKEditorToolbarExpandingViewDelegate: AnyObject {
func toolbarExpandingViewDidTapFormatText(toolbarView: WKEditorToolbarExpandingView)
func toolbarExpandingViewDidTapFormatHeading(toolbarView: WKEditorToolbarExpandingView)
func toolbarExpandingViewDidTapTemplate(toolbarView: WKEditorToolbarExpandingView, isSelected: Bool)
func toolbarExpandingViewDidTapReference(toolbarView: WKEditorToolbarExpandingView, isSelected: Bool)
}

class WKEditorToolbarExpandingView: WKEditorToolbarView {
Expand Down Expand Up @@ -201,6 +202,7 @@ class WKEditorToolbarExpandingView: WKEditorToolbarView {
}

@objc private func tappedReference() {
delegate?.toolbarExpandingViewDidTapReference(toolbarView: self, isSelected: referenceButton.isSelected)
}

@objc private func tappedLink() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ protocol WKEditorToolbarHighlightViewDelegate: AnyObject {
func toolbarHighlightViewDidTapBold(toolbarView: WKEditorToolbarHighlightView, isSelected: Bool)
func toolbarHighlightViewDidTapItalics(toolbarView: WKEditorToolbarHighlightView, isSelected: Bool)
func toolbarHighlightViewDidTapTemplate(toolbarView: WKEditorToolbarHighlightView, isSelected: Bool)
func toolbarHighlightViewDidTapReference(toolbarView: WKEditorToolbarHighlightView, isSelected: Bool)
func toolbarHighlightViewDidTapShowMore(toolbarView: WKEditorToolbarHighlightView)
func toolbarHighlightViewDidTapFormatHeading(toolbarView: WKEditorToolbarHighlightView)
}
Expand Down Expand Up @@ -97,6 +98,7 @@ class WKEditorToolbarHighlightView: WKEditorToolbarView {
}

@objc private func tappedReference() {
delegate?.toolbarHighlightViewDidTapReference(toolbarView: self, isSelected: referenceButton.isSelected)
}

@objc private func tappedLink() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class WKEditorToolbarPlainView: WKEditorToolbarView {
}

@objc private func tappedReference() {
delegate?.didTapReference(isSelected: referenceButton.isSelected)
}

@objc private func tappedTemplate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ protocol WKEditorInputViewDelegate: AnyObject {
func didTapBold(isSelected: Bool)
func didTapItalics(isSelected: Bool)
func didTapTemplate(isSelected: Bool)
func didTapReference(isSelected: Bool)
}

class WKEditorInputViewController: WKComponentViewController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ extension WKSourceEditorViewController: WKEditorToolbarExpandingViewDelegate {
let action: WKSourceEditorFormatterButtonAction = isSelected ? .remove : .add
textFrameworkMediator.templateFormatter?.toggleTemplateFormatting(action: action, in: textView)
}

func toolbarExpandingViewDidTapReference(toolbarView: WKEditorToolbarExpandingView, isSelected: Bool) {

}
}

// MARK: - WKEditorToolbarHighlightViewDelegate
Expand All @@ -331,6 +335,9 @@ extension WKSourceEditorViewController: WKEditorToolbarHighlightViewDelegate {
textFrameworkMediator.templateFormatter?.toggleTemplateFormatting(action: action, in: textView)
}

func toolbarHighlightViewDidTapReference(toolbarView: WKEditorToolbarHighlightView, isSelected: Bool) {
}

func toolbarHighlightViewDidTapShowMore(toolbarView: WKEditorToolbarHighlightView) {
inputViewType = .main
postUpdateButtonSelectionStatesNotification(withDelay: true)
Expand All @@ -344,6 +351,7 @@ extension WKSourceEditorViewController: WKEditorToolbarHighlightViewDelegate {
// MARK: - WKEditorInputViewDelegate

extension WKSourceEditorViewController: WKEditorInputViewDelegate {

func didTapBold(isSelected: Bool) {
let action: WKSourceEditorFormatterButtonAction = isSelected ? .remove : .add
textFrameworkMediator.boldItalicsFormatter?.toggleBoldFormatting(action: action, in: textView)
Expand All @@ -359,6 +367,10 @@ extension WKSourceEditorViewController: WKEditorInputViewDelegate {
textFrameworkMediator.templateFormatter?.toggleTemplateFormatting(action: action, in: textView)
}

func didTapReference(isSelected: Bool) {

}

func didTapClose() {
inputViewType = nil
let isRangeSelected = textView.selectedRange.length > 0
Expand Down

0 comments on commit bfb1e46

Please sign in to comment.