Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement blockquotes with paragraph style #168

Merged

Conversation

SergioEstevao
Copy link
Contributor

Fix #76 #145

This PR implements blockquotes using a custom paragraph style

How to test:

  • Add and remove block quote styles to ranges of text
  • Play around by adding or removing lines
  • Test the case where two new lines are inserted in a row and see if block quote is close

Notes:

  • Still not implements updates of the DOM nodes
  • At the moment it's not possible to combine block quotes and list it's one or the other.


override init() {
textList = nil
blockquote = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Optionals are nil by default. You don't really need these two lines

super.init()
}

public required init?(coder aDecoder: NSCoder) {
textList = nil
blockquote = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above

/// - Parameters:
/// - text: the text being added
/// - range: the range of the insertion of the new text
private func refreshListAfterDeletionOf(text deletedText: NSAttributedString, atRange range:NSRange) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing // between the last doc's line and the method signature

///
/// - Parameters:
/// - text: the text being added
/// - range: the range of the insertion of the new text
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

/// - Parameters:
/// - text: the text being added
/// - range: the range of the insertion of the new text
private func refreshBlockquoteAfterInsertionOf(text:String, range:NSRange) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Aaand same as above!

if aDecoder.containsValue(forKey: String(describing: TextList.self)) {
let styleRaw = aDecoder.decodeInteger(forKey: String(describing: TextList.self))
if let style = TextList.Style(rawValue:styleRaw) {
textList = TextList(style: style)
}
}
if aDecoder.containsValue(forKey: String(describing:Blockquote.self)) {
blockquote = aDecoder.decodeObject(forKey: String(describing:Blockquote.self)) as? Blockquote
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing space between describing: and the class kind

@@ -26,11 +32,16 @@ open class ParagraphStyle: NSMutableParagraphStyle {
if let textListSet = textList {
aCoder.encode(textListSet.style.rawValue, forKey: String(describing: TextList.self))
}

if let blockquote = self.blockquote {
aCoder.encode(blockquote, forKey: String(describing:Blockquote.self))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above


let isBegginingOfListItem = storage.isStartOfNewLine(atLocation: range.location)

if text == "\n" && beforeString == "\n" && afterString == "\n" && isBegginingOfListItem {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this could be refactored (anyhow) using CharacterSet.newlines?

@jleandroperez
Copy link
Contributor

@SergioEstevao added a couple comments (100% of them are style / cosmetic ones, and please, by all means, feel free to disregard).

This PR works beautifully, nice job sir!!

:shipit:

@SergioEstevao SergioEstevao merged commit fb48e54 into develop Dec 7, 2016
@SergioEstevao SergioEstevao deleted the issue/implement_blockquotes_with_paragraph_style branch December 7, 2016 22:09
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.

Blockquote support.
2 participants