百度Ueditor

  最近用到了百度Ueditor,也來寫一寫百度Ueditor的使用教程:javascript

  1、從官網下載百度Ueditor,http://ueditor.baidu.com/website/download.html,根據本身的語言選擇壓縮包:php

  

 

  2、使用百度Ueditor:css

  1)簡單的demo以下【更多的配置請閱讀官方文檔:http://fex.baidu.com/ueditor/#server-php】:html

<!doctype html>
<html lang="zh_CN">
<head>
    
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <script type="text/javascript" charset="utf-8" src="__UE__/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__UE__/ueditor.all.min.js"> </script>
    <!--建議手動加在語言,避免在ie下有時由於加載語言失敗致使編輯器加載失敗-->
    <!--這裏加載的語言文件會覆蓋你在配置項目裏添加的語言類型,好比你在配置項目裏配置的是英文,這裏加載的中文,那最後就是中文-->
    <script type="text/javascript" charset="utf-8" src="__UE__/lang/zh-cn/zh-cn.js"></script>
    <title>Ueditor</title>
</head>
<body>

    <form action="{:U('Ueditor/saveUeditor')}" method="post"> 

        <script id="editor" type="text/plain" name="content" style="width:1024px;height:500px;"></script> 
        
        <button type="submit">提交</button>
        
    </form> 
    
    
    
    <script type="text/javascript">

    //實例化編輯器
    //建議使用工廠方法getEditor建立和引用編輯器實例,若是在某個閉包下引用該編輯器,直接調用UE.getEditor('editor')就能拿到相關的實例
    var ue = UE.getEditor('editor');
    
    
    
    
    
    </script>
</body>
</html>

  2)上傳圖片和其餘文件須要對\Ueditor\php\config.json進行配置,以上傳圖片爲例:java

    1. 上傳路徑配置:(官網例子)http://fex.baidu.com/ueditor/#server-path
    2. PHP使用說明:(官網例子)http://fex.baidu.com/ueditor/#server-php  

  3、展現編輯後的內容demo:web

  

<!doctype html>
<html lang="zh_CN">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <script type="text/javascript" charset="utf-8" src="__UE__/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__UE__/ueditor.all.min.js"> </script>
    <script src="__UE__/ueditor.parse.js"></script>
    <!--建議手動加在語言,避免在ie下有時由於加載語言失敗致使編輯器加載失敗-->
    <!--這裏加載的語言文件會覆蓋你在配置項目裏添加的語言類型,好比你在配置項目裏配置的是英文,這裏加載的中文,那最後就是中文-->
    <script type="text/javascript" charset="utf-8" src="__UE__/lang/zh-cn/zh-cn.js"></script>
    
    <script type="text/javascript" charset="utf-8" src="__UE__/third-party/SyntaxHighlighter/shCore.js"></script>
    <link rel="stylesheet" href="__UE__/third-party/SyntaxHighlighter/shCoreDefault.css">  
    <title>展現內容ueditor</title>
</head>
<body>
    <div class="thiscontent">
    {$content}
    </div>
    
    
</body>
<script type="text/javascript">
    uParse('.thiscontent',{
        rootPath: '../'
    });
</script>
</html>
相關文章
相關標籤/搜索