当前位置:网站首页>富文本编辑:wangEditor使用教程
富文本编辑:wangEditor使用教程
2022-07-04 12:51:00 【愤怒的小火柴人】
前言
孩子最近做的一个项目需要用到富文本编辑,本来想用github上的react-draft-wysiwyg资源,但是发现出现了版本问题,React更新到了v18,所以很多功能都不好使了,百度半年也没找到解决方法,最后舍弃决定使用wangEditor
官方文档
一、官方文档
基本就是下载,引入
按需下载安装
我创建的是React项目,所以按react下载的依赖
二、样式问题
我是今天才发现这个样式问题,看看这万恶的官方大大,叫我们自定义,如果你不写样式,最后表格、引用、代码块什么的都只是简单的文本显示!!!
解决方法:
在引用Editor的外面嵌套一个div(什么都可,不写也行),你需要给这整个html内容显示区添加下面样式,就可以显示表格什么的了
.editor-content-view {
border: 3px solid #ccc;
border-radius: 5px;
padding: 0 10px;
margin-top: 20px;
overflow-x: auto;
}
.editor-content-view p, .editor-content-view li {
white-space: pre-wrap;
/* 保留空格 */
}
.editor-content-view blockquote {
border-left: 8px solid #d0e5f2;
padding: 10px 10px;
margin: 10px 0;
background-color: #f1f1f1;
}
.editor-content-view code {
font-family: monospace;
background-color: #eee;
padding: 3px;
border-radius: 3px;
}
.editor-content-view pre>code {
display: block;
padding: 10px;
}
.editor-content-view table {
border-collapse: collapse;
}
.editor-content-view td, .editor-content-view th {
border: 1px solid #ccc;
min-width: 50px;
height: 20px;
}
.editor-content-view th {
background-color: #f1f1f1;
}
.editor-content-view ul, .editor-content-view ol {
padding-left: 20px;
}
.editor-content-view input[type="checkbox"] {
margin-right: 5px;
}
注意editor-content-view是你自定义的class类名,下面是我的html显示代码(React)
<div className='editor-content-view' dangerouslySetInnerHTML={
{
__html:newsDetail.content
}} style={
{
border:'1px solid #BAC0BA',
margin:'0px 24px',
height:'300px',
overflow:'auto',
padding:'5px 10px'
}} />
边栏推荐
- Product identification of intelligent retail cabinet based on paddlex
- 【C 题集】of Ⅶ
- One of the solutions for unity not recognizing riders
- 392. Judgement subsequence
- Unittest框架之断言
- Understand chisel language thoroughly 08. Chisel Foundation (V) -- wire, REG and IO, and how to understand chisel generation hardware
- 吃透Chisel语言.05.Chisel基础(二)——组合电路与运算符
- BLOB,TEXT GEOMETRY or JSON column 'xxx' can't have a default value query 问题
- [FAQ] summary of common causes and solutions of Huawei account service error 907135701
- Haobo medical sprint technology innovation board: annual revenue of 260million Yonggang and Shen Zhiqun are the actual controllers
猜你喜欢
好博医疗冲刺科创板:年营收2.6亿 万永钢和沈智群为实控人
【Matlab】conv、filter、conv2、filter2和imfilter卷积函数总结
Interview disassembly: how to check the soaring usage of CPU after the system goes online?
Understand chisel language thoroughly 06. Chisel Foundation (III) -- registers and counters
Use the default route as the route to the Internet
面试拆解:系统上线后Cpu使用率飙升如何排查?
吃透Chisel语言.05.Chisel基础(二)——组合电路与运算符
Fisher信息量检测对抗样本代码详解
Interviewer: what is the internal implementation of hash data type in redis?
测试流程整理(3)
随机推荐
[FAQ] Huawei Account Service Error Report 907135701 Common reasons Summary and Solutions
China Post technology rushes to the scientific innovation board: the annual revenue is 2.058 billion, and the postal group is the major shareholder
【Antd】Antd 如何在 Form.Item 中有 Input.Gourp 时获取 Input.Gourp 的每一个 Input 的value
IP 实验室月复盘 · 第 5 期
如何在 2022 年为 Web 应用程序选择技术堆栈
面试拆解:系统上线后Cpu使用率飙升如何排查?
MySQL version 8 installation Free Tutorial
Excel快速合并多行数据
Unity shader learning (3) try to draw a circle
WS2818M是CPC8封装,是三通道LED驱动控制专用电路外置IC全彩双信号5V32灯可编程led灯带户外工程
美国土安全部部长警告移民“不要踏上危险的旅程”
Gorm 读写分离(转)
Understand chisel language thoroughly 04. Chisel Foundation (I) - signal type and constant
File creation, writing, reading, deletion (transfer) in go language
[C question set] of VII
2022g3 boiler water treatment examination question simulation examination question bank and simulation examination
IP lab monthly resumption · issue 5
Understand chisel language thoroughly 11. Chisel project construction, operation and test (III) -- scalatest of chisel test
Understand chisel language thoroughly 05. Chisel Foundation (II) -- combinational circuits and operators
苹果5G芯片研发失败:继续依赖高通,还要担心被起诉?