The simple use of Baidu editor Ueditor

Source: Internet
Author: User

Recently, I've just been assigned a task published with a message that uses a rich text editor. Used before, but this time I chose Baidu Rich Text editor ueditor1_4_3-utf8-jsp version.

actually see Ueditor function is very powerful, but the design of Baidu is still very good. It can be used with just a little configuration.

First download to Ueditor1_4_3-utf8-jsp.rar, the connection address is: http://ueditor.baidu.com/website/. I chose the utf-8 version.

Unzip the whole copy to the Java Web Project's Web page root directory. I am here to build the project with MyEclipse, so the ueditor copy to the Webroot can be.

The second step is to refer to the jar package under Ueditor/jsp/lib. You can choose to configure directly in the Java Build path, or directly into the Webroot/web-inf/lib folder, and the item will automatically refer to the jar under that folder. It is recommended to put the jar directly under the web-inf/lib so that your jar is moved with the project and the system will load the jars under the project according to the relative path. If you choose the first, this function will fail if the jar file is moved.

Step three, introduce 2 JS files on the page

<scripttype= "Text/javascript" src= "Ueditor/ueditor.config.js" ></script><scripttype= "text/ JavaScript "src=" Ueditor/ueditor.all.js "></script>

Fourth step, in the editor location of the page, add HTML code

1 <textareaname= "content" id= "Myeditor" ></textarea>2  <scripttype= "text/ JavaScript ">3  // must use this sentence, otherwise you need to go to ueditor.config.js modify the configuration information for the path 4  Ue.geteditor (' Myeditor '); 5  </script>

Fifth step, Ueditor support image, document, music and other file upload function, if you want to configure the upload path, you can modify the Ueditor/jsp/config.json.

This file has a clear text description for each configuration item. Attach a picture upload configuration:

    /*Uploading picture Configuration items*/"Imageactionname": "Uploadimage",/*execute the action name of the upload picture*/"Imagefieldname": "Upfile",/*name of the submitted picture form*/"Imagemaxsize": 2048000,/*Upload size limit, Unit B*/"Imageallowfiles": [". png", ". jpg", ". jpeg", ". gif", ". bmp"],/*upload image format display*/"Imagecompressenable":true,/*whether to compress the picture, the default is True*/"Imagecompressborder": 1600,/*picture compression maximum edge limit*/"Imageinsertalign": "None",/*How to insert a picture floating*/"Imageurlprefix": "",/*Picture access Path prefix*/"Imagepathformat": "_images/image/{yyyy}{mm}{dd}/{time}{rand:6}",/*upload save path, can customize save path and file name format*/

The sixth step, Ueditor support the custom function, the interface display features are configurable, as long as the Ueditor/ueditor.config.js toolbar in the configuration can be removed, the code is as follows:

1  //all the function buttons and drop-down boxes on the toolbar, you can select the new definition you want when you use the new editor instance2 , toolbars: [[3' fullscreen ', ' source ', ' | ', ' undo ', ' Redo ', ' | ', 4' Bold ', ' italic ', ' underline ', ' fontborder ', ' strikethrough ', ' superscript ', ' subscript ', ' removeformat ', ' formatmatch ' ', ' autotypeset ', ' blockquote ', ' pasteplain ', ' | ', ' ForeColor ', ' BackColor ', ' insertorderedlist ', ' insertunorderedlist ' ', ' SelectAll ', ' cleardoc ', ' | ', 5' Rowspacingtop ', ' rowspacingbottom ', ' lineheight ', ' | ', 6' Customstyle ', ' paragraph ', ' fontfamily ', ' fontsize ', ' | ', 7' Directionalityltr ', ' Directionalityrtl ', ' indent ', ' | ', 8' Justifyleft ', ' justifycenter ', ' justifyright ', ' justifyjustify ', ' | ', ' touppercase ', ' tolowercase ', ' | ', 9' Link ', ' unlink ', ' anchor ', ' | ', ' imagenone ', ' imageleft ', ' imageright ', ' imagecenter ', ' | ', Ten' Simpleupload ', ' insertimage ', ' emotion ', ' scrawl ', ' insertvideo ', ' music ', ' attachment ', ' map ', ' gmap ', ' insertframe ', ' Insertcode ', ' pagebreak ', ' template ', ' background ', ' | ',  One' Horizontal ', ' date ', ' time ', ' spechars ', ' snapscreen ', ' wordimage ', ' | ',  A' Inserttable ', ' deletetable ', ' insertparagraphbeforetable ', ' insertrow ', ' deleterow ', ' insertcol ', ' deletecol ', ' MergeCells ', ' mergeright ', ' mergedown ', ' splittocells ', ' splittorows ', ' splittocols ', ' charts ', ' | ',  -' Searchreplace ', ' help ', ' drafts ' -]]

It looks like 6 steps, in fact every step is very simple. To let the little friends see more clearly, come to Zhang:

The effect is not bad, in fact, it seems that complex functions, the implementation is very simple. Simple features can be complex to implement. We are not just using a variety of open source components that look complicated and simple to use, but also to learn how to encapsulate complex functions and provide a simple interface for others to use easily.

The simple use of Baidu editor Ueditor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.