• UEditor 编辑器


    1:插件的导入

    2:工具类

    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:页面书写

      1):js引用

    <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>

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

      ue.getContent();//主要存放上传的文件地址(后台使用)

      ue.getContentTxt();//附件名+文字内容(后台使用)

      3):放入到页面

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

      4):文件地址可在(config.json)文件中调节,也可使用默认地址

      如文件地址默认为:

      

      

  • 相关阅读:
    得到相对Plugin的路径
    GEF常见问题4:非矩形图元
    在Eclipse的About对话框上添加自己的图标
    用GMF生成简化的数据库设计器
    全超实用的Javascript类库和jQuery插件大全之一:图片,地图和图形
    #敏捷个人# 第二批敏捷个人推广者实践团报名
    2012年最新的12款超棒jQuery插件
    《敏捷个人》周刊 第14期 (可下载)
    时间管理:敏捷个人时中法卡片
    #敏捷个人# 实践团报名
  • 原文地址:https://www.cnblogs.com/ai211234/p/5945205.html
Copyright © 2020-2023  润新知