当前位置: 首页 > news >正文

视频图站主题 wordpress广州市城乡住房建设厅网站

视频图站主题 wordpress,广州市城乡住房建设厅网站,太仓住房与城乡建设部网站,seo优化易下拉排名昨天同事那边有个需求#xff0c;就是要实现聊天功能#xff0c;需要用到一个富文本编辑器#xff0c;参考如下#xff1a; 上面的这个效果图是博客园的评论输入框 最终使用wangEditor编辑器实现的效果如下#xff1a; 只保留了个别的菜单#xff1a; 默认模式的wangE…昨天同事那边有个需求就是要实现聊天功能需要用到一个富文本编辑器参考如下 上面的这个效果图是博客园的评论输入框 最终使用wangEditor编辑器实现的效果如下 只保留了个别的菜单 默认模式的wangEditor编辑器如下 下面直接上代码 解决步骤1cdn引入 head头部标签引入css linkhrefhttps://unpkg.com/wangeditor/editorlatest/dist/css/style.cssrelstylesheet/script引入js script srchttps://unpkg.com/wangeditor/editorlatest/dist/index.js/script解决步骤2其余css配置 style#editor—wrapper {border: 1px solid #ccc;z-index: 100; /* 按需定义 */}#toolbar-container {border-bottom: 1px solid #ccc;}#editor-container {height: 500px;}/style解决步骤3html代码 div ideditor-content-textarea/divbutton idbtn-set-html设置html/buttondiv ideditor—wrapper stylewidth: 900pxdiv idtoolbar-container!-- 工具栏 --/divdiv ideditor-container!-- 编辑器 --/div/div解决步骤4script代码 scriptconst { createEditor, createToolbar } window.wangEditor;const editorConfig {placeholder: 请输入内容...,// maxLength:2000,//设置最大长度MENU_CONF: {},onChange(editor) {const html editor.getHtml();console.log(editor content, html);// 也可以同步到 textarea},};const editor createEditor({selector: #editor-container,html: pbr/p,config: editorConfig,mode: simple, // or simple});const toolbarConfig {excludeKeys: [blockquote,bgColor,// headerSelect,italic,group-more-style, // 排除菜单组写菜单组 key 的值即可bulletedList, //无序列表numberedList, //有序列表todo, //待办emotion, //表情insertTable, //表格codeBlock, //代码块group-video, //视频divider, //分割线fullScreen, //全屏// insertLink,//插入链接group-justify, //对齐方式group-indent, //缩进fontSize, //字体大小fontFamily, //字体lineHeight, //行高underline, //下划线color, //颜色undo, //撤销redo, //重做],};toolbarConfig.modalAppendToBody true;// 创建 toolbar 和 editor// 可监听 modalOrPanelShow 和 modalOrPanelHide 自定义事件来设置样式、蒙层editor.on(modalOrPanelShow, (modalOrPanel) {if (modalOrPanel.type ! modal) return;const { $elem } modalOrPanel; // modal element// 设置 modal 样式定位、z-index// 显示蒙层});editor.on(modalOrPanelHide, () {// 隐藏蒙层});const toolbar createToolbar({editor,selector: #toolbar-container,config: toolbarConfig,mode: default, // or simple});editorConfig.MENU_CONF[uploadImage] {server: /api/upload-image,fieldName: custom-field-name,// 继续写其他配置...customInsert(res, insertFn) {console.log(res);// JS 语法// res 即服务端的返回结果// 从 res 中找到 url alt href 然后插入图片// url: xxx, // 图片 src 必须// alt: yyy, // 图片描述文字非必须// href: zzz // 图片的链接非必须insertFn(url, alt, href);},//【注意】不需要修改的不用写wangEditor 会去 merge 当前其他配置}; });如果要实现回显则需要通过下面的代码 // textarea 初始化值const textarea document.getElementById(editor-content-textarea);textarea.value pwangEditor 只识别 editor.getHtml() 生成的 html 格式不可以随意自定义 html 代码html 格式太灵活了不会全部兼容/p\npwangEditor can only understand the HTML format from editor.getHtml() , but not all HTML formats./p\npbr/p;// Set HTMLdocument.getElementById(btn-set-html).addEventListener(click, () {if (editor.isDisabled()) editor.enable();if (!editor.isFocused()) editor.focus();editor.select([]);editor.deleteFragment();window.wangEditor.SlateTransforms.setNodes(editor,{ type: paragraph },{ mode: highest });editor.dangerouslyInsertHtml(textarea.value);完整代码如下 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlnshttp://www.w3.org/1999/xhtmlheadmeta http-equivcontent-type contenttext/html;charsetutf-8 /title富文本编辑器/titlelinkhrefhttps://unpkg.com/wangeditor/editorlatest/dist/css/style.cssrelstylesheet/style#editor—wrapper {border: 1px solid #ccc;z-index: 100; /* 按需定义 */}#toolbar-container {border-bottom: 1px solid #ccc;}#editor-container {height: 500px;}/style/headbodydiv ideditor-content-textarea/divbutton idbtn-set-html设置html/buttondiv ideditor—wrapper stylewidth: 900pxdiv idtoolbar-container!-- 工具栏 --/divdiv ideditor-container!-- 编辑器 --/div/divscript srchttps://unpkg.com/wangeditor/editorlatest/dist/index.js/scriptscriptconst { createEditor, createToolbar } window.wangEditor;const editorConfig {placeholder: 请输入内容...,// maxLength:2000,//设置最大长度MENU_CONF: {},onChange(editor) {const html editor.getHtml();console.log(editor content, html);// 也可以同步到 textarea},};const editor createEditor({selector: #editor-container,html: pbr/p,config: editorConfig,mode: simple, // or simple});const toolbarConfig {excludeKeys: [blockquote,bgColor,// headerSelect,italic,group-more-style, // 排除菜单组写菜单组 key 的值即可bulletedList, //无序列表numberedList, //有序列表todo, //待办emotion, //表情insertTable, //表格codeBlock, //代码块group-video, //视频divider, //分割线fullScreen, //全屏// insertLink,//插入链接group-justify, //对齐方式group-indent, //缩进fontSize, //字体大小fontFamily, //字体lineHeight, //行高underline, //下划线color, //颜色undo, //撤销redo, //重做],};toolbarConfig.modalAppendToBody true;// 创建 toolbar 和 editor// 可监听 modalOrPanelShow 和 modalOrPanelHide 自定义事件来设置样式、蒙层editor.on(modalOrPanelShow, (modalOrPanel) {if (modalOrPanel.type ! modal) return;const { $elem } modalOrPanel; // modal element// 设置 modal 样式定位、z-index// 显示蒙层});editor.on(modalOrPanelHide, () {// 隐藏蒙层});const toolbar createToolbar({editor,selector: #toolbar-container,config: toolbarConfig,mode: default, // or simple});editorConfig.MENU_CONF[uploadImage] {server: /api/upload-image,fieldName: custom-field-name,// 继续写其他配置...customInsert(res, insertFn) {console.log(res);// JS 语法// res 即服务端的返回结果// 从 res 中找到 url alt href 然后插入图片// url: xxx, // 图片 src 必须// alt: yyy, // 图片描述文字非必须// href: zzz // 图片的链接非必须insertFn(url, alt, href);},//【注意】不需要修改的不用写wangEditor 会去 merge 当前其他配置};// textarea 初始化值const textarea document.getElementById(editor-content-textarea);textarea.value pwangEditor 只识别 editor.getHtml() 生成的 html 格式不可以随意自定义 html 代码html 格式太灵活了不会全部兼容/p\npwangEditor can only understand the HTML format from editor.getHtml() , but not all HTML formats./p\npbr/p;// Set HTMLdocument.getElementById(btn-set-html).addEventListener(click, () {if (editor.isDisabled()) editor.enable();if (!editor.isFocused()) editor.focus();editor.select([]);editor.deleteFragment();window.wangEditor.SlateTransforms.setNodes(editor,{ type: paragraph },{ mode: highest });editor.dangerouslyInsertHtml(textarea.value);});/script/body /html
http://www.dnsts.com.cn/news/269860.html

