• 【快速上手系列】百度富文本编辑器的快速上手和简单使用


    【快速上手系列】百度富文本编辑器的快速上手和简单使用

    使用步骤

    1、首先要把demo下载下来

    demo链接: (18条消息) 百度富文本编辑器demo-Javascript文档类资源-CSDN文库

    • index.html:demo中的测试页面,可以看到很多方法使用

    2、新建一个web项目

    3、在webapp下新建一个文件夹,将demo中的文件(除index.html外)放入此文件夹中,index.html放到webapp下

    4、将demo项目/jsp/lib中的jar包粘到webapp/WEB-INF/lib

    5、然后将demo项目/jsp/config.json文件中

    "imageActionName": "uploadimage", 
        "imageFieldName": "upfile", 
        "imageMaxSize": 2048000, 
        "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], 
        "imageCompressEnable": true, 
        "imageCompressBorder": 1600,
        "imageInsertAlign": "none",
        "imageUrlPrefix": "/这里写成你自己的项目名!!!", 	
        "imagePathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    如果路径不对会导致富文本编辑器中添加图片时不能正确回显

    config.json官方带的文件有注释会报错,我整理了一下,代码直接粘就行:

    {
    
        "imageActionName": "uploadimage", 
        "imageFieldName": "upfile", 
        "imageMaxSize": 2048000, 
        "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], 
        "imageCompressEnable": true, 
        "imageCompressBorder": 1600,
        "imageInsertAlign": "none",
        "imageUrlPrefix": "/这里写成你自己的项目名!!!", 
        "imagePathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
                                  
        "scrawlActionName": "uploadscrawl", 
        "scrawlFieldName": "upfile", 
        "scrawlPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", 
        "scrawlMaxSize": 2048000, 
        "scrawlUrlPrefix": "", 
        "scrawlInsertAlign": "none",
    
        "snapscreenActionName": "uploadimage", 
        "snapscreenPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", 
        "snapscreenUrlPrefix": "", 
        "snapscreenInsertAlign": "none", 
      
        "catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"],
        "catcherActionName": "catchimage", 
        "catcherFieldName": "source", 
        "catcherPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", 
        "catcherUrlPrefix": "", 
        "catcherMaxSize": 2048000,
        "catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
        
        "videoActionName": "uploadvideo", 
        "videoFieldName": "upfile", 
        "videoPathFormat": "/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}", 
        "videoUrlPrefix": "", 
        "videoMaxSize": 102400000,
        "videoAllowFiles": [
            ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
            ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"], 
    
       
        "fileActionName": "uploadfile", 
        "fileFieldName": "upfile", 
        "filePathFormat": "/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}", 
        "fileUrlPrefix": "", 
        "fileMaxSize": 51200000, 
        "fileAllowFiles": [
            ".png", ".jpg", ".jpeg", ".gif", ".bmp",
            ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
            ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
            ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
            ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
        ],
    
       
        "imageManagerActionName": "listimage", 
        "imageManagerListPath": "/ueditor/jsp/upload/image/", 
        "imageManagerListSize": 20, 
        "imageManagerUrlPrefix": "",
        "imageManagerInsertAlign": "none", 
        "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
    
     
        "fileManagerActionName": "listfile", 
        "fileManagerListPath": "/ueditor/jsp/upload/file/", 
        "fileManagerUrlPrefix": "", 
        "fileManagerListSize": 20, 
        "fileManagerAllowFiles": [
            ".png", ".jpg", ".jpeg", ".gif", ".bmp",
            ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
            ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
            ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
            ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
        ]
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77

    效果图

    请添加图片描述

    注意点

    1、自己做页面时调用时js引用:

    <script type="text/javascript" charset="utf-8" src="/这里的路径记得改/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/这里的路径记得改/ueditor.all.min.js"> </script>
    <!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="/这里的路径记得改/lang/zh-cn/zh-cn.js"></script>
    
    • 1
    • 2
    • 3
    • 4
    • 5

    且调用js的顺序不要变,否则显示不出来

    2、可以粘demo中index.html的一些js代码示例来用到自己的网页

  • 相关阅读:
    JD(按关键字搜索商品)API接口
    最详细的CompletableFuture异步编程-进阶篇
    vue/react/node项目通过eslint检查语法规范
    Neo4j入门实战
    若依-匿名注解@Anonymous解析
    tomcat敏感数据加密实现方案
    Linux通过端口号找到对应的服务及其安装位置
    《最新出炉》系列初窥篇-Python+Playwright自动化测试-11-playwright操作iframe-上篇
    构建一个语音转文字的WebApi服务
    MYSQL存储过程注释详解
  • 原文地址:https://blog.csdn.net/weixin_55452293/article/details/127918374