Open TheGeekPharaoh opened 5 years ago
Greetings!
How are you saving the text? What function(s) are you calling to convert the NSAttributedString
to HTML? Any chance you could plop your functions here for load and save?
The load and save is just a simple CoreData operation. I obtain the HTML string by calling richTextEditor?.htmlString() and save that returned value. I do not manipulate it at all. When I want to later edit the text, I call richTextEditor?.setHtmlString() and pass it the same value. Again, I do not manipulate it at all. If I call richTextEditor?.htmlString() again, I see that the font size has increased, even if I do not manipulate the text. On Wednesday, April 24, 2019, 8:51:35 PM EDT, Deadpikle notifications@github.com wrote:
Greetings!
How are you saving the text? What function(s) are you calling to convert the NSAttributedString to HTML? Any chance you could plop your functions here for load and save?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hi again,
Sorry for your wait.
I am able to replicate the issue you're facing; however, I don't think it's unique to this RTE. All the code for loading and saving is calling native iOS stuff...hhmmmm....
The best I can figure out right now is that the HTML for px is being converted to pt (times 96/72) -- 12x96/72 = 16, which is what you're seeing. So, both the saving and loading appear to be messing up somehow.
It looks as though someone has had this issue before. Please see: https://stackoverflow.com/q/28441486/3938401 -- thus, it looks like this is an iOS/Apple issue. 😢
The reason I never ran into this myself is that I use DTCoreText to do all my HTML loading and saving (on both iOS and Mac). I recall usually using DTUseiOS6Attributes
when loading/saving HTML, but I don't know if that's needed on newer versions of iOS.
Thanks for your quick response! I'll be sure to check out DTCoreText. Any examples or advice for making use of it?
For what it's worth, I took a stab at incorporating the answer from the Stackoverflow link you provided and it worked like a charm! I simply overrode the [RichTextEditor attributedStringFromHTMLString] method with the answer. I can try and clean it up a bit and submit a pull request for you.
Hi, I'm sorry for my lack of response. I'm not dead, just very busy. 😅
I'm glad the SO link answer worked!! Very good to hear. Will keep this issue open for visibility for future users.
I'm open to PR's, sure. If you do one, please make the behavior opt-out so that folks can turn it off as they have need. Thanks!
I've run into an issue where if i create HTML text, save it (somewhere), then use RichTextEditor to edit the same text, the font size is increased. Example...
I save this text off, then go to edit it by calling richTextEditor?.setHtmlString()
Upon saving, my font size is automatically increased (with no interaction from me) to Arial 16.0. Result:
Please advise. Thanks!