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

copy/paste from MS Word to Kendo Editor

5 Answers 696 Views
Editor
This is a migrated thread and some comments may be shown as answers.
marco
Top achievements
Rank 1
marco asked on 16 Jul 2013, 12:13 PM
Hello, 
I have to substitute the AjaxControlToolkit.HTMLEditor with a Kendo Editor, maintaining more or less the same functionalities.I have problems to reproduce the functionalities provided by the buttons "Cut/Copy/Paste".
THINGS WORK OKAY if what I copy/paste is pure text. How can I maintain the formatting tags as color, numbered list, etc ?

Since the keys Ctrl-C and Ctrl-V work I thought it would be easier to reproduce the same behavior but I'm not able to.  In Kendo_web.js somehow this is achieved though.
A kendo forum "Copy text from Office to Editor"suggested to disable the pasting handler as
function onPaste(e) {
var editor = $("[data-role=editor]").data("kendoEditor");
$(editor.body).off("paste");
}
but it didn't work for me.
Basically this is the code I use in a .js file
I call my editor "myeditor" declared as a text area, I added three custom buttons as cut, copy, paste
$("#myeditor").kendoEditor({
            tools: [
                {
                    name: "customcut",
                    tooltip: "Cut the selection",
                    exec: function (e) {
                        var editor = $(this).data("kendoEditor");
                        range = editor.getRange();
                        seltext = editor.selectedHtml();
                        window.clipboardData.setData("Text", seltext);
                        range.deleteContents();
                    }
                },
                {
                    name: "customcopy",
                    tooltip: "Copy to clipboard",
                    exec: function (e) {
                        myeditor.encodedValue();
                        seltext = myeditor.selectedHtml();
                        window.clipboardData.setData("Text", seltext);
                    }
                },
                {
                    name: "custompaste",
                    tooltip: "Paste from clipboard",
                    exec: function (e) {
                        var wclip = window.clipboardData.getData("Text");
                        if (wclip.length > 0) {
                            myeditor.paste(wclip);
                        }
                    }
                }
            ],  //end tools[]
            change: onChange,
            select: onSelect,
            execute: onExecute,
            paste: onPaste
        });

I believe I don't know how to access the clipboard properly.
Sorry for the long text, I will be very grateful for any help

MarcoF

5 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 17 Jul 2013, 01:50 PM
Hello Marco,

The cut/copy/paste buttons are not available as a design decision in the Kendo UI editor, because accessing the complete clipboard data yields different markup, as you have figured out. We have not found a robust cross-browser way of implementing them, so we cannot give much advice on this. As an alternative approach, you can simply alert the user that these actions can be performed with the Ctrl+X/C/V shortcuts.

Regards,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Beto
Top achievements
Rank 1
answered on 21 Dec 2018, 06:31 AM
Has this changed since 2013?  Is there now a way to copy and paste via icon buttons?  
0
Joana
Telerik team
answered on 24 Dec 2018, 07:44 AM
Hello Beto,

By design, Kendo UI Editor do not have Copy/Paste/Cut buttons. You could add custom tools to theEditor and add custom implementation:

https://demos.telerik.com/kendo-ui/editor/custom-tools

Regards,
Joana
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Don
Top achievements
Rank 1
answered on 29 Apr 2019, 09:49 PM

The ability to have Copy & Paste icon buttons would be really great features to be added to the Kendo Editor in the future.

We often may not want to use the built-in View HTML icon because it exposes the HTML codes to the users and risk them to mess up the HTML codes. However, for user convenience, we would want to capture the HTML codes to the clipboard with a Copy icon button, and have a Paste icon button to paste the HTML codes onto another Editor.

The Custom button implementation has limited features (ex: unless I'm missing something, there is only 1 custom icon image... can't have different custom icon images for different functions)

0
Joana
Telerik team
answered on 30 Apr 2019, 08:19 AM
Hi Don,

Thank you for your feedback.

As Alexander Gyoshev has replied in the thread, there is no consistent and reliable way to process clipboard through javascript or in other words a solution that will be cross-browser. However, you could give your vote in a similar feedback portal issue where we track the demand for features:

https://feedback.telerik.com/kendo-jquery-ui/1360272-can-we-have-the-same-functionalities-as-the-ajax-html-editor

Regards,
Joana
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Editor
Asked by
marco
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Beto
Top achievements
Rank 1
Joana
Telerik team
Don
Top achievements
Rank 1
Share this question
or