Unplanned
Last Updated: 13 Apr 2020 09:12 by ADMIN
Philippe
Created on: 10 Apr 2020 12:47
Category: Editor
Type: Feature Request
2
Snippets and PasteCleanup options

Hello there,

 

I'm trying to use both snippets (to make a shortcode for our users to add templated Links) and pasteCleanup option (to prevent any style to be import from a copy paste) but it seems like the pasteCleanUp option is preventing my html tags from snippets to be added.

 

Here my code :


@(Html.Kendo().Editor()
      .Name(ViewData.TemplateInfo.HtmlFieldPrefix)
      .HtmlAttributes(new { style = ViewData["style"], @class = ViewData["class"] })
      .Resizable(resizable => resizable.Content(true).Toolbar(true))
      .Value(@Model)
      .Encode(false)
      .PasteCleanup(paste => paste.All(true))
      .Tools(tools => tools
                .Clear()
                .Bold().Italic().Underline().Strikethrough()
                .JustifyLeft().JustifyCenter().JustifyRight().JustifyFull()
                .CreateLink().Unlink()
                .TableEditing()
                .Snippets(snippets =>
                    {
                    snippets.Add("Test", " <a class='testclass' href='www.test.com'>TestLink</a> ");
                })
                .FontColor().BackColor()
                .CleanFormatting()
                .ViewHtml()
                )

If I don't remove the line

.PasteCleanup(paste => paste.All(true))

All I can get from my snippet is "TestLink" instead of "

 

<a class='testclass' href='www.test.com'>TestLink</a>

 

But maybe i'm doing this wrong ?

 

Thx a lot.

 

Cordialy

1 comment
ADMIN
Aleksandar
Posted on: 13 Apr 2020 09:12

Hi Philippe,

With the current implementation of the Editor widget, the Snippet command actually pastes the predefined snippet in the editable area, thus the observed behavior can be expected. However, as different behavior is expected I have converted this thread to a Feature Request and made it available on our Feedback portal here. We will monitor the community interest in the proposed Feature and based on the interest and our tasks queue will consider adding it to a future release. 

As a possible workaround, you can handle the execution of the inserthtml command within the execute event on the client-side. When the command is executed you would need to turn off the pasteCleanup, paste the snippet, and then reset the pastCleanup configuration:

execute:function(e){
        if(e.name == "inserthtml"){
          e.preventDefault();
          e.sender.options.pasteCleanup.all = false;
          e.sender.paste(e.command.options.value);
          e.sender.setOptions({
            pasteCleanup:{
              all:true
            }
          });
        }
      }

Here is a dojo that demonstrates this approach.

Regards,
Aleksandar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.