Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Alignment not working when use NewLineMode="Br" in Editor.

$
0
0

Thanks Ianko for your reply,

 I have used below solution for fix above issue which works fine :

Telerik.Web.UI.Editor.CommandList["JustifyRight"] = function(commandName, editor, args) {
                                            var oElem = editor.getSelectedElement();
                                            if (oElem && oElem.tagName == "DIV") {                                                
                                                oElem.style.textAlign = "right";
                                            } else if (editor.getSelectionHtml())//There is some selection  
                                            {
                                                
                                                var toPaste = "<div  style='text-align: right'>" + editor.getSelectionHtml() + "</div>";
                                                editor.pasteHtml(toPaste.trim());
  }
                                                
                                        };

                                        Telerik.Web.UI.Editor.CommandList["JustifyLeft"] = function(commandName, editor, args) {
                                            var oElem = editor.getSelectedElement();

                                            if (oElem && oElem.tagName == "DIV") {
                                               
                                                oElem.style.textAlign = "left";
                                            } else if (editor.getSelectionHtml())//There is some selection  
                                            {
                                             
                                                var toPaste = "<div style='text-align: left'>" + editor.getSelectionHtml() + "</div>";
                                                editor.pasteHtml(toPaste.trim());                                             
                                            }
                                        };  
                
                                        Telerik.Web.UI.Editor.CommandList["JustifyCenter"] = function(commandName, editor, args) {
                                            var oElem = editor.getSelectedElement();
                                            if (oElem && oElem.tagName == "DIV") {                                                
                                                oElem.style.textAlign = "center";
                                            } else if (editor.getSelectionHtml())//There is some selection  
                                            {
                                             
                                                var toPaste = "<div  style='text-align: center'>" + editor.getSelectionHtml() + "</div>";
                                                editor.pasteHtml(toPaste.trim());                                             
                                            }
                                        };​

But problem is when i select any content and set alignment first time like Right,left,center​ then selected content lost its focus.

This only happened at first time. after select same content and set alignment then focus works fine.

 

Please suggest. 
Thanks.​


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>