zoukankan      html  css  js  c++  java
  • vs2008 使用百度编辑器

    准备工作

    百度编辑器官方下载并将文件放到项目根目录下

    因为vs2008 只到Framework 3.5,所以需要将4.0的东西去掉。

    1)下载.net framework 3.5版的 Newtonsoft.Json.dll 替换掉 /net/bin 中的。

    2)删除 net 文件下 config.cs 里的 using System.Dynamic,因为3.5版本没有这个。

    3)查找替换,用 string.IsNullOrEmpty 替换 String.IsNullOrWhiteSpace。

    4)去掉 config.json 里的解释,不然上传图片功能用不了。(下面的可以直接拿去用,里面修改了图片显示的地址,"imageUrlPrefix": "" 原文是这样:"imageUrlPrefix": "/ueditor/net/", /* 图片访问路径前缀 */)

    {
        
        "imageActionName": "uploadimage", 
        "imageFieldName": "upfile",
        "imageMaxSize": 2048000, 
        "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], 
        "imageCompressEnable": true, 
        "imageCompressBorder": 1600,
        "imageInsertAlign": "none",
        "imageUrlPrefix": "",
        "imagePathFormat": "/UeEditor/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", 
    
     
        "scrawlActionName": "uploadscrawl",
        "scrawlFieldName": "upfile",
        "scrawlPathFormat": "upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", 
        "scrawlMaxSize": 2048000,
        "scrawlUrlPrefix": "/ueditor/net/", 
        "scrawlInsertAlign": "none",
    
    
        "snapscreenActionName": "uploadimage", 
        "snapscreenPathFormat": "upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", 
        "snapscreenUrlPrefix": "/ueditor/net/", 
        "snapscreenInsertAlign": "none", 
    
       
        "catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"],
        "catcherActionName": "catchimage", 
        "catcherFieldName": "source", 
        "catcherPathFormat": "upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
        "catcherUrlPrefix": "/ueditor/net/",
        "catcherMaxSize": 2048000,
        "catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], 
    
        
        "videoActionName": "uploadvideo", 
        "videoFieldName": "upfile", 
        "videoPathFormat": "upload/video/{yyyy}{mm}{dd}/{time}{rand:6}",
        "videoUrlPrefix": "/ueditor/net/", 
        "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": "upload/file/{yyyy}{mm}{dd}/{time}{rand:6}", 
        "fileUrlPrefix": "/ueditor/net/", 
        "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": "upload/image",
        "imageManagerListSize": 20, 
        "imageManagerUrlPrefix": "/ueditor/net/",
        "imageManagerInsertAlign": "none", 
        "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
    
       
        "fileManagerActionName": "listfile", 
        "fileManagerListPath": "upload/file", 
        "fileManagerUrlPrefix": "/ueditor/net/", 
        "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"
        ] 
    
    }
    去掉注释后的config.json

    关于调用

    <script src="../../UeEditor/ueditor.config.js" type="text/javascript"></script>
    
    <script src="../../UeEditor/ueditor.all.min.js" type="text/javascript"></script>
    
    <script id="editor" type="text/plain" style=" 1024px; height: 500px;"></script>
    
    <script type="text/javascript">
        var ue = UE.getEditor('editor');//初始化后才能看到百度编辑器
        function getData() {
            return UE.getEditor('editor').getContent();//获取内容
        }
        ue.ready(function() {
            //异步回调
            UE.getEditor('editor').execCommand('insertHtml', "123456");//设置内容,用于修改功能
        });
    </script>

    Ps:Js 的引用顺序不能变,否则会报错。下载的 demo 中有详细用法。

    关于上传图片(重点)

    此时上传图片是不好使的,按F12,会看到报错的信息,错误的原因是因为没有找到 net 文件夹中的 controller.ashx 这个文件。

    controller.ashx 里面写了加载 config.json,加载到了,上传图片的功能也就好使了。

    解决步骤:

    1、修改 ueditor.config.js 文件,将, serverUrl: URL + "net/controller.ashx" 改成 , serverUrl: "/UeEditor/controller.ashx" ,改成相对路径。(此处可不改,但是需要删除 net 文件夹下的 web.config ,显示图片的路径也会有些问题。)

    2、准备工作中的第4条,已经处理了显示图片的路径问题。(去掉注释,清空路径)

    3、将 net 文件夹下的 config.json 与 controller.ashx 移动到 UeEditor 下。

    效果:

     Ps:关于图片的保存路径,可以在 etApp_Code 中 UploadHandler.cs 的 Process 方法中修改。

  • 相关阅读:
    左孩子右兄弟的字典树
    UVA 1401 Remember the Word
    HDOJ 4770 Lights Against Dudely
    UvaLA 3938 "Ray, Pass me the dishes!"
    UVA
    Codeforces 215A A.Sereja and Coat Rack
    Codeforces 215B B.Sereja and Suffixes
    HDU 4788 Hard Disk Drive
    HDU 2095 find your present (2)
    图的连通性问题—学习笔记
  • 原文地址:https://www.cnblogs.com/cang12138/p/9450329.html
Copyright © 2011-2022 走看看