Tbeditor"

From Documentation
 
(11 intermediate revisions by 3 users not shown)
Line 2: Line 2:
  
 
= Tbeditor =
 
= Tbeditor =
 +
{{versionSince | 8.0.0}}
 +
{{ZK EE}}
  
*Java API: N/A
+
*Java API: [https://www.zkoss.org/javadoc/latest/zk/org/zkoss/zkmax/zul/Tbeditor.html Tbeditor]
*JavaScript API: N/A
+
*JavaScript API: [https://www.zkoss.org/javadoc/latest/jsdoc/zkmax/inp/Tbeditor.html Tbeditor]
  
 
= Employment/Purpose =
 
= Employment/Purpose =
The component used to represent [http://alex-d.github.io/Trumbowyg/ Trumbowyg]
 
 
 
Tbeditor is a rich 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.
 
Tbeditor is a rich 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.
  
= Example =
+
The component wraps [http://alex-d.github.io/Trumbowyg/ Trumbowyg]
[[Image:ZKCompRef_CKEditor.png]]
+
== Bundled Versions==
  
<source lang="xml" >
+
{| class="wikitable"
<ckeditor width="850px">
+
|-
<attribute name="value"><![CDATA[
+
! ZK !! Trumbowyg
<table width="200" cellspacing="1" cellpadding="1" border="1">
+
|-
<tbody>
+
| 9.6.0+ || 2.7.2
<tr style="background: #B7B313; color:white;">
+
|-
<td>First Name</td>
+
| 8.5.0 || 2.6
<td>Last Name</td>
+
|-
</tr>
+
| 8.0.0 || 2.0.0-beta.2
<tr>
+
|}
<td>Jone</td>
 
<td>Hayes</td>
 
</tr>
 
<tr>
 
<td>Mary</td>
 
<td>Bally</td>
 
</tr>
 
</tbody>
 
</table>
 
]]></attribute>
 
</ckeditor>
 
</source>
 
  
[[Image:ZKCompRef_CKEditor2.png]]
+
= Example =
 
+
[[Image:Zkcompref tbeditor.png|800px]]
'''It will turn on the save button when inside a form'''
 
  
 
<source lang="xml" >
 
<source lang="xml" >
<zk xmlns:n="http://www.zkoss.org/2005/zk/native">
+
<tbeditor id="tb" value="this is a demo for &lt;b&gt;trumbowy&lt;/b&gt; editor!!" />
<n:form>
 
<ckeditor width="850" />
 
</n:form>
 
</zk>
 
 
</source>
 
</source>
  
=Work with ZK6 MVVM=
+
= Customized Properties =
since 6.0.0
+
Tbeditor provides a way for users to customize their own properties, check [http://alex-d.github.io/Trumbowyg/documentation.html official document] for the details. (Not all properties are supported, for example, localization, and custom skin, are not supported.)
 
 
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
 
<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
+
Here is a simple example of how to programmatic change the property:
  
<source lang="xml" >
+
<source lang="java">
<zk>
+
Map config = new HashMap();
<language-config>
+
config.put("btns", new String[] {"bold", "italic", "link"});
<addon-uri>/WEB-INF/ckez-bind-addon.xml</addon-uri>
+
config.put("closable", true);
</language-config>
+
tbeditor.setConfig(config);
</zk>
 
 
</source>
 
</source>
Since 3.6.0.1, server annotation has been added to the lang-addon.xml file, so you no more need to add the above settings to your zk.xml file.
+
* Line 1: We create a map while a key is a property name with a supported value. Note that we have to wrap the value into <code>JavaScriptValue</code> object if it's not String.
 
 
=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.
 
  
 
=Supported Events=
 
=Supported Events=
  
{| border="1" | width="100%"
+
{| class='wikitable' | width="100%"
 
! <center>Name</center>
 
! <center>Name</center>
 
! <center>Event Type</center>
 
! <center>Event Type</center>
 
|-
 
|-
| <center><tt>onChange</tt></center>
+
| <center><code>onChange</code></center>
 
| <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc>
 
| <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc>
  
<tt>'''Description:''' </tt> Denotes the content of an input component has been modified by the user.
+
Denotes that the content of the component has been modified by a user
  
 
|-
 
|-
| <center><tt>onChanging</tt></center>
+
| <center><code>onChanging</code></center>
 
| <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc>
 
| <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc>
  
<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 a user is changing the content of an input component. Notice that the component's content (at the server) won't be changed until <code>onChange</code> is received. Thus, you have to invoke the <code>getValue </code>method in the <code>InputEvent </code>class to retrieve the temporary value.
 
 
|-
 
| <center><tt>onSave</tt></center>
 
| <javadoc>org.zkoss.zk.ui.event.InputEvent</javadoc>
 
 
 
<tt>'''Description:''' </tt> Denotes the save button of the CKEditor component has been clicked by the user.
 
 
 
 
|}
 
|}
  
Line 170: Line 67:
 
  *NONE
 
  *NONE
  
=Use Cases=
 
 
{| border='1px' | width="100%"
 
! Version !! Description !! Example Location
 
|-
 
| &nbsp;
 
| &nbsp;
 
| &nbsp;
 
|}
 
 
=Version History=
 
{{LastUpdated}}
 
 
{| border='1px' | width="100%"
 
! Version !! Date !! Content
 
|-
 
| &nbsp;
 
| &nbsp;
 
| &nbsp;
 
|}
 
  
 
{{ZKComponentReferencePageFooter}}
 
{{ZKComponentReferencePageFooter}}

Latest revision as of 05:58, 22 December 2023

Tbeditor

Since 8.0.0

  • Available for ZK:
  • http://www.zkoss.org/product/zkhttp://www.zkoss.org/whyzk/zkeeVersion ee.png

Employment/Purpose

Tbeditor is a rich 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.

The component wraps Trumbowyg

Bundled Versions

ZK Trumbowyg
9.6.0+ 2.7.2
8.5.0 2.6
8.0.0 2.0.0-beta.2

Example

Zkcompref tbeditor.png

<tbeditor id="tb" value="this is a demo for &lt;b&gt;trumbowy&lt;/b&gt; editor!!" />

Customized Properties

Tbeditor provides a way for users to customize their own properties, check official document for the details. (Not all properties are supported, for example, localization, and custom skin, are not supported.)

Here is a simple example of how to programmatic change the property:

Map config = new HashMap();
config.put("btns", new String[] {"bold", "italic", "link"});
config.put("closable", true);
tbeditor.setConfig(config);
  • Line 1: We create a map while a key is a property name with a supported value. Note that we have to wrap the value into JavaScriptValue object if it's not String.

Supported Events

Name
Event Type
onChange
InputEvent

Denotes that the content of the component has been modified by a user

onChanging
InputEvent

Denotes that a 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.

Supported Children

*NONE



Last Update : 2023/12/22

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.