💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 处理粘贴文本 **以下配置暂时对 IE 无效。IE 暂时使用系统自带的粘贴功能,没有样式过滤!** 用户从别的网站、论坛、word文档中拷贝文字的时候,可能会带上各种样式、字体、颜色等代码,需要编辑器做一定的处理,才能保持样式统一 #### 关闭粘贴文本处理事件 ``` editor.customConfig.pasteFilterStyle = false // 默认true editor.create(); ``` #### 忽略粘贴内容中的图片 ``` editor.customConfig.pasteIgnoreImg = true // 默认false editor.create(); ``` #### 处理粘贴文本 默认去除粘贴文本中的font-size,font,font-family,保持字体格式和大小基本统一。可根据自我需求进行覆盖修改 ``` editor.customConfig.pasteTextHandle = function(content) { // content 即粘贴过来的内容(html 或 纯文本),可进行自定义处理然后返回 content = content.replace(/(font-size:[^><;"]*(;)?)/ig, ''); // 去除font-size content = content.replace(/(font:[^><;"]*(;)?)/ig, ''); // 去除font content = content.replace(/(font-family:[^><;"]*(;)?)/ig, ''); // 去除font-family return content; } editor.create(); ``` #### 处理word特殊标签 用户从word拷贝的文章,可能会携带部分word专有的标签,如需去除这些标签,需搭配xss插件进行使用。详见[xss过滤](https://www.kancloud.cn/hejin/ushare-editor/883252)