froala / react-froala-wysiwyg

React component for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
562 stars 130 forks source link

Is the getText method exposed? #229

Closed christopherparo closed 2 years ago

christopherparo commented 4 years ago

I've been trying to grab just the plain text from the editor but I can't seem to find the exposed getText method that is offered in the base api.

I've found the method here but it doesn't seem this is included in the editor object. https://froala.com/wysiwyg-editor/v1-2/docs/methods/#getText

giovanigenerali commented 4 years ago

@ChristopherParo try to use this https://froala.com/wysiwyg-editor/docs/methods/#html.get or https://froala.com/wysiwyg-editor/docs/methods/#html.getSelected

dejanmartinovic commented 4 years ago

@ChristopherParo You can use the selection.text method: https://froala.com/wysiwyg-editor/docs/methods/#selection.text https://jsfiddle.net/dejan_m/og0hxf2t/4170/

jameslicarte commented 3 years ago

any update on this? the solutions proposed above are not really the answers. I also just want to grab the plain text, with no html tags included.

dejanmartinovic commented 3 years ago

@Licarte97 selection.text() does not return the HTML tags. Can you test this demo and let me know the result: https://github.com/froala/react-froala-wysiwyg/issues/229#issuecomment-674850795?

jameslicarte commented 3 years ago

it does, but It only extracts the highlighted/selected text. I want to get the plain text without selecting the actual text.

jameslicarte commented 3 years ago

Ohhh okay, I just saw your jsfiddle code. I just need to select all the text before extracting. thanks!

dejanmartinovic commented 3 years ago

You can choose one of the following approaches: To highlight the part you want to export: https://jsfiddle.net/dejan_m/og0hxf2t/4804/ To export all without selecting anything: https://jsfiddle.net/dejan_m/og0hxf2t/4803/