SimpleBox (Creating a Custom Widget) Documentation
This sample demonstrates the Simple Box widget plugin that was created in the Creating a Simple CKEditor 4 Widget tutorial series from the Widget SDK section of the CKEditor 4 Developer's Guide.
The custom widget created in the tutorials lets the users insert a simple box with a title and comment fields into their documents. The widget creates a predefined content structure that is added to the document when the user clicks the dedicated toolbar button available in the editor instance below. The included dialog window lets users both insert a new widget into the editor and modify an existing one and set some basic properties (width, alignment) for it.
Simple Box is a proof-of-concept plugin that can be
downloaded
from the repository or created by following the step-by-step tutorial.
Related Features
- Tutorials – Timestamp (Creating a Most Basic CKEditor 4 Plugin)
- Tutorials – Abbreviation (Custom Plugin with Dialog, Context Menu and ACF)
- API Usage – Using CKEditor 4 API
- Styling and Formatting – Applying Styles to Editor Content
Get Sample Source Code
- Simple box widget
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="robots" content="noindex, nofollow"> <title>Simple box widget</title> <script src="https://cdn.ckeditor.com/4.25.0-lts/standard-all/ckeditor.js"></script> </head> <body> <textarea cols="80" id="editor1" name="editor1" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="https://ckeditor.com/">CKEditor</a>.</p></textarea> <script> CKEDITOR.plugins.addExternal('simplebox', 'https://ckeditor.com/docs/ckeditor4/4.25.0-lts/examples/assets/plugins/simplebox/', 'plugin.js'); CKEDITOR.replace('editor1', { // Add the Simple Box plugin. extraPlugins: 'simplebox', // Besides editor's main stylesheet load also simplebox styles. // In the usual case they can be added to the main stylesheet. contentsCss: [ 'http://cdn.ckeditor.com/4.25.0-lts/full-all/contents.css', 'https://ckeditor.com/docs/ckeditor4/4.25.0-lts/examples/assets/plugins/simplebox/styles/contents.css' ], // Set height to make more content visible. height: 500, removeButtons: 'PasteFromWord' }); </script> </body> </html>