UEditor 編輯器

1:插件的導入javascript

2:工具類java

package com.flow.util;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class UEditorContentUtil {

    /**
     * @Title: getExcelsFromContent 
     * @Description: 獲取UEditor內容中的Excel文件
     * @param content UEditor內容
     * @param rootPath 系統路徑
     * @return
     * @throws Exception
     */
    public static List<File> getExcelsFromContent(String content,
            String rootPath) throws Exception {
        List<File> excelList = new ArrayList<File>();

        Document doc = Jsoup.parse(content);
        // 獲取內容中的a標籤
        Elements els = doc.getElementsByTag("a");
        Iterator<Element> it = els.iterator();
        for (; it.hasNext();) {
            Element el = it.next();
            // 獲取文件地址
            String href = el.attr("href");
            String[] str = href.split("\\.");
            String end = str[str.length - 1];
            // 判斷是不是Excel文件
            if ("xls".equals(end) || "xlsx".equals(end)) {
                File file = new File(rootPath, href);
                if (file.exists()) {
                    excelList.add(file);
                }
            }
        }

        return excelList;
    }
}

3:頁面書寫node

  1):js引用json

<script type="text/javascript" src="plugins/ueditor1_4_3_2/ueditor.config.js"></script>
<script type="text/javascript" src="plugins/ueditor1_4_3_2/ueditor.all.js"> </script>
<script type="text/javascript" src="plugins/ueditor1_4_3_2/lang/zh-cn/zh-cn.js"></script>

  2):JQ工具

  var ue = UE.getEditor('editor');//"editor"對應  ---3)的id屬性 <script id="editor"></script>spa

  ue.hasContents();//判斷插件是否有內容(文字或附件等)插件

  ue.getContent();//主要存放上傳的文件地址(後臺使用)excel

  ue.getContentTxt();//附件名+文字內容(後臺使用)code

  3):放入到頁面blog

<td class="tl xwid">
   <script id="editor" type="text/plain" style="width:100%;height:210px;"></script>
</td>

  4):文件地址可在(config.json)文件中調節,也可以使用默認地址

 

  如文件地址默認爲:

相關文章
相關標籤/搜索