Skip to content

Conversation

@SergioEstevao
Copy link
Contributor

This PR implements the capability of undo redo when removing an attachment by pressing on it and select the option remove.

To test:

  • Start the demo app
  • open the demo with content
  • scroll to the coyote image
  • Tap on it
  • Tap again
  • Select Remove Media
  • Check if image was removed
  • Tap Undo
  • Check if image comes back again.

Copy link
Contributor

@diegoreymendez diegoreymendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments added.

}


/// Return the range of an attachment with the specified identifier if any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency: Let's make sure this comment is formatted with similar spacing as the rest of the comments.

}

/// Removes the attachments that match the attachament identifier provided from the storage
/// Removes the attachment that match the attachment identifier provided from the storage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "match" with "matches"

guard let range = storage.rangeFor(attachmentID: attachmentID) else {
return
}
let originalText = storage.attributedSubstring(from: range)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From line 983 to line 990 we're repeating code that's in several other places in TextView.swift

Why not implement in TextView.swift method

func replaceCharacters(in: range, with attrString: NSAttributedString)

to take care of unified undo support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion may I do this in another PR just dedicated to that refactor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

/// - Parameter attachmentID: the unique id of the attachment
///
open func remove(attachmentID: String) {
storage.remove(attachmentID: attachmentID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is no longer called from anywhere in the code. We should remove it from TextStorage.swift.

Copy link
Contributor

@diegoreymendez diegoreymendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

# Conflicts:
#	AztecTests/TextViewTests.swift
@SergioEstevao SergioEstevao merged commit 4430090 into develop Jun 28, 2017
@SergioEstevao SergioEstevao deleted the issue/removing_media_implement_undo_redo branch June 28, 2017 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants