Paragraph to Blockquote using format sets?

3 posts, 1 answers
  1. Rob
    Rob avatar
    11 posts
    Member since:
    Apr 2011

    Posted 25 Oct 2012 Link to this post

    We previously used the following in a ToolsFile.xml to allow users to change the current paragraph to a blockquote.

    <paragraphs>
        <paragraph name="<blockquote>Block Quote (Full)</blockquote>" value="<blockquote>" />
        <paragraph name="<blockquote class='floatright'>Block Quote (Float Right)</blockquote>" value="<blockquote class='floatright'>" />
        <paragraph name="<blockquote class='floatright'>Block Quote (Float Left)</blockquote>" value="<blockquote class='floatleft'>" />
    </paragraphs>

    We're moving everything over to format sets in a new ToolsFile.xml. I thought the following would work, but the blockquote options do not appear in the format sets drop-down when a paragraph is selected.

    <formatSets>
        <formatSet tag="blockquote" title="<blockquote>Block Quote (Full)</blockquote>" />
        <formatSet tag="blockquote" title="<blockquote>Block Quote (Float Right)</blockquote>">
            <attributes>
                <item name="class" value="floatright" />
            </attributes>
        </formatSet>
        <formatSet tag="blockquote" title="<blockquote>Block Quote (Float Left)</blockquote>">
            <attributes>
                <item name="class" value="floatleft" />
            </attributes>
        </formatSet>
    </formatSets>

    Is there a way to allow users to change a paragraph to a blockquote using RadEditor?
  2. Answer
    Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 30 Oct 2012 Link to this post

    Hi,

    The FormatBlock and the FormatSets are quite different tools. The FormatBlock dropdown always shows static information in its dropdown, whilst the FormatSets popup is dynamically updated according to the selected tag in the content area. If you select a P tag in the content area, the FormatSets dropdown will display only formatting items which could be applied to the paragraphs, if you select a blockquote in the content area, the dropdown will show you specific Block Quote (Full), Block Quote (Float Right) and Block Quote (Float Left) items.

    To achieve your goal you should override the formatSetBlockElements array using this code:

    <telerik:RadEditor ID="RadEditor1" runat="server" ToolsFile="ToolsFile.xml">
        <Content><p>dsaasdasd</p><blockquote>sample content</blockquote></Content>
    </telerik:RadEditor>
    <script type="text/javascript">
        $T = Telerik.Web.UI;
        $T.Editor.formatSetBlockElements = [
        "p",
        "h1",
        "h2",
        "h3",
        "h4",
        "h5",
        "h6",
        "menu",
        "pre",
        "address",
        "blockquote"
    ];
    </script>

    and predefine the format sets for all block elements in the ToolsFile.xml file:

    <formatSets>
        <formatSet tag="h1" title="&lt;h1>Heading 1&lt;/h1>">
            <attributes>
                <item name="class" value="headingstyle" />
            </attributes>
        </formatSet>
        <formatSet tag="p" title="&lt;p>Paragraph&lt;/p>">
            <attributes>
                <item name="class" value="parastyle" />
            </attributes>
        </formatSet>
        <formatSet tag="blockquote" title="&lt;blockquote>Block Quote (Full)&lt;/blockquote>" />
        <formatSet tag="blockquote" title="&lt;blockquote>Block Quote (Float Right)&lt;/blockquote>">
            <attributes>
                <item name="class" value="floatright" />
            </attributes>
        </formatSet>
        <formatSet tag="blockquote" title="&lt;blockquote>Block Quote (Float Left)&lt;/blockquote>">
            <attributes>
                <item name="class" value="floatleft" />
            </attributes>
        </formatSet>
    </formatSets>

    All the best,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rob
    Rob avatar
    11 posts
    Member since:
    Apr 2011

    Posted 30 Oct 2012 Link to this post

    Rumen,

    Thanks, it worked perfectly!

    Rob
Back to Top