Hi All,
Business requirement: I want to bold the text without using the toolbar buttons but with my custom button.
Process that I am following: I have added the CkEditor in my site and it is working fine. I have added one more button in my html page (Not inside the CkEditor). I want to call the functions like Bold, Italic, Cut Etc on click of that button. Not by clicking the toolbar buttons.
Exact Requirment: JS function that can be called on click of my button and will bold the text inside the CKEditor
Just give me one example I will implement all the functions and buttons accordingly.
Thanks
You would have to use
You would have to use execCommand. More on how to get it done here and here, etc. It's used to trigger some (mostly end-user) features. Most of these features have buttons assigned, but not all of them. And not all buttons have commands assigned (e.g. format drop down does not have it).
Additionally features may have states (so buttons automatically have a state) and are integrated with many other components like ACF or selection (feature is disabled automatically if some rules are not fullfilled).
So in short, you can use execCommand if "outside" is removed because some editor features also use execCommand to trigger other features.
Customer and Community Manager, CKSource
Follow us on: Facebook, Twitter, LinkedIn
If you think you found a bug in CKEditor, read this!
Want to verify one more thing
Hi Sebstefanov,
Thank you very much for this information this is what I am looking for.
I want to verify one more thing I am using Lite addon for track changes I want use execCommand for accept all changes what i need to call for this.
Again thanks.
Regards,
Mubasher
Below is the command that work for me
Hi,
This command works for me
<div onclick="ckePrint()">Click to print</div>
<script type="text/javascript">
function ckePrint() {
// Replace "editor1" with your editor name
alert("");
var i = CKEDITOR.instances.editor1;
alert(i);
// Edited as per the comment by Reinmar
i.execCommand( 'lite.AcceptAll' );
}
</script>
Thanks and regards,
Mubasher