CKEditor"
Jimmyshiau (talk | contribs) |
|||
(38 intermediate revisions by 8 users not shown) | |||
Line 3: | Line 3: | ||
= CKEditor = | = CKEditor = | ||
− | *Demonstration: | + | *Demonstration: [http://www.zkoss.org/zkdemo/input/wysiwyg_editor WYSIWYG Editor] |
*Java API: N/A | *Java API: N/A | ||
*JavaScript API: N/A | *JavaScript API: N/A | ||
+ | |||
+ | {{ZKAddon | link=http://sourceforge.net/projects/zk1/files/ZK%20CKEditor/ZK%205/}} '''(deprecated)''' | ||
+ | |||
+ | It is moved to google code after 3.5.2.0: [http://code.google.com/p/zkckeditor/ zkckeditor] '''(deprecated)''' | ||
+ | |||
+ | It is moved to github after 3.6.0.0: https://github.com/zkoss/zkckeditor | ||
+ | |||
+ | = Maven = | ||
+ | You need to include CKEditor jar in pom.xml before using it because it has a different group id from ZK other components. | ||
+ | <source lang='xml'> | ||
+ | <dependency> | ||
+ | <groupId>org.zkoss.zkforge</groupId> | ||
+ | <artifactId>ckez</artifactId> | ||
+ | <version>${ckez.version}</version> | ||
+ | </dependency> | ||
+ | </source> | ||
+ | |||
+ | Check the latest version on [http://mavensync.zkoss.org/maven2/org/zkoss/zkforge/ckez/ CE repository]. | ||
= Employment/Purpose = | = Employment/Purpose = | ||
The component used to represent [http://ckeditor.com/ CKEditor] | The component used to represent [http://ckeditor.com/ CKEditor] | ||
− | CKEditor is a popular HTML on-line text editor developed by Frederico Caldeira Knabben. | + | CKEditor is a popular HTML on-line text editor developed by Frederico Caldeira Knabben. |
+ | CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to the results users have when publishing it. | ||
+ | It brings to the web common editing features found on desktop editing applications like Microsoft Word and OpenOffice. | ||
= Example = | = Example = | ||
Line 18: | Line 38: | ||
<source lang="xml" > | <source lang="xml" > | ||
− | <ckeditor> | + | <ckeditor width="850px"> |
− | + | <attribute name="value"><![CDATA[ | |
− | + | <table width="200" cellspacing="1" cellpadding="1" border="1"> | |
− | + | <tbody> | |
− | + | <tr style="background: #B7B313; color:white;"> | |
− | + | <td>First Name</td> | |
− | + | <td>Last Name</td> | |
− | + | </tr> | |
− | + | <tr> | |
− | + | <td>Jone</td> | |
− | + | <td>Hayes</td> | |
− | + | </tr> | |
− | + | <tr> | |
− | + | <td>Mary</td> | |
− | + | <td>Bally</td> | |
− | + | </tr> | |
− | + | </tbody> | |
− | + | </table> | |
− | + | ]]></attribute> | |
</ckeditor> | </ckeditor> | ||
</source> | </source> | ||
Line 47: | Line 67: | ||
<zk xmlns:n="http://www.zkoss.org/2005/zk/native"> | <zk xmlns:n="http://www.zkoss.org/2005/zk/native"> | ||
<n:form> | <n:form> | ||
− | <ckeditor | + | <ckeditor width="850" /> |
</n:form> | </n:form> | ||
</zk> | </zk> | ||
</source> | </source> | ||
+ | =Work with ZK6 MVVM= | ||
+ | {{Notice|text=Since Ckeditor '''3.6.0.1''', we have added data binding annotation into the lang-addon.xml file, so you no more need to add the settings below.}} | ||
+ | since 6.0.0 | ||
+ | For work with ZK6 MVVM, it is required to create an addon xml and add the server annotation as follows: | ||
− | =Supported | + | WEB-INF/ckez-bind-addon.xml |
+ | <source lang="xml" > | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <language-addon> | ||
+ | <!-- The name of this addon. It must be unique --> | ||
+ | <addon-name>ckezbind</addon-name> | ||
+ | <!-- Specifies what other addon this depends | ||
+ | <depends></depends> | ||
+ | --> | ||
+ | <!-- Which language this addon will be added to --> | ||
+ | <language-name>xul/html</language-name> | ||
+ | |||
+ | <component> | ||
+ | <component-name>ckeditor</component-name> | ||
+ | <extends>ckeditor</extends> | ||
+ | <annotation> | ||
+ | <annotation-name>ZKBIND</annotation-name> | ||
+ | <property-name>value</property-name> | ||
+ | <attribute> | ||
+ | <attribute-name>ACCESS</attribute-name> | ||
+ | <attribute-value>both</attribute-value> | ||
+ | </attribute> | ||
+ | <attribute> | ||
+ | <attribute-name>SAVE_EVENT</attribute-name> | ||
+ | <attribute-value>onChange</attribute-value> | ||
+ | </attribute> | ||
+ | <attribute> | ||
+ | <attribute-name>LOAD_REPLACEMENT</attribute-name> | ||
+ | <attribute-value>value</attribute-value> | ||
+ | </attribute> | ||
+ | <attribute> | ||
+ | <attribute-name>LOAD_TYPE</attribute-name> | ||
+ | <attribute-value>java.lang.String</attribute-value> | ||
+ | </attribute> | ||
+ | </annotation> | ||
+ | </component> | ||
+ | </language-addon> | ||
+ | </source> | ||
+ | |||
+ | then add it into WEB-INF/zk.xml | ||
+ | |||
+ | <source lang="xml" > | ||
+ | <zk> | ||
+ | <language-config> | ||
+ | <addon-uri>/WEB-INF/ckez-bind-addon.xml</addon-uri> | ||
+ | </language-config> | ||
+ | </zk> | ||
+ | </source> | ||
+ | |||
+ | =File browser= | ||
+ | ZK CKEditor provides a default file browser for browsing the files in a folder that you specify. You can define a target folder in index.zul and when you open the add image/flash dialog and click "Browse Server", CKEditor will open a new window, and list all the files in the file browser. | ||
+ | {| width="100%" | ||
+ | |- | ||
+ | |[[File:ZKCompRef_CKEditor_filebrowser.png]] | ||
+ | | <source lang="xml" > | ||
+ | <zk> | ||
+ | <ckeditor filebrowserImageBrowseUrl="img"/> | ||
+ | </zk> | ||
+ | </source> | ||
+ | |} | ||
+ | [[File:ZKCompRef_CKEditor_filebrowser2.png]] | ||
+ | [[File:ZKCompRef_CKEditor_filebrowser3.png]] | ||
+ | |||
+ | ==Custom File browser== | ||
+ | since 3.6.0.2 | ||
+ | If you wish to customize your own file browser, you can change the location by calling CKeditor.setFilebrowserImageUploadUrl(page_url), and refer to [http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_%28Uploader%29 CKEditor Developers Guide] to create your custom file browser. | ||
+ | |||
+ | =File upload= | ||
+ | since 3.6.0.2 | ||
+ | ZK CKEditor provides a default file upload handler for uploading the files to the folder you specify. You can define a target folder in index.zul and when user uploads a file, it will save the file in the folder that you have specified. | ||
+ | {| width="100%" | ||
+ | |- | ||
+ | |[[File:ZKCompRef_CKEditor_filebrowser.png]] | ||
+ | | <source lang="xml" > | ||
+ | <zk> | ||
+ | <ckeditor filebrowserImageBrowseUrl="img" filebrowserImageUploadUrl="img"/> | ||
+ | </zk> | ||
+ | </source> | ||
+ | |} | ||
+ | [[File:ZKCompRef_CKEditor_fileupload.png]] | ||
+ | [[File:ZKCompRef_CKEditor_fileupload2.png]] | ||
+ | |||
+ | ==Custom File upload handler== | ||
+ | since 3.6.0.2 | ||
+ | If you wish to customize your own file upload handler, you can change the location by calling CKeditor.setFileUploadHandlePage(page_url), and refer to [http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_%28Uploader%29 CKEditor Developers Guide] to create your custom file upload handler. | ||
+ | |||
+ | = Custom Configuration = | ||
+ | |||
+ | Prepare a javascript file for configuration like: | ||
+ | |||
+ | '''config.js''' | ||
+ | <source lang='javascript'> | ||
+ | CKEDITOR.editorConfig = function(config) { | ||
+ | //enable spell checker | ||
+ | config.disableNativeSpellChecker = false; | ||
+ | //Automatically enables "Spell Check As You Type" on editor startup | ||
+ | config.scayt_autoStartup = true; | ||
+ | //locale | ||
+ | config.language = 'de'; | ||
+ | }; | ||
+ | </source> | ||
+ | |||
+ | Please refer to http://docs.ckeditor.com/#!/api/CKEDITOR.config for complete configuration options. | ||
+ | |||
+ | Specify the configuration file at <tt>customConfigurationsPath</tt> attribute with the absolute path. | ||
+ | <source lang='xml'> | ||
+ | <ckeditor customConfigurationsPath="/config.js"/> | ||
+ | </source> | ||
+ | |||
+ | == Custom Save Button == | ||
+ | You can implement a custom plugin to enable save button and fire onChange event to the server to save the editor's content. Please refer to [https://github.com/zkoss/zkbooks/tree/master/componentreference/src/main/webapp/input the source on the github]. | ||
+ | |||
+ | =Supported Events= | ||
{| border="1" | width="100%" | {| border="1" | width="100%" | ||
Line 64: | Line 200: | ||
| <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc> | | <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc> | ||
− | '''Description:''' | + | <tt>'''Description:''' </tt> Denotes the content of an input component has been modified by the user. |
− | |||
− | Denotes the content of an input component has been modified by the user. | ||
|- | |- | ||
Line 72: | Line 206: | ||
| <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc> | | <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc> | ||
− | '''Description: ''' | + | <tt>'''Description:''' </tt> Denotes that user is changing the content of an input component. Notice that the component's content (at the server) won't be changed until <tt>onChange</tt> is received. Thus, you have to invoke the <tt>getValue </tt>method in the <tt>InputEvent </tt>class to retrieve the temporary value. |
− | |||
− | Denotes that user is changing the content of an input component. Notice that the component's content (at the server) won't be changed until <tt>onChange</tt> is received. Thus, you have to invoke the <tt>getValue </tt>method in the <tt>InputEvent </tt>class to retrieve the temporary value. | ||
− | |||
|- | |- | ||
Line 81: | Line 212: | ||
| <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc> | | <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc> | ||
− | '''Description:''' | + | <tt>'''Description:''' </tt> Denotes the save button of the CKEditor component has been clicked by the user. |
− | |||
− | Denotes the save button of the CKEditor component has been clicked by the user. | ||
|} | |} | ||
Line 91: | Line 220: | ||
*NONE | *NONE | ||
− | =Use | + | =Use Cases= |
{| border='1px' | width="100%" | {| border='1px' | width="100%" | ||
Line 102: | Line 231: | ||
=Version History= | =Version History= | ||
+ | {{LastUpdated}} | ||
{| border='1px' | width="100%" | {| border='1px' | width="100%" | ||
! Version !! Date !! Content | ! Version !! Date !! Content | ||
|- | |- | ||
− | | | + | | |
− | | | + | | |
− | | | + | | |
|} | |} | ||
{{ZKComponentReferencePageFooter}} | {{ZKComponentReferencePageFooter}} |
Revision as of 01:42, 6 May 2019
CKEditor
- Demonstration: WYSIWYG Editor
- Java API: N/A
- JavaScript API: N/A
Template:ZKAddon (deprecated)
It is moved to google code after 3.5.2.0: zkckeditor (deprecated)
It is moved to github after 3.6.0.0: https://github.com/zkoss/zkckeditor
Maven
You need to include CKEditor jar in pom.xml before using it because it has a different group id from ZK other components.
<dependency>
<groupId>org.zkoss.zkforge</groupId>
<artifactId>ckez</artifactId>
<version>${ckez.version}</version>
</dependency>
Check the latest version on CE repository.
Employment/Purpose
The component used to represent CKEditor
CKEditor is a popular HTML on-line text editor developed by Frederico Caldeira Knabben.
CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to the results users have when publishing it.
It brings to the web common editing features found on desktop editing applications like Microsoft Word and OpenOffice.
Example
<ckeditor width="850px">
<attribute name="value"><![CDATA[
<table width="200" cellspacing="1" cellpadding="1" border="1">
<tbody>
<tr style="background: #B7B313; color:white;">
<td>First Name</td>
<td>Last Name</td>
</tr>
<tr>
<td>Jone</td>
<td>Hayes</td>
</tr>
<tr>
<td>Mary</td>
<td>Bally</td>
</tr>
</tbody>
</table>
]]></attribute>
</ckeditor>
It will turn on the save button when inside a form
<zk xmlns:n="http://www.zkoss.org/2005/zk/native">
<n:form>
<ckeditor width="850" />
</n:form>
</zk>
Work with ZK6 MVVM
Notice: Since Ckeditor 3.6.0.1, we have added data binding annotation into the lang-addon.xml file, so you no more need to add the settings below.
since 6.0.0
For work with ZK6 MVVM, it is required to create an addon xml and add the server annotation as follows:
WEB-INF/ckez-bind-addon.xml
<?xml version="1.0" encoding="UTF-8"?>
<language-addon>
<!-- The name of this addon. It must be unique -->
<addon-name>ckezbind</addon-name>
<!-- Specifies what other addon this depends
<depends></depends>
-->
<!-- Which language this addon will be added to -->
<language-name>xul/html</language-name>
<component>
<component-name>ckeditor</component-name>
<extends>ckeditor</extends>
<annotation>
<annotation-name>ZKBIND</annotation-name>
<property-name>value</property-name>
<attribute>
<attribute-name>ACCESS</attribute-name>
<attribute-value>both</attribute-value>
</attribute>
<attribute>
<attribute-name>SAVE_EVENT</attribute-name>
<attribute-value>onChange</attribute-value>
</attribute>
<attribute>
<attribute-name>LOAD_REPLACEMENT</attribute-name>
<attribute-value>value</attribute-value>
</attribute>
<attribute>
<attribute-name>LOAD_TYPE</attribute-name>
<attribute-value>java.lang.String</attribute-value>
</attribute>
</annotation>
</component>
</language-addon>
then add it into WEB-INF/zk.xml
<zk>
<language-config>
<addon-uri>/WEB-INF/ckez-bind-addon.xml</addon-uri>
</language-config>
</zk>
File browser
ZK CKEditor provides a default file browser for browsing the files in a folder that you specify. You can define a target folder in index.zul and when you open the add image/flash dialog and click "Browse Server", CKEditor will open a new window, and list all the files in the file browser.
File:ZKCompRef CKEditor filebrowser.png | <zk>
<ckeditor filebrowserImageBrowseUrl="img"/>
</zk>
|
Custom File browser
since 3.6.0.2
If you wish to customize your own file browser, you can change the location by calling CKeditor.setFilebrowserImageUploadUrl(page_url), and refer to CKEditor Developers Guide to create your custom file browser.
File upload
since 3.6.0.2
ZK CKEditor provides a default file upload handler for uploading the files to the folder you specify. You can define a target folder in index.zul and when user uploads a file, it will save the file in the folder that you have specified.
File:ZKCompRef CKEditor filebrowser.png | <zk>
<ckeditor filebrowserImageBrowseUrl="img" filebrowserImageUploadUrl="img"/>
</zk>
|
Custom File upload handler
since 3.6.0.2
If you wish to customize your own file upload handler, you can change the location by calling CKeditor.setFileUploadHandlePage(page_url), and refer to CKEditor Developers Guide to create your custom file upload handler.
Custom Configuration
Prepare a javascript file for configuration like:
config.js
CKEDITOR.editorConfig = function(config) {
//enable spell checker
config.disableNativeSpellChecker = false;
//Automatically enables "Spell Check As You Type" on editor startup
config.scayt_autoStartup = true;
//locale
config.language = 'de';
};
Please refer to http://docs.ckeditor.com/#!/api/CKEDITOR.config for complete configuration options.
Specify the configuration file at customConfigurationsPath attribute with the absolute path.
<ckeditor customConfigurationsPath="/config.js"/>
Custom Save Button
You can implement a custom plugin to enable save button and fire onChange event to the server to save the editor's content. Please refer to the source on the github.
Supported Events
InputEvent
Description: Denotes the content of an input component has been modified by the user. | |
InputEvent
Description: Denotes that user is changing the content of an input component. Notice that the component's content (at the server) won't be changed until onChange is received. Thus, you have to invoke the getValue method in the InputEvent class to retrieve the temporary value. | |
InputEvent
Description: Denotes the save button of the CKEditor component has been clicked by the user. |
Supported Children
*NONE
Use Cases
Version | Description | Example Location |
---|---|---|
Version History
Version | Date | Content |
---|---|---|