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

JS_wangEditor富文本编辑器

官网:https://www.wangeditor.com/

引入 CSS 定义样式

<link href="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>

定义 HTML 结构

<div id="editor—wrapper"><div id="toolbar-container"><!-- 工具栏 --></div><div id="editor-container"><!-- 编辑器 --></div>
</div>

引入 JS 创建编辑器

<script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script>
<script>
const { createEditor, createToolbar } = window.wangEditorconst editorConfig = {placeholder: 'Type here...',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: 'default', // or 'simple'
})const toolbarConfig = {}const toolbar = createToolbar({editor,selector: '#toolbar-container',config: toolbarConfig,mode: 'default', // or 'simple'
})
</script>

.

http://www.lryc.cn/news/37851.html

相关文章:

  • Django实践-06导出excel/pdf/echarts
  • java并发入门(一)共享模型—Synchronized、Wait/Notify、pack/unpack
  • Ast2500增加用户自定义功能
  • 用Python暴力求解德·梅齐里亚克的砝码问题
  • 离散Hopfield神经网络的分类——高校科研能力评价
  • Retrofit核心源码分析(三)- Call逻辑分析和扩展机制
  • 源码分析spring如和对@Component注解进行BeanDefinition注册的
  • C语言--字符串函数1
  • Webstorm使用、nginx启动、FinalShell使用
  • 源码分析Spring @Configuration注解如何巧夺天空,偷梁换柱。
  • vector的使用及模拟实现
  • “华为杯”研究生数学建模竞赛2007年-【华为杯】A题:基于自助法和核密度估计的膳食暴露评估模型(附获奖论文)
  • 刷题(第三周)
  • 新C++(14):移动语义与右值引用
  • TCP相关概念
  • MySQL锁篇
  • SWF (Simple Workflow Service)简介
  • java(Class 常用方法 获取Class对象六种方式 动态和静态加载 类加载流程)
  • 【数据结构】线性表和顺序表
  • Ubuntu数据库安装(mysql)
  • MyBatis-Plus的入门学习
  • 华为OD机试题 - 内存池(JavaScript)
  • 数据库索引原理
  • 字符函数和字符串函数详解(1)
  • 【数据分析:工具篇】NumPy(1)NumPy介绍
  • mysql时区问题
  • 磨金石教育摄影技能干货分享|高邮湖上观花海
  • mysql navicat忘记密码
  • Git的下载、安装、配置、使用、卸载
  • 【博客631】监控网卡与进程网络IO使用情况