The main content of this article is to teach you how to insert Baidu Rich Text Editor into Html. Friends who are interested can learn about it. I hope it will be helpful to you.
In daily work, you will definitely need a rich text editor. The rich text editor is powerful and easy to use. If you use Baidu rich text editor, you first need to download the demo of Baidu editor, and then Create the ueditor.html file, introduce Baidu editor, then introduce it in the html file, and then use js to instantiate the editor. The code is as follows:
<!DOCTYPE html> <html> <head> <title>百度编辑器</title> </head> <body> <script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script> <script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"></script> <script type="text/javascript" charset="utf-8" src="ueditor/lang/zh-cn/zh-cn.js"></script> <script id="editor" type="text/plain" name="gdesc" style="width:100%;height:350px;"></script> <script type="text/javascript"> //实例化编辑器 var ue = UE.getEditor('editor', {}); </script> </body> </html>
Go here and open the ueditor.html file above in the browser and you will see the following picture:
This is instantiation There are many functions in the initial editor, some of which may not be used by us at all. What should we do if we want to customize it? Don’t worry, Baidu provides customizable functions. Just use the js that instantiates the editor above. Change the code to the following code:
<script type="text/javascript"> //实例化编辑器 var ue = UE.getEditor('editor', { toolbars: [ [ 'undo', //撤销 'bold', //加粗 'underline', //下划线 'preview', //预览 'horizontal', //分隔线 'inserttitle', //插入标题 'cleardoc', //清空文档 'fontfamily', //字体 'fontsize', //字号 'paragraph', //段落格式 'simpleupload', //单图上传 'insertimage', //多图上传 'attachment', //附件 'music', //音乐 'inserttable', //插入表格 'emotion', //表情 'insertvideo', //视频 'justifyleft', //居左对齐 'justifyright', //居右对齐 'justifycenter', //居中对 'justifyjustify', //两端对齐 'forecolor', //字体颜色 'fullscreen', //全屏 'edittip ', //编辑提示 'customstyle', //自定义标题 'template', //模板 ] ] }); </script>
Refresh the ueditor.html page and you will see the changes:
If you want to customize any functions, just refer to the above In the ueditor.config.js file in the downloaded editor demo, add the corresponding string to the toolbars attribute:
//工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义 , toolbars: [[ 'fullscreen', 'source', '|', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|', 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|', 'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|', 'directionalityltr', 'directionalityrtl', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|', 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|', 'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|', 'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|', 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|', 'print', 'preview', 'searchreplace', 'drafts', 'help' ]]
ueditor.config.js file can customize the editor For many functions, you only need to remove the '//' in front of the corresponding attribute. True means on, false means off and set it. For example:
//elementPathEnabled //是否启用元素路径,默认是显示 ,elementPathEnabled : false //wordCount ,wordCount:false //是否开启字数统计 //,maximumWords:10000 //允许的最大字符数
// Whether to automatically grow taller, the default is true
,autoHeightEnabled:false
After modifying the ueditor.config.js file according to the above code, refresh the page and you will see the difference:
The following The element path and word count have disappeared. Isn’t it more beautiful? O(∩_∩)O~
In practical application, we may also upload content edited by Baidu editor under a domain name (for example: A picture was uploaded under the domain name www.52lnamp.com), and the requirement is not only to display it under this domain name, but also to display it under other domain names. In this case, the picture will not exist,
This is because the default upload path in the Baidu Editor configuration file is a relative path, which means that the address of the image uploaded above is uploaded relative to the current domain name, and can only be displayed under the domain name you uploaded. Other domain names cannot be displayed.
If you want to display it on another domain name, you only need to modify the configuration file to an absolute path. Open the demo downloaded above, find the php/config.json file, and open it. Then you will see
where the attribute imageUrlPrefix can be added to the domain name: "imageUrlPrefix": "http://www.xxx.com", /* Image access Path prefix */
It should be noted that when adding a domain name, you must include http or https. Only if it is written in this way can it be displayed normally. If not, it will be displayed normally. When you quote, you will repeatedly add a domain name in front of it. A basic understanding of these is enough to meet daily needs. If you have other alternative needs, you can refer to the Baidu editor documentation. You are also welcome to supplement and learn from each other.
Related tutorials: javascript video tutorial
The above is the detailed content of How to insert Html into Baidu rich text editor ueditor. For more information, please follow other related articles on the PHP Chinese website!

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools