I'm in the process of developing my own plugin and dialog using an html element. I have a requirement where upon clicking the html element, I need to add some text to the editor. However, I'm facing challenges with the onOk
function and finding it difficult to bypass it.
If I include editor.insertHtml(' some code ')
within the onOk
function, the text is successfully added. But when I try to execute it outside, I encounter an error saying
Uncaught TypeError: Cannot read property 'editor' of undefined(…)
.
Can someone guide me on the correct approach to access the editor?
CKEDITOR.dialog.add( 'smiley2', function( editor ) {
return {
title: 'Abbreviation Properties',
minWidth: 400,
minHeight: 200,
contents: [
{
id: 'tab-basic',
label: 'Basic Settings',
elements: [
{
type: 'html',
id: '2',
label: 'Explanation',
html: "<div onclick=\"editor.insertHtml(' some code ')\">add code</a></div></div>"
}
]
}
],
onShow : function()
{
document.getElementById(this.getButton('ok').domId).style.display='none'; // hide ok button
},
onOk: function() {
editor.insertHtml(' abbr ');
}
};
});