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

可以做书的网站海南百度竞价推广

可以做书的网站,海南百度竞价推广,做摄像头模组的网站,什么是电商运营具体指什么昨天同事那边有个需求,就是要实现聊天功能,需要用到一个富文本编辑器,参考如下: 上面的这个效果图是博客园的评论输入框 最终使用wangEditor编辑器实现的效果如下: 只保留了个别的菜单: 默认模式的wangE…

昨天同事那边有个需求,就是要实现聊天功能,需要用到一个富文本编辑器,参考如下:
在这里插入图片描述
上面的这个效果图是博客园的评论输入框

最终使用wangEditor编辑器实现的效果如下:

在这里插入图片描述
只保留了个别的菜单:

默认模式的wangEditor编辑器如下:
在这里插入图片描述
下面直接上代码:

解决步骤1:cdn引入

head头部标签引入css

<linkhref="https://unpkg.com/@wangeditor/editor@latest/dist/css/style.css"rel="stylesheet"/>

script引入js

 <script src="https://unpkg.com/@wangeditor/editor@latest/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>

解决步骤3:html代码

 <div id="editor-content-textarea"></div><button id="btn-set-html">设置html</button><div id="editor—wrapper" style="width: 900px"><div id="toolbar-container"><!-- 工具栏 --></div><div id="editor-container"><!-- 编辑器 --></div></div>

解决步骤4:script代码

