Unplanned
Last Updated: 03 Aug 2022 15:33 by ADMIN
Tejinder
Created on: 10 Feb 2022 12:22
Category: Editor
Type: Feature Request
3
Expose Preview tool/mode in the ViewHtml dialog box

I couldn't find the Preview Tool button in the Editor.

Please help me with that, how can I add that functionality into the Editor?

1 comment
ADMIN
Dimo
Posted on: 03 Aug 2022 15:33

In the meantime, here is how to implement Preview as a custom Editor tool:

@using Telerik.Blazor.Components.Editor

<TelerikEditor @bind-Value="@EditorValue"
               Tools="@EditorTools">
    <EditorCustomTools>
        <EditorCustomTool Name="Preview">
            <TelerikButton Icon="search" Title="Preview" OnClick="@ShowPreview">Preview</TelerikButton>
        </EditorCustomTool>
    </EditorCustomTools>
</TelerikEditor>

<TelerikWindow @bind-Visible="@WindowVisible"
               Modal="true"
               Width="70vw"
               Height="70vh">
    <WindowTitle>
        Editor Value Preview
    </WindowTitle>
    <WindowActions>
        <WindowAction Name="Close" />
    </WindowActions>
    <WindowContent>
        @( new MarkupString(EditorValue) )
    </WindowContent>
</TelerikWindow>

@code {
    private string EditorValue { get; set; } = @"<p>Foo <strong>Bar</strong> Baz</p>";

    private bool WindowVisible { get; set; }

    private List<IEditorTool> EditorTools { get; set; } = new List<IEditorTool>() {
        new EditorButtonGroup(
            new Bold(),
            new Italic(),
            new Underline()
        ),
        new EditorButtonGroup(
            new UnorderedList(),
            new OrderedList()
        ),
        new CustomTool("Preview")
    };

    private void ShowPreview()
    {
        WindowVisible = true;
    }
}