Look at the source code (Hint: _Source/). Also, change your editor to use ckeditor_source.js instead of ckeditor.js, that will help with debugging. Lastly, to get started, look at the _samples folder where they alter a dialog.
That's the fun part you have to figure out. Look at the existing dialog definition and see if you can't perhaps work some magic in the commit: function.
All right, I have a new field called caption, and it is working great. I've also managed to wrap the image element in a div, and put a div after the inner image element. My only issue is getting the value of the text box from the commit function up to the onOK function. I'm sure I'm doing something silly here:
//on show
onShow : function()
{
this.divElement = false;
this.captionElement = false;
this.captionText = ''; // THIS LINE
this.imageElement = false;
this.linkElement = false;
...
}
onOk: function(){
...
// Insert a new Image.
if ( !this.imageEditMode )
{
if (this.addLink) {
//Insert a new Link.
if (!this.linkEditMode) {
editor.insertElement(this.linkElement);
this.linkElement.append(this.imageElement, false);
}
else //Link already exists, image not.
editor.insertElement(this.imageElement);
}
else
{
this.captionElement = editor.document.createElement( 'div' );
this.captionElement.setAttribute ( 'class' , 'magazine_image_caption' );
this.captionElement.setText(this.captionText); // THIS LINE
this.divElement = editor.document.createElement( 'div' );
editor.insertElement(this.divElement);
this.divElement.append(this.imageElement);
this.divElement.append(this.captionElement);
}
}
...
content: [
...
{
type : 'text',
label : 'Caption',
id : 'textCaption',
commit:function( type, element )
{
if ( type == IMAGE )
{
}
else if ( type == PREVIEW )
{
}
else if ( type == CLEANUP )
{
this.captionElement = this.getValue(); // THIS LINE
}
}
},
...
I have a feeling I need to access the property differently in the assigning part, as in not use this.. I tried messing with the element but it looks like it is an image? I've marked the 3 relevant lines.
Re: Modify An Existing Plugin
Re: Modify An Existing Plugin
*facepalm*
Thanks!
Re: Modify An Existing Plugin
CKEDITOR.on( 'dialogDefinition', function( ev ) { var dialogName = ev.data.name; var dialogDefinition = ev.data.definition; if ( dialogName == 'image' ) { var infoTab = dialogDefinition.getContents( 'info' ); infoTab.add( { type : 'text', label : 'Caption', id : 'magazine_image_caption', 'default' : '', validate : function() { if (this.getValue()=='') return 'You must provide a caption!'; } }); } });Thanks SO much!
- Josh
Re: Modify An Existing Plugin
Re: Modify An Existing Plugin
//on show onShow : function() { this.divElement = false; this.captionElement = false; this.captionText = ''; // THIS LINE this.imageElement = false; this.linkElement = false; ... }onOk: function(){ ... // Insert a new Image. if ( !this.imageEditMode ) { if (this.addLink) { //Insert a new Link. if (!this.linkEditMode) { editor.insertElement(this.linkElement); this.linkElement.append(this.imageElement, false); } else //Link already exists, image not. editor.insertElement(this.imageElement); } else { this.captionElement = editor.document.createElement( 'div' ); this.captionElement.setAttribute ( 'class' , 'magazine_image_caption' ); this.captionElement.setText(this.captionText); // THIS LINE this.divElement = editor.document.createElement( 'div' ); editor.insertElement(this.divElement); this.divElement.append(this.imageElement); this.divElement.append(this.captionElement); } } ...content: [ ... { type : 'text', label : 'Caption', id : 'textCaption', commit:function( type, element ) { if ( type == IMAGE ) { } else if ( type == PREVIEW ) { } else if ( type == CLEANUP ) { this.captionElement = this.getValue(); // THIS LINE } } }, ...I have a feeling I need to access the property differently in the assigning part, as in not use this.. I tried messing with the element but it looks like it is an image? I've marked the 3 relevant lines.
This is the output:
I am so close, but I know I'm doing something wrong.
Thanks!
- Josh
Re: Modify An Existing Plugin