-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1341 from wordpress-mobile/release/1.19.6
Release 1.19.6
- Loading branch information
Showing
8 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Aztec/Classes/Formatters/Implementations/MarkFormatter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Foundation | ||
import UIKit | ||
|
||
class MarkFormatter: AttributeFormatter { | ||
|
||
var placeholderAttributes: [NSAttributedString.Key: Any]? | ||
|
||
func applicationRange(for range: NSRange, in text: NSAttributedString) -> NSRange { | ||
return range | ||
} | ||
|
||
func apply(to attributes: [NSAttributedString.Key: Any], andStore representation: HTMLRepresentation?) -> [NSAttributedString.Key: Any] { | ||
var resultingAttributes = attributes | ||
|
||
var representationToUse = HTMLRepresentation(for: .element(HTMLElementRepresentation.init(name: "mark", attributes: []))) | ||
if let requestedRepresentation = representation { | ||
representationToUse = requestedRepresentation | ||
} | ||
resultingAttributes[.markHtmlRepresentation] = representationToUse | ||
|
||
return resultingAttributes | ||
} | ||
|
||
func remove(from attributes: [NSAttributedString.Key: Any]) -> [NSAttributedString.Key: Any] { | ||
var resultingAttributes = attributes | ||
|
||
resultingAttributes.removeValue(forKey: .markHtmlRepresentation) | ||
|
||
return resultingAttributes | ||
} | ||
|
||
func present(in attributes: [NSAttributedString.Key: Any]) -> Bool { | ||
return attributes[NSAttributedString.Key.markHtmlRepresentation] != nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters