当前位置:网站首页>Summernote rich text editor
Summernote rich text editor
2022-07-24 02:46:00 【Summer is already slightly cool】
One 、 file
- Official website address https://summernote.org/
- github https://github.com/summernote/summernote
- Select version download https://github.com/summernote/summernote/tags
Two 、 Use
- bootstrap Find the online address on the official website
- summernote Find the online address on the official website
- File upload to Tp5 For example , Refer to this article :kindeditor Custom upload file ( Picture and video files ) Fang ( backstage PHP)
- Successfully returns
return [
'error' => 0, // success
'url' => ' picture , The address after uploading the video '
];
- Failure to return
return [
'error' => 1, // When the failure
'message' => $file->getError()
];
design sketch

The code is as follows :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>summernote Rich text editor </title>
<!-- Reference Online bootstrap.css -->
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"/>
<!-- Reference Online summernote.css -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/summernote.css" rel="stylesheet">
</head>
<body>
<div id="vue-mount-element" style="padding: 20px">
<textarea name="content" id="editor">{
{info.content}}</textarea>
</div>
</body>
<!-- Reference Online jquery.js -->
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<!-- Abreast of the times Bootstrap The core JavaScript file -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<!-- Abreast of the times summernote The core JavaScript file -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/summernote.js"></script>
<!-- Reference Online vue.js -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script> let vueObject = new Vue({
el: '#vue-mount-element', //vue Mounted elements data() {
return {
info: {
id: 1, content: "<b> Bold content </b>, Normal content "} }; } }) $(document).ready(function () {
$('#editor').summernote({
// Rich text mounted elements id=editor // height: 500, // width: 1000, minHeight: 300, // Wide and high , Set up according to your own needs : If it is displayed on the mobile phone , Just make the width smaller , such as 410px maxwidth: 1000, minwidth: 200, maxHeight: 500, focus: false, callbacks: {
onImageUpload: function (files, editor) {
var $files = $(files); // adopt each Method to iterate through each file $files.each(function () {
var file = this; // FormData, new form Form encapsulation , Baidu , But in fact, the usage is very simple , as follows var data = new FormData(); // Add files to file in , The back end can get the parameter named “file” data.append("file", file); // ajax Upload $.ajax({
data: data, type: "POST", url: "/upload/image",// div Upper action cache: false, contentType: false, processData: false, // Call the method when successful , Backend return json data success: function (response) {
// console.log(response) if (response.error != 0) {
alert(" Upload failed :" + response.message); } else {
// Insert into summernote $('#editor').summernote('insertImage', response.url); } }, }); }) }, onFileUpload: function (files) {
// Upload files , There is no default , How to add , Please read the next one var $files = $(files); // adopt each Method to iterate through each file $files.each(function () {
var file = this; // FormData, new form Form encapsulation , Baidu , But in fact, the usage is very simple , as follows var data = new FormData(); // Add files to file in , The back end can get the parameter named “file” data.append("file", file); // ajax Upload $.ajax({
data: data, type: "POST", url: "/upload/file",// div Upper action cache: false, contentType: false, processData: false, // Call the method when successful , Backend return json data success: function (response) {
// console.log(response) if (response.error != 0) {
alert(" Upload failed :" + response.message); } else {
$(".note-video-url").val(response.url); //Insert Video Before, input online video url Remove disable after address , Now we upload it to Video URL Disable is removed after the input box is assigned $(".note-video-btn").removeAttr("disabled"); } }, }); }) } } }); }) </script>
</html>
Four 、 His shan zhishi
边栏推荐
- Liveqing live broadcast on demand streaming media OBS streaming live broadcast how to obtain interface verification token video verification streamtoken and configure token validity
- Mysql database, sorting and single line processing functions
- Is it safe to open an account for Xiaobai stock? Can I apply online?
- 508. The subtree element with the most occurrences and the pure C implementation of hash table method
- Make life full of happiness
- go log包
- Data conversion problem in Qt development serial communication software: when reading_ Qbytearray to string; When sending_ Data format; Int to hexadecimal format string; Intercept characters in string
- Honey, we are homeless now
- Nirvana rebirth! Byte Daniel recommends a large distributed manual, and the Phoenix architecture makes you become a God in fire
- Recommendation system topic | recommendation system architecture and single domain cross domain recall model
猜你喜欢

22 -- range and of binary search tree

PMP first-hand data and information acquisition

Share an API Gateway project based on ABP and yarp

数据湖(十五):Spark与Iceberg整合写操作

Unity TimeLine使用教程

508. The subtree element with the most occurrences and the pure C implementation of hash table method

Job hunting and recruitment system of SSM part-time job hunting

SkyWalking分布式系统应用程序性能监控工具-上

summernote富文本编辑器

Camper recruitment | AI youth with the world in mind, the United Nations needs your help for sustainable development!
随机推荐
To forge ahead on a new journey, the city chain science and technology carnival was grandly held in Xiamen
Vscade connects to the server. The password is correct, but it has been unable to connect
go log包
中城院真的在帮助供应商解决问题吗?
【补题日记】[2022牛客暑期多校2]K-Link with Bracket Sequence I
Honey, we are homeless now
This article shows you how to use SQL to process weekly report data
攻防世界WEB练习区(view_source、get_post、robots)
TCP data transmission and performance
Jparepository extension interface
Understand the timing of loading classes into the JVM
Nodejs builds cloud native microservice applications based on dapr, a quick start guide from 0 to 1
How to get gait energy map Gei
JpaRepository扩展接口
自定义log注解,请求抓取
Redis data type concept
7月开发过程中遇到的问题总结
7 issues to consider before website construction
508. 出现次数最多的子树元素和-哈希表法纯c实现
如何获取步态能量图gei