the Calendar control here is open source.My97datepicker, first look at the following:
1, click on the left-hand customCalendar Controlbutton to pop up the Calendar Control dialog box.
2. Click OK to add the Calendar control to the form designer while preserving the calendar's control style
3. Click the CKEditor preview control to see if you can make a calendar selection.
Here's the implementation, for how to add a custom control to CKEditor, refer to theckeditor_4.4.5 Customizing Toolbars"article.
First add the My97datepicker js file to the plugin directory:
the code for Plugin.js is as follows:
- CKEDITOR.plugins.add (' DatePicker ',
- {
- Requires: [' Dialog '],
- Init: function (editor)
- {
- var pluginname = ' DatePicker ';
- //Loading a custom window
- CKEDITOR.dialog.add (' DatePicker ',This.path + "Dialogs/datepicker.js");
- //Register a call command for a custom plugin
- Editor.addcommand (Pluginname, new Ckeditor.dialogcommand ( ' DatePicker '));
- //Register a button to invoke the custom plugin
- Editor.ui.addButton (' DatePicker ',
- {
- //editor.lang.mine is a Chinese item defined in the Zh-cn.js,
- //You can write English characters directly here, but to display Chinese you have to modify Zh-cn.js
- Label:editor.lang.mine,
- Command:pluginname
- });
- }
- }
- );
The This.path in the Nineth line of code above can get the path where the current file is located.
The Datepicker.js code under dialogs is as follows:
- CKEDITOR.dialog.add ( ' datepicker ', function (editor)
- {
- return {
- Title: ' Calendar control ',
- MINWIDTH:300,
- minheight:150,
- Contents: [
- {
- ID: ' tab1 ',
- Label: ",
- Title: ",
- Elements:
- [
- {
- Type: ' html ',
- HTML:' Select Date: <style type= ' text/css ' >
- . Wdate{border: #999 1px solid;height:20px;
- Background: #fff URL (' +ckeditor.plugins.get ("DatePicker"). path+'/images/datepicker.gif)
- No-repeat right;}
- </style>
- <input type= "text" id= "d241" onfocus= "Wdatepicker ({datefmt:\ ' Yyyy-mm-dd hh:mm:ss\ '})"
- class= "Wdate" style= "width:150px"/> '
- }
- ]
- }
- ],
- OnOk: function () {
- editor.inserthtml ('
- <style type= "Text/css" >
- . Wdate{border: #999 1px solid;height:20px;
- Background: #fff URL (' +ckeditor.plugins.get ("DatePicker"). path+'/images/datepicker.gif)
- No-repeat right;}
- </style>
- <input type= "text" id= "d241" onfocus= "Wdatepicker ({datefmt:\ ' Yyyy-mm-dd hh:mm:ss\ '})"
- class= "Wdate" style= "width:150px"/> ");
- },
- };
- } );
The style of the calendar control needs to be added to the above JS file, otherwise it is easy to refer to a bug where the reference path does not cause the style to be lost.
Transferred from: http://itxxz.com/a/gaoji/2014/1127/ckeditor_my97DatePicker.html
CKEditor Adding a Calendar control