当前位置:网站首页>富文本编辑: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'
}} />
边栏推荐
- 30: Chapter 3: develop Passport Service: 13: develop [change / improve user information, interface]; (use * * * Bo class to accept parameters, and use parameter verification)
- Fisher信息量检测对抗样本代码详解
- 英视睿达冲刺科创板:年营收4.5亿 拟募资9.79亿
- Haobo medical sprint technology innovation board: annual revenue of 260million Yonggang and Shen Zhiqun are the actual controllers
- qt 怎么检测鼠标在不在某个控件上
- 苹果5G芯片研发失败:继续依赖高通,还要担心被起诉?
- 华昊中天冲刺科创板:年亏2.8亿拟募资15亿 贝达药业是股东
- 安装Mysql
- 華昊中天沖刺科創板:年虧2.8億擬募資15億 貝達藥業是股東
- Gorm data insertion (transfer)
猜你喜欢

基于YOLOv1的口罩佩戴检测

吃透Chisel语言.05.Chisel基础(二)——组合电路与运算符

Interview disassembly: how to check the soaring usage of CPU after the system goes online?

markdown 语法之字体标红

The font of markdown grammar is marked in red

【Matlab】conv、filter、conv2、filter2和imfilter卷积函数总结

1200. Minimum absolute difference

吃透Chisel语言.12.Chisel项目构建、运行和测试(四)——Chisel测试之ChiselTest

How to choose a technology stack for web applications in 2022

Understanding and difference between viewbinding and databinding
随机推荐
MySQL 5 installation and modification free
吃透Chisel语言.12.Chisel项目构建、运行和测试(四)——Chisel测试之ChiselTest
China Post technology rushes to the scientific innovation board: the annual revenue is 2.058 billion, and the postal group is the major shareholder
Lick the dog until the last one has nothing (state machine)
PHP log debugging
Ruichengxin micro sprint technology innovation board: annual revenue of 367million, proposed to raise 1.3 billion, Datang Telecom is a shareholder
R语言使用dplyr包的group_by函数和summarise函数基于分组变量计算目标变量的均值、标准差
Interview disassembly: how to check the soaring usage of CPU after the system goes online?
测试流程整理(2)
美国土安全部部长警告移民“不要踏上危险的旅程”
R语言dplyr包summarise_if函数计算dataframe数据中所有数值数据列的均值和中位数、基于条件进行数据汇总分析(Summarize all Numeric Variables)
Mask wearing detection based on yolov1
392. 判断子序列
mac redis安装与使用,连接远程服务器 redis
Understand chisel language thoroughly 06. Chisel Foundation (III) -- registers and counters
go vendor 项目迁移到 mod 项目
Blob, text geometry or JSON column'xxx'can't have a default value query question
Detailed explanation of Fisher information quantity detection countermeasure sample code
Code hoof collection of wonderful secret place
程序员的焦虑