wangEditor富文本编辑器的使用

本文介绍了如何使用开源富文本编辑器wangEditor。通过引入wangEditor.min.js,创建编辑器实例,并展示了获取HTML和text文本的方法。此外,还提及了设置editor.config.uploadImgShowBase64为true以支持base64格式保存图片。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

富文本编辑器wangEditor的使用,这是一个开源的框架,官方网站地址:https://www.wangeditor.com/

使用该框架,需要接入一个js:wangEditor.min.js,

官方下载下载地址:https://www.jsdelivr.com/package/npm/wangeditor

云盘下载:https://pan.baidu.com/s/1OkbmUcP2OsxSPStwiNC6ug 
提取码:sdkh 
 

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"> 
	<title> 实例 </title>
	<script src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script> 	
		

</head>
<body>
<div id="div1">
    <p>欢迎使用 <b>wangEditor</b> 富文本编辑器</p>
</div>

<!-- 引入 wangEditor.min.js -->
<script type="text/javascript">
    const E = window.wangEditor
    const editor = new E('#div1')
    // 或者 const editor = new E( document.getElementById('div1') )
    editor.create()
</script>
			
</body>
</html>

 

简单说明:

获取 html

使用 editor.txt.html() 获取 html 。

使用 editor.txt.text() 获取 text 文本。

设置 editor.config.uploadImgShowBase64 = true 可使用 base64 格式保存图片。即,可选择本地图片,编辑器用 base64 格式显示图片。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值