This is a migrated thread and some comments may be shown as answers.

Bullet list only

1 Answer 60 Views
Editor
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 18 Jul 2016, 01:38 PM
Is there a way to programmatically set the editor to an unordered list and keep it in that mode, so the user can only enter bullets?

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 21 Jul 2016, 08:49 AM
Hi John,

You can implement such a logic by handling the OnClientCommandExecuting event and prevent EnterNewLine to remove a list item. Something like this:

<telerik:RadEditor runat="server" ID="RadEditor1"
    OnClientCommandExecuting="OnClientCommandExecuting">
    <Content>
        <ul>
            <li></li>
        </ul>
    </Content>
</telerik:RadEditor>
 
<script>
    function OnClientCommandExecuting(sender, args) {
        var editorUtils = Telerik.Web.UI.Editor.Utils;
        var command = args.get_commandName();
        var selElm = sender.getSelectedElement();
        var isEmptyLi = selElm.nodeName === "LI" &&
                        editorUtils.isEmptyDom(selElm.firstChild);
 
        if (command === "EnterNewLine" && isEmptyLi) {
            args.set_cancel(true);
        }
    }
</script>

If you need to also prevent the backspace key, you should rather do that by using the OnClientLoad event

Regards,
Ianko
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Editor
Asked by
John
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or