Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Aztec/Classes/Formatters/Implementations/HeaderFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ open class HeaderFormatter: ParagraphAttributeFormatter {
} else {
newParagraphStyle.replaceProperty(ofType: Header.self, with: header)
}

let targetFontSize = headerFontSize(for: headerLevel, defaultSize: defaultSize)
let targetFontSize = CGFloat(headerFontSize(for: headerLevel, defaultSize: defaultSize))
var resultingAttributes = attributes

let newDescriptor = font.fontDescriptor.addingAttributes([.size: targetFontSize])

resultingAttributes[.paragraphStyle] = newParagraphStyle
resultingAttributes[.font] = font.withSize(CGFloat(targetFontSize))

resultingAttributes[.font] = UIFont(descriptor: newDescriptor, size: targetFontSize)
return resultingAttributes
}

Expand Down
5 changes: 1 addition & 4 deletions Aztec/Classes/TextKit/TextStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,6 @@ open class TextStorage: NSTextStorage {

edited([.editedAttributes, .editedCharacters], range: range, changeInLength: attrString.length - range.length)

let invalidateRange = NSMakeRange(range.location, attrString.length)
invalidateAttributes(in: invalidateRange)

endEditing()
}

Expand Down Expand Up @@ -408,7 +405,7 @@ private extension TextStorage {
guard oldLevel != newLevel else {
return attrs
}

return fixFontAttribute(in: attrs, headerLevel: newLevel)
}

Expand Down
15 changes: 14 additions & 1 deletion Aztec/Classes/TextKit/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ open class TextView: UITextView {
}
}


/// Returns the collection of Typing Attributes, with all of the available 'String' keys properly converted into
/// NSAttributedStringKey. Also known as: what you would expect from the SDK.
///
Expand Down Expand Up @@ -599,6 +598,20 @@ open class TextView: UITextView {

return caretRect
}

/// When typing with the Chinese keyboard, the text is automatically marked in the editor.
/// You have to press ENTER once to confirm your chosen input. The problem is that in iOS 11
/// the typing attributes are lost when the text is unmarked, causing the font to be lost.
/// Since localized characters need specific fonts to be rendered, this causes some characters
/// to stop rendering completely.
///
/// Reference: https://github.com/wordpress-mobile/AztecEditor-iOS/issues/811
///
override open func unmarkText() {
preserveTypingAttributesForInsertion {
super.unmarkText()
}
}

// MARK: - HTML Interaction

Expand Down