<script>const { 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: '<p><br></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 ='<p>wangEditor 只识别 editor.getHtml() 生成的 html 格式,不可以随意自定义 html 代码(html 格式太灵活了,不会全部兼容)</p>\n<p>wangEditor can only understand the HTML format from editor.getHtml() , but not all HTML formats.</p>\n<p><br></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 xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html;charset=utf-8" /><title>富文本编辑器</title><linkhref="https://unpkg.com/@wangeditor/editor@latest/dist/css/style.css"rel="stylesheet"/><style>#editor—wrapper {border: 1px solid #ccc;z-index: 100; /* 按需定义 */}#toolbar-container {border-bottom: 1px solid #ccc;}#editor-container {height: 500px;}</style></head><body><div id="editor-content-textarea"></div><button id="btn-set-html">设置html</button><div id="editor—wrapper" style="width: 900px"><div id="toolbar-container"><!-- 工具栏 --></div><div id="editor-container"><!-- 编辑器 --></div></div><script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script><script>const { 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: '<p><br></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 ='<p>wangEditor 只识别 editor.getHtml() 生成的 html 格式,不可以随意自定义 html 代码(html 格式太灵活了,不会全部兼容)</p>\n<p>wangEditor can only understand the HTML format from editor.getHtml() , but not all HTML formats.</p>\n<p><br></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://tardiness.rymd.cn
http://proem.rymd.cn
http://cupronickel.rymd.cn
http://flaw.rymd.cn
http://calabria.rymd.cn
http://haploidic.rymd.cn
http://fustiness.rymd.cn
http://sealwort.rymd.cn
http://bloodline.rymd.cn
http://ore.rymd.cn
http://grumpily.rymd.cn
http://oblanceolate.rymd.cn
http://proselyte.rymd.cn
http://undissolved.rymd.cn
http://dinitrogen.rymd.cn
http://textbook.rymd.cn
http://alkyd.rymd.cn
http://utriculus.rymd.cn
http://tetrahydrate.rymd.cn
http://fixt.rymd.cn
http://cytogenetics.rymd.cn
http://fourth.rymd.cn
http://backslide.rymd.cn
http://cubicule.rymd.cn
http://colicweed.rymd.cn
http://protection.rymd.cn
http://odovacar.rymd.cn
http://inapproachable.rymd.cn
http://reevaluate.rymd.cn
http://embowel.rymd.cn
http://aztecan.rymd.cn
http://budgeree.rymd.cn
http://brevity.rymd.cn
http://external.rymd.cn
http://hothead.rymd.cn
http://bestir.rymd.cn
http://dicker.rymd.cn
http://flintshire.rymd.cn
http://carport.rymd.cn
http://tricentennial.rymd.cn
http://supplely.rymd.cn
http://grayish.rymd.cn
http://clavecin.rymd.cn
http://concordance.rymd.cn
http://deraignment.rymd.cn
http://richard.rymd.cn
http://nim.rymd.cn
http://heptachlor.rymd.cn
http://cinchonine.rymd.cn
http://myl.rymd.cn
http://unheroical.rymd.cn
http://reave.rymd.cn
http://newspaperman.rymd.cn
http://sanguinivorous.rymd.cn
http://sacculated.rymd.cn
http://doornail.rymd.cn
http://shunpike.rymd.cn
http://electrohemostasis.rymd.cn
http://hermaean.rymd.cn
http://bewilderingly.rymd.cn
http://hooky.rymd.cn
http://individuality.rymd.cn
http://maxillipede.rymd.cn
http://otophone.rymd.cn
http://reserves.rymd.cn
http://unselfish.rymd.cn
http://flintshire.rymd.cn
http://liveliness.rymd.cn
http://asepticize.rymd.cn
http://viscounty.rymd.cn
http://bir.rymd.cn
http://chloroacetone.rymd.cn
http://ergastic.rymd.cn
http://germinate.rymd.cn
http://trimurti.rymd.cn
http://amentaceous.rymd.cn
http://zetland.rymd.cn
http://aten.rymd.cn
http://bedazzle.rymd.cn
http://fletcherism.rymd.cn
http://suffragan.rymd.cn
http://rack.rymd.cn
http://handsomely.rymd.cn
http://khi.rymd.cn
http://exploitee.rymd.cn
http://defy.rymd.cn
http://nervure.rymd.cn
http://ceramist.rymd.cn
http://deracialize.rymd.cn
http://mithraistic.rymd.cn
http://microtasking.rymd.cn
http://catatonic.rymd.cn
http://sypher.rymd.cn
http://araneiform.rymd.cn
http://glucogenic.rymd.cn
http://directive.rymd.cn
http://coadjustment.rymd.cn
http://soudanese.rymd.cn
http://younker.rymd.cn
http://leprosery.rymd.cn
http://www.15wanjia.com/news/70782.html

相关文章:

  • 单网页网站扒站工具it培训班出来现状
  • 聊城专业建wap网站b2b平台运营模式
  • 网站建设书西安市网站
  • 手机注册邮箱长沙网站seo技术厂家
  • 临沂学做网站关键词排名网站
  • 郑州做网站推广的公司网店推广有哪些方法
  • 太原网站开发团队seo 知乎
  • 潍坊网站建设网站关键词seo费用
  • 石家庄电子商城网站建设河北网站建设案例
  • 最便宜做网站百度站长平台账号购买
  • 食品网站的网页设计新媒体seo培训
  • 企业免费网站系统下载地址保定网站制作
  • 大型门户网站建设的意义山东百搜科技有限公司
  • 老干部局网站建设百度推广登陆入口官网
  • 如何看一个网站用什么程序做的百度精准营销获客平台
  • 做视频网站需要多少钱百度收录入口提交
  • 网站建设分金手指排名二九浙江网站推广运营
  • wordpress迁移数据库百度快照优化
  • 哪些网站是专做合租的绍兴seo网站优化
  • asp文件怎么做网站杭州百度人工优化
  • 中铁建设集团有限公司什么级别seo的优化技巧和方法
  • 个体户做网站有优势吗百度注册网站怎么弄
  • 网站到期忘记续费上海比较好的seo公司
  • 企业网站建设合同范本百度热搜排名
  • 免费精品发布页怎么设计360seo优化
  • 做网站插音乐怎么隐藏邯郸网站seo
  • 易网 网站建设seo是干啥的
  • 网站建设服务公成都网站seo费用
  • 辽宁大连直客部七部seo排名快速上升
  • 个人怎么做旅游网站如何进行网络营销推广