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

Blockquote for Indent, setting?

4 Answers 66 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 25 Feb 2014, 09:10 PM
Is it possible to indicate to RadEditor to use blockquotes for the indent (like it used to) instead of the new style-tag?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Feb 2014, 09:57 AM
Hi Amit,

Please have a look into the following code snippet which works fine at my end.

ASPX:
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientCommandExecuted="OnClientCommandExecuted">
</telerik:RadEditor>

JavaScript:
<script type="text/javascript">
    function OnClientCommandExecuted(editor, args) {
        var commandName = args.get_commandName();
        var editorParentSelection = editor.getSelection().getParentElement();
        if (commandName == "Indent") {
            var selectedElement = editor.getSelectedElement();
            while (!Telerik.Web.UI.Editor.Utils.isEditorContentArea(selectedElement) && !(selectedElement.tagName.toLowerCase() == "blockquote")) {
                selectedElement = selectedElement.parentNode;
            }
            var tempDiv = editor.get_document().createElement("blockquote");
            tempDiv.innerHTML = selectedElement.innerHTML;
            selectedElement.parentNode.replaceChild(tempDiv, selectedElement);
        }
    }
</script>

Thanks,
Shinu.
0
Amit
Top achievements
Rank 1
answered on 26 Feb 2014, 02:36 PM
WOW thanks for your help. I will have a programmer try this out asap and let you know the results.
0
Amit
Top achievements
Rank 1
answered on 27 Feb 2014, 06:55 PM
We tried the supplied fix but didn't work correctly, so we modified it (below). HOWEVER, now the "out-dent"  button doesn't work to remove the indent/blockquote... would you be able to provide a starting point for that?

here's the modified code. The above while indented the block in the GUI it indented ALL the text  not the element and teh <blockquote> was not found in the HTML.

 var commandName = args.get_commandName();
    var editorParentSelection = sender.getSelection().getParentElement();
    switch (commandName) {
        case "Indent":
            var selectedElement = sender.getSelectedElement();
            if (!Telerik.Web.UI.Editor.Utils.isEditorContentArea(selectedElement)) {
                var tempDiv = sender.get_document().createElement("blockquote");
                tempDiv.innerHTML = selectedElement.outerHTML;
                selectedElement.parentNode.replaceChild(tempDiv, selectedElement);
            }
            break;
    }

Again if you have any guidance on out-denting that would be great, or if you see any issue with the code as written here. Thanks!


0
Shinu
Top achievements
Rank 2
answered on 28 Feb 2014, 06:32 AM
Hi Amit,

Please try the following JavaScript which works fine at my end.

JavaScript:
<script type="text/javascript">
    function OnClientCommandExecuted(sender, args) {
        var commandName = args.get_commandName();
        var selectedElement = sender.getSelectedElement();
        switch (commandName) {
            case "Indent":
                if(!Telerik.Web.UI.Editor.Utils.isEditorContentArea(selectedElement)){
                    var tempDiv = sender.get_document().createElement("blockquote");
                    tempDiv.innerHTML = selectedElement.outerHTML;
                    selectedElement.parentNode.replaceChild(tempDiv,selectedElement);
                }
                break;
            case "Outdent":
                selectedElement.parentNode.outerHTML =selectedElement.parentNode.innerHTML;
                break;
        }
    }
</script>

Hope this will helps you.
Thanks,
Shinu.
Tags
Editor
Asked by
Amit
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Amit
Top achievements
Rank 1
Share this question
or