Skip to content

Commit 11cda32

Browse files
committed
Merge branch 'develop' into release/1.10.0
2 parents d3e5321 + 4b6cc3d commit 11cda32

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Aztec/Classes/Formatters/Implementations/UnderlineFormatter.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ class UnderlineFormatter: StandardAttributeFormatter {
88
htmlRepresentationKey: .underlineHtmlRepresentation)
99
}
1010
}
11+
12+
class SpanUnderlineFormatter: UnderlineFormatter {
13+
14+
override func apply(to attributes: [NSAttributedString.Key : Any], andStore representation: HTMLRepresentation?) -> [NSAttributedString.Key : Any] {
15+
16+
let cssAttribute = CSSAttribute.underline
17+
let underlineStyleAttribute = Attribute(type: .style, value: .inlineCss([cssAttribute]))
18+
let spanRepresentation = HTMLElementRepresentation(ElementNode.init(type: .span, attributes: [underlineStyleAttribute], children: []))
19+
20+
return super.apply(to: attributes, andStore: HTMLRepresentation(for: .element(spanRepresentation)))
21+
}
22+
}

Aztec/Classes/TextKit/TextView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ open class TextView: UITextView {
747747
private static let formatterMap: [FormattingIdentifier: AttributeFormatter] = [
748748
.bold: BoldFormatter(),
749749
.italic: ItalicFormatter(),
750-
.underline: UnderlineFormatter(),
750+
.underline: SpanUnderlineFormatter(),
751751
.strikethrough: StrikethroughFormatter(),
752752
.link: LinkFormatter(),
753753
.orderedlist: TextListFormatter(style: .ordered),
@@ -935,7 +935,7 @@ open class TextView: UITextView {
935935
/// - Parameter range: The NSRange to edit.
936936
///
937937
open func toggleUnderline(range: NSRange) {
938-
let formatter = UnderlineFormatter()
938+
let formatter = SpanUnderlineFormatter()
939939
toggle(formatter: formatter, atRange: range)
940940
}
941941

0 commit comments

Comments
 (0)