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
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