相关文章:

  • 做钓鱼网站软件下载重庆有什么好玩的游乐场
  • 静态网站建设规划辽宁朝阳网站建设公司
  • 建设房地产法律网站centos 7安装wordpress
  • 自己的服务器 做网站江苏大丰做网站
  • dw网站建设代码深圳做人工智能芯片的公司
  • 建行深圳网站网站建设样式
  • 广州市开发区建设网站seo技术快速网站排名
  • 网站源码下载后怎么布置做平面vi网站
  • 那个网站科四做课时免费网站代码下载
  • o2o系统网站建设肇庆市网站建设
  • 佛山网站建设服务公司用哪个网站做相册视频文件夹
  • 微盟网站模板求一个好用的网站
  • 能解析国外网站的dns长沙房地产公司排名
  • seo两个域名一个网站有影响吗衡阳网站优化
  • 松江网站建设公司怎么样企业app有哪些软件
  • 网站推广规范wed网站开发是什么
  • wordpress优化网站打开速度施工企业安全生产管理体系案例
  • 做高端网站的公司html5国内网站建设
  • 营销型网站建设题库提供企业网站建设价格
  • 专业北京网站建设河北网站建设seo优化营销制作设计
  • 可做长图的网站商城网站建设策划书
  • 工作室网站需要备案吗山东省建设厅招标网站首页
  • 网站推广方案中国企业信用网
  • 网站首页代码在哪里5g全连接工厂建设指南
  • 专门做国外家具书籍的网站数据库做网站和做软件有什么不一样
  • 怎样创建行业门户网站ppt模板百度网盘
  • 建设企业网站收费中企动力销售陪酒多吗
  • wordpress仿站教程2018html用什么软件编写好一点
  • 做五金上哪个网站推广家乡网页设计教程
  • 网站在线支付接口申请怎么查询技术支持公司做的网站