I've been at this for more than 8 eight hours. Whenever I think I'm close to figuring it out, I'm close to home, I feel like I'm in a completely different country, haha. I've scoured http://docs.ckeditor.com/#!/api/CKEDITOR and attempted nearly ( well maybe not nearly since there was a lot ) every piece of advice I could find in the forums where it made sense.
My plugin code:
CKEDITOR.plugins.add( 'lkchrcast' , {
icons: 'lkchrcast',
init: function( editor ) {
editor.addCommand( 'insertURL', {
exec: function( editor ) {
//code to use selected text
var linktext = editor.getSelection().getSelectedText();
//code to create <a> tag;
var linktag = new CKEDITOR.dom.element( 'a' );
//code to attach a specific " *.php?ID = linktext " url to href attribute;
linktag.setAttribute( 'href', 'www.test.com/test.php?ID=' + linktext );
//code to appendText (linktext) to <a> tag;
linktag.appendText( linktext );
//code to insert final html into editor;
//???
}
});
editor.ui.addButton( 'Lkchrcast', {
label: 'Link to Cast',
command: 'insertURL',
toolbar: 'Characters',
});
}
});
I just discovered some other things I can try, but I'm exhausted and going to bed. haha. I thought I would give posting for some help a try.
Thanks {:-}
Would be nice if you would
Would be nice if you would say what the problem is...
Customer and Community Manager, CKSource
Follow us on: Facebook, Twitter, LinkedIn
If you think you found a bug in CKEditor, read this!
Haha Sorry about that.
Basically, the button would create a link that uses the selected text as a php url parameter.
For example:
This Text becomes <a> tag href attribute is http: // www.example. com/example.php?ID=This Text" - This Text - </a>
("<. " added to prevent this forum editor from making an actual link)
hmmm, it has also dawned on me that I'm going to need it to actually write:
<<a> tag href attribute is http: // www.example. com/example.php?ID=This Text" - This%20Text - </a>
which does complicate things...
I'm starting to think this functionality may be a little above my pay grade as it is apparently far from being as simple as my mind wants to believe.
Thanks for any suggestions in advance.
Solved, almost, sort of
Kinda. More like a workaround. I just modified the <abbr> sample plugin to work for my needs.
It works just fine, however, the initially selected text gets stuck in the fields.
I'm sure I'll either figure it out or find a way around it, but if anyone can help me figure out how to clear, reset or otherwise replace text collected from:
That would be awesome.
Thanks
Discovered the answer here
http://ckeditor.com/forums/Support/getselection-to-set-default-value-of-dialog-field
Moving on...