We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

set line spacing

Hello

There is no item in the "Rich Text Editor" to adjust the line spacing. Can this item be added?


8 Replies

BS Buvana Sathasivam Syncfusion Team March 3, 2022 04:35 PM UTC

Hi hkourd, 

Greetings from Syncfusion support. 
You should be able to achieve your requirement by using custom toolbar items with a created event. Please find the below code and sample for your reference. 
Index.cshtml 
<ejs-richtexteditor id="default" created="created"> 
            <e-richtexteditor-toolbarsettings items="@ViewBag.items"></e-richtexteditor-toolbarsettings> 
….. 
        </ejs-richtexteditor> 
 
<script type="text/javascript"> 
    var rteObj, selection, ranges, dialogObj, editorManager; 
    function created() { 
        rteObj = this; 
        editorManager = rteObj.formatter.editorManager; 
        var btnObj = new ej.splitbuttons.DropDownButton({ items: items, iconCss: 'e-icons e-btn-icons e-line-height', select: select }); 
        btnObj.appendTo('#lineheight_tbar'); // Created drop down button 
    } 
    function select(args) {  // Triggered when you select the dropdown buttons 
        if (rteObj.formatter.getUndoRedoStack().length === 0) { 
            rteObj.formatter.saveData(); 
        } 
        let nodes = editorManager.domNode.blockNodes(); 
        for (let i = 0; nodes.length > i; i++) { 
            (nodes[i]).style.lineHeight = args.item.text; // Set the line height 
        } 
        rteObj.formatter.saveData(); 
        rteObj.formatter.enableUndo(rteObj); 
    } 
</script> 
<style> 
    .e-dropdown-btn .e-btn-icon.e-icons.e-btn-icons.e-line-height::before { 
        content: "\eb37"; 
    } 
</style> 
 

HomeController.cs 
public IActionResult Index() 
        { 
            var tools = new 
            { 
                tooltipText = "Line Height", 
                template = "<button class='e-tbar-btn e-btn' tabindex='-1' id='lineheight_tbar' style='width:100%'></button>" 
            }; 
            ViewBag.items = new object[] { tools, "Bold", "Italic", "Underline", "|", "Formats", "Alignments", "OrderedList", 
        "UnorderedList", "|", "CreateLink", "Image", "CreateTable", "|", "SourceCode", "|", "Undo", "Redo" 
            }; 
            return View(); 
        } 
 



Please let us know if you have any other concerns. 

Regards, 
Buvana S 
 
 
 
 
 
 
 
 
 
 
 



HK hkourd March 4, 2022 02:20 AM UTC

thank you

The example you attached works well, but it does not work when I enter the same code into my project.

Could the used version cause problems in working?


Attachment: sssss_97309d40.rar


BS Buvana Sathasivam Syncfusion Team March 4, 2022 11:51 AM UTC

Hi hkourd, 
No, it is not related to versions that cause a problem based on your shared screenshot. We suspect that you are facing theme-related issues. We have created a simple sample with dropdown buttons using the material theme. Can you please check the below sample? 
In the below code, we create a custom button inside the Rich Text Editor toolbar. 
HomeController.cs 
public IActionResult Index() 
        { 
            var tools = new 
            { 
                tooltipText = "Line Height", 
                template = "<button class='e-tbar-btn e-btn' tabindex='-1' id='lineheight_tbar' style='width:100%'></button>" // Create custom template button 
            }; 
            ViewBag.items = new object[] { tools, "Bold", "Italic", "Underline", "|", "Formats", "Alignments", "OrderedList", 
        "UnorderedList", "|", "CreateLink", "Image", "CreateTable", "|", "SourceCode", "|", "Undo", "Redo" 
            }; // You can define the custom button into Toolbar items. 
            return View(); 
        } 
 
We have converted a toolbar custom button to a dropdown button in the below way using Rich Text Editor's created event. 
Index.cshtml 
<e-richtexteditor-toolbarsettings items="@ViewBag.items"></e-richtexteditor-toolbarsettings> 
….. 
function created() { 
var btnObj = new ej.splitbuttons.DropDownButton({ items: items, iconCss: 'e-icons e-btn-icons e-line-height' }); 
btnObj.appendTo('#lineheight_tbar'); 
 
} 
 
Screenshot:  
 
 Could you please share the below information with us to replicate your issue on our end? 
  • Share your Rich Text Editor related codes and nuget package versions.
  • Have you faced any console errors?
  • Share your Syncfusion theme name.
Regards, 
Buvana S 



HK hkourd March 7, 2022 03:06 AM UTC

Excellent

The problem was solved and it worked.

Thank you very much 



HK hkourd March 7, 2022 03:14 AM UTC

The problem now is that

When I select several lines to change the distance between the lines, but the distance between all the lines changes

I want to change only the selected lines, not all lines of text



BS Buvana Sathasivam Syncfusion Team March 8, 2022 04:59 PM UTC

Hi hkourd, 

As per behavior, line height applies only to block nodes. You are not able to set the line height on selected lines. Please find the below links for your reference. 


Regards, 
Buvana S 



HK hkourd March 9, 2022 03:39 AM UTC

ok

Thank you



BS Buvana Sathasivam Syncfusion Team March 10, 2022 06:03 AM UTC

Hi Hkourd, 

Most welcome. Please get back to us if you need any further assistance. 

Regards, 
Buvana S 


Loader.
Up arrow icon