RichEditorView
RichEditorView copied to clipboard
How to get attributed string (Highlight)
I can get the string with editorView.getSelectedText, but how can I get attributed string( if it's bold, italic, etc.) ?
Does getSelectedHref work?
I don't use any url in my project, that's why I didnt check.
I checked it now , getSelectedHref works
But how can I get attributed string?
I can get String and URL, but I cannot get attributed string!?
Ah that's... strange. Typically you can just convert your string to an attributed string like NSAttributedString(string: string)
In your example : editorView.html = "What I'll usually do for focus and unfocus is similar to what Google Docs does. The insert link functionality is similar to Reddit's except I use a UIAlertController. There are some added and altered functionality like running your custom JS; you will just have to learn what goes on with this package, but it's a quick learn. Good luck! If you have any issues, Yoom will help out, so long as those issues are opened in this repo. Credits still go out to cjwirth and C. Bess"
"Good luck!" is bold. When I use getSelectedText, I get the text as String, but I want to get attributed string, then I can know selected text is bold, italic, underline and/or etc.
Did you try using NSAttributedString(string: editorView.getSelectedHref())
?
I'll check on it. Gimme a sec. Edit: ok so it looks like the method is just half-ass broken. I'll probably find some code to replace it from somewhere like TinyMCE.
Thanks.
If you add this function like this, when the user selected some text or moved the cursor to a different position can get attributed string.
- func editor(_ editor: TextEditorView, selectedTextAttributeDidChange attribute: TextAttribute)
You can check this link (https://github.com/OneupNetwork/SQRichTextEditor).
It's definitely possible, but to make this fix actually work, there's a bit of discussion that I'd have to read over since there's multiple ways "getSelectedHref" can work: https://github.com/cjwirth/RichEditorView/pull/25