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

视频图站主题 wordpress电子商务网站建设预算

视频图站主题 wordpress,电子商务网站建设预算,手机网页源码,工农区网站建设昨天同事那边有个需求#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.hkea.cn/news/14449273/

相关文章:

  • 网站建设产品手册网站建设及网站推广
  • 网站建设公司哪家好cms网站管理系统制作
  • 怎么自己编码做网站游戏网页设计html代码大全
  • 物流网站建设公司哪家好物联网平台中心
  • 外贸订单的网站办公门户网站模板下载
  • 昆明做商城网站多少钱苏州网络公司排行榜
  • 莱西网站建设wap网站的域名
  • n加1网站建设无忧建站
  • 上海权威发布最新消息重庆网站优化网络服务
  • 电商网站建设公司哪家好郑州一站式网站搭建
  • 做网站友汇网抄袭网站后台会侵权吗
  • 怎样进行网站后台管理百度识图以图搜图
  • 外贸建站专业公司长春火车站防疫政策
  • 微信网站上传图片大学网站建设评比考核办法
  • 4a级旅游网站建设的要求网络空间服务商
  • 有没有哪个网站能够做简历怎么找关键词
  • 梁山网站开发网站建设 账务处理
  • 电子商务网站模板免费下载wordpress评论回复通知
  • 域名出售网站linux wordpress配置文件
  • 网站后台百度关键词竞价
  • 建立购物网站 appapp打包平台
  • 八字排盘网站建设网站如何编辑
  • 十堰建网站厦门seo优化
  • 东莞网站制作外包锦州网站建设公司
  • 做扎染的网站做网站服务器收费吗
  • 房产网站建设推广做网站什么软件好
  • 手机网站开发 速度傻瓜式wordpress
  • 中英文网站程序网站优化哪家好
  • 智慧园区 展厅设计seo快速排名培训
  • 淮安做微信网站群辉wordpress端口