# wangEditor **Repository Path**: GangDanYiHao/wangEditor ## Basic Information - **Project Name**: wangEditor - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2019-02-13 - **Last Updated**: 2021-09-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # wangEditor ##先说使用方式: 1.引入图标样式 ``` ``` 上述连接中的图表样式在下面使用: ``` function Video(editor) { this.editor = editor; this.$elem = $('
'); this.type = 'panel'; // 当前是否 active 状态 this._active = false; } ``` 不用我的样式,可以找到上面的函数在里面自定义图表样式 ,函数名:Video Audio ``` editor.customConfig = wangConfig; header的配置,只需要配置img的即可,视频的和音乐的都是走的这个header editor.customConfig.uploadImgHeaders={ webToken:sessionStorage.token, woAppId:sessionStorage.appid }; 下面的配置是粘贴的配置,在粘贴的时候进入这个函数: this.editor.customConfig.pasteTextHandle =function (content){ if (content == '' && !content) return ''; return removeFormatWrd(content); }; ``` 插入内容的配置 ``` insertLinkImg: function insertLinkImg(link) { var _this2 = this; if (!link) { return; } var editor = this.editor; // 校验格式 editor.cmd.do('insertHTML', ''); // 验证图片 url 是否有效,无效的话给出提示 }, 这边我写的比较简陋,欢迎issue ``` 2. wangConfig配置: ``` server:XXXX function customInsert(insertImg, result, editor) { //如果后台返回数据格式不一致,需要写多个函数对应 // 图片上传并返回结果,自定义插入图片的事件(而不是编辑器自动插入图片!!!) // insertImg 是插入图片的函数,editor 是编辑器对象,result 是服务器端返回的结果 // 举例:假如上传图片成功后,服务器端返回的是 {url:'....'} 这种格式,即可这样插入图片: var url = ip.JIp + result.data.uri; insertImg(url); // result 必须是一个 JSON 格式字符串!!!否则报错 } let customConfig = { uploadImgServer:server, uploadFileName:'file', zIndex:1, //编辑器层级,层级过高会导致悬浮与页面之上 uploadImgShowBase64:true, uploadVedioServer:server, uploadAudioServer:server, uploadImgMaxSize:3 * 1024 * 1024, uploadImgMaxLength:5, pasteText:false, pasteFilterStyle:false, pasteIgnoreImg:false, //粘贴别的文档的时候,是否忽略图片,false不忽略 uploadImgHooks:{ customInsert }, uploadVedioHooks:{ customInsert }, uploadAudioHooks:{ customInsert } }; ``` 3. 过滤格式的函数, ``` removeFormatWrd (html){ html = html.replace(/<\/?\w+:[^>]*>/gi, "");// Remove Tags with XML namespace declarations: