>[success] # UEditor文本編輯器
* UEditor是由百度WEB前端研發部開發的所見即所得的開源富文本編輯器,具有輕量、可定制、用戶體驗優秀等特點。開源基于BSD協議,所有源代碼在協議允許范圍內可自由修改和使用
- [官網介紹](http://ueditor.baidu.com/website/)

>[info] # 簡單應用
```html
<html>
<head>
<!-- 配置文件 -->
<script type="text/javascript" src="<?php echo STATIC_PATH . "/ueditor/" ?>ueditor.config.js"></script>
<!-- 編輯器源碼文件 -->
<script type="text/javascript" src="<?php echo STATIC_PATH . "/ueditor/" ?>ueditor.all.js"></script>
<script src="<?php echo STATIC_PATH . "/js/jquery-1.8.0.js"; ?>"></script>
</head>
<body>
<div class="editor-wrapper">
<script id="container" name="content" type="text/plain"></script>
</div>
<input class="btn1" type="button" value="獲取內容">
<input class="btn2" type="button" value="設置內容">
</body>
<!-- 實例化編輯器 -->
<script type="text/javascript">
var ue = UE.getEditor('container', {
//自定義工具欄圖標:http://fex.baidu.com/ueditor/#start-toolbar
toolbars: [
[
'bold', 'italic', 'underline', 'fontsize', 'forecolor', 'horizontal', '|',
'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
'simpleupload', 'attachment', '|', 'link', 'unlink', '|',
'inserttable', 'deletetable', 'insertrow', 'insertcol', 'mergeright',
'mergedown', 'deleterow', 'deletecol', 'splittorows', 'splittocols', 'mergecells',
'fullscreen'
]
],
//初始化編輯器的內容
initialContent: '歡迎使用ueditor!',
//初始化編輯器寬度,默認1000
initialFrameWidth: 858,
//初始化編輯器高度,默認320
initialFrameHeight: 500,
//阻止div標簽自動轉換為p標簽
allowDivTransToP: false,
//是否自動長高,默認true
autoHeightEnabled: false,
//是否開啟字數統計
//wordCount:true
//允許的最大字符數
//maximumWords:10000
//字數統計提示,{#count}代表當前字數,{#leave}代表還可以輸入多少字符數,留空支持多語言自動切換,否則按此配置顯示
//wordCountMsg:'' //當前已輸入 {#count} 個字符,您還可以輸入{#leave} 個字符
//超出字數限制提示 留空支持多語言自動切換,否則按此配置顯示
//wordOverFlowMsg: '' //<span style="color:red;">你輸入的字符個數已經超出最大允許值,服務器可能會拒絕保存!</span>
});
$(".btn1").click(function () {
<!-- 判斷編輯器是否有內容: ue.hasContents -->
if (ue.hasContents) {
<!-- 獲取編輯器內容: ue.getContent() -->
alert(ue.getContent());
}
});
$(".btn2").click(function () {
<!-- 設置編輯器內容: ue.setContent('設置內容') -->
ue.setContent('設置內容!!!!');
});
</script>
</html>
```
>[info] # 相關閱讀
* [定制工具欄圖標](http://fex.baidu.com/ueditor/#start-toolbar)
* [上傳路徑配置](http://fex.baidu.com/ueditor/#server-path)
>[info] # 源碼下載
- Tip:公眾號回復【022】獲取源代碼

- 技術擴展閱讀
- 第一章
- 第一節 PHP與Golang 項目案例 - 留言板
- 第二節 PHP 實現日歷功能
- 第三節 ThinkPHP 自定義分頁模板
- 第四節 WebUpload 文件上傳
- 第五節 UEditor 文本編輯器
- 第六節 ThinkPHP 驗證碼
- 第七節 百度地圖
- 第八節 PHP 接口調試工具 SocketLog
- 第九節 PHP 跟蹤調試代碼 XDebug
- 第十節 PHPExcel 表格導入和導出
- 第二章
- 十一節 實戰筆記 - Kafka 篇
- 十二節 實戰筆記 - Redis 篇
- 十三節 實戰筆記 - MySQL 篇
- 十四節 圖片轉ASCII碼圖
- 十六節 Python 視頻轉代碼視頻
- 源代碼
- 代碼2
- 十七節 GRPC PHP客戶端