wordpress-mobile / wordpress-mobile/AztecEditor-iOS
Provide default implementations for optional TextViewAttachmentDelegate functions
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 669
- Forks
- 153
- Avg merge
- 11h 27m
- Merged PRs (30d)
- 4
Description
Expected behavior
Some functions of the TextViewAttachmentDelegate protocol should be considered optional since the functionality they provide is not required for many instances of a TextView. Specifically, the selection and deselection functions are not necessary if the text view is not providing any custom behavior for these actions (for example, relying on the delete key to remove the attachment, and not providing any additional attachment features).
These should be made optional by providing an empty default implementation in an extension to TextViewAttachmentDelegate:
extension TextViewAttachmentDelegate {
func textView(_ textView: TextView, selected attachment: NSTextAttachment, atPosition position: CGPoint) { }
func textView(_ textView: TextView, deselected attachment: NSTextAttachment, atPosition position: CGPoint) { }
}
Actual behavior
The selection and deselection functions are unnecessarily required by any object conforming to TextViewAttachmentDelegate.
Steps to reproduce the behavior
Conform to TextViewAttachmentDelegate and attempt to compile without implementing the two mentioned functions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the TextViewAttachmentDelegate protocol and review its selection and deselection requirements. Add the default implementations described in the issue's extension example, then verify that a conforming type can compile without implementing those two functions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100