This project has moved. For the latest updates, please go here.
1
Vote

this.getSelectedHTML(); method is returning undefined. Any clue? Using it to create a custom button

description

Have a requirement where I need to convert a selected text into arial 10 using a custom button so need to use getSelectedHTML() but this method is returning underfined.
toolbar:[
                [""html""],
                [""bold"", ""underline""],
                [""orderedlist"", ""unorderedlist""],
                [""link"", ""unlink""],
                [""cut"", ""copy"", ""paste""],
                [""forecolor""],
                [{
                    css: ""font_arial"",
                    text: ""To Arial 10pt"",
                    action: function (btn) {
                        var selectedText = this.getSelection();
                        var selectedTextHtml = this.getSelectedHTML();
                        alert(selectedTextHtml);
                        formattedSelectedText = ""<span style='font-family:Arial;font-size:10pt;'>"" + selectedText + ""</span>"";                                                                                    
                        var wholeText = $('ididid').htmlarea('html');
                        //alert(wholeText);
                        var finalText = wholeText.replace(this.getSelection(), formattedSelectedText);
                        //paste the final text in text area
                        $('ididid').htmlarea('html', finalText);
                    }
                }]
            ]
        }";

comments

amitburnwal wrote Apr 24, 2016 at 2:56 AM

Please help