search
HomeWeb Front-endJS TutorialCode implementation of uploading picture pop-up layer using rich text editor

The content of this article is about the code implementation of using the rich text editor to upload the image pop-up layer. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

I asked a question two days ago, mainly because I am lazy and wanted to find a ready-made image that I uploaded before.
Regarding this, I found that there is no similar project in the entire community. I tried it out today and got the following results

Code implementation of uploading picture pop-up layer using rich text editor

Customize the toolbar on the editor and add a new Created a menu cloud disk.
Click on the cloud disk and a pop-up window similar to an emoticon will pop up as follows
Code implementation of uploading picture pop-up layer using rich text editorThis is what I have always wanted to make a pop-up window similar to UEditor.
After modification, the images and files previously uploaded by users can be called up in the editor. There is no need to modify the images uploaded by the editor.
Core Code
1. Customize the editor toolbar

//全局配置
    that.config = {
      //默认工具bar
      tool: [
        'strong', 'italic', 'underline', 'del'
        ,'|'
        ,'left', 'center', 'right'
        ,'|'
        ,'link', 'unlink', 'face', 'image', 'yunpan' //新增部分
      ]
      ,hideTool: []
      ,height: 240 //默认高
    };

2. Add a new click event

//全部工具
  ,tools = {
    html: &#39;<i class="layui-icon layedit-tool-html" title="HTML源代码" lay-command="html" layedit-event="html""></i><span class="layedit-tool-mid"></span>&#39;
    ,strong: &#39;<i class="layui-icon layedit-tool-b" title="加粗" lay-command="Bold" layedit-event="b""></i>&#39;
    ,italic: &#39;<i class="layui-icon layedit-tool-i" title="斜体" lay-command="italic" layedit-event="i""></i>&#39;
    ,underline: &#39;<i class="layui-icon layedit-tool-u" title="下划线" lay-command="underline" layedit-event="u""></i>&#39;
    ,del: &#39;<i class="layui-icon layedit-tool-d" title="删除线" lay-command="strikeThrough" layedit-event="d""></i>&#39;
    
    ,&#39;|&#39;: &#39;<span class="layedit-tool-mid"></span>&#39;
    
    ,left: &#39;<i class="layui-icon layedit-tool-left" title="左对齐" lay-command="justifyLeft" layedit-event="left""></i>&#39;
    ,center: &#39;<i class="layui-icon layedit-tool-center" title="居中对齐" lay-command="justifyCenter" layedit-event="center""></i>&#39;
    ,right: &#39;<i class="layui-icon layedit-tool-right" title="右对齐" lay-command="justifyRight" layedit-event="right""></i>&#39;
    ,link: &#39;<i class="layui-icon layedit-tool-link" title="插入链接" layedit-event="link""></i>&#39;
    ,unlink: &#39;<i class="layui-icon layedit-tool-unlink layui-disabled" title="清除链接" lay-command="unlink" layedit-event="unlink""></i>&#39;
    ,face: &#39;<i class="layui-icon layedit-tool-face" title="表情" layedit-event="face""></i>&#39;
    ,yunpan: &#39;<i class="layui-icon layedit-tool-image iconfont sw-yunpan-icon" title="云盘" layedit-event="yunpan"></i>&#39; //新增的部分
    ,image: &#39;<i class="layui-icon layedit-tool-image" title="图片" layedit-event="image"><input type="file" name="file"></i>&#39;
    ,code: &#39;<i class="layui-icon layedit-tool-code" title="插入代码" layedit-event="code"></i>&#39;
    
    ,help: &#39;<i class="layui-icon layedit-tool-help" title="帮助" layedit-event="help"></i>&#39;
  }

3. Cloud disk panel

//云盘面板
  ,yunpan=function(options, callback){
    //云盘
    var body = this, index = layer.open({
      type: 1
      ,id: &#39;LAY_layedit_yunpan&#39;
      ,area: &#39;600px&#39;
      ,shade: 0.05
      ,shadeClose: true
      ,moveType: 1
      ,title: &#39;企业云盘&#39;
      ,skin: &#39;layui-layer-msg&#39;
      ,content:[&#39;<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">&#39;
      ,&#39;<ul class="layui-tab-title">&#39;
      ,&#39;<li class="layui-this">产品图片</li>&#39;
      ,&#39;<li>头像</li>&#39;
      ,&#39;<li>LOGO</li>&#39;
      ,&#39;<li>轮播图片</li>&#39;
      ,&#39;<li>其他图片</li>&#39;
      ,&#39;<li>文档文件</li>&#39;
      ,&#39;</ul>&#39;
      ,&#39;<div class="layui-tab-content" style="height: 340px;">&#39;
      ,&#39;<div class="layui-tab-item layui-show">这里还没有加载产品图片</div>&#39;
      ,&#39;<div class="layui-tab-item">内容2</div>&#39;
      ,&#39;<div class="layui-tab-item">内容3</div>&#39;
      ,&#39;<div class="layui-tab-item">内容4</div>&#39;
      ,&#39;<div class="layui-tab-item">内容5</div>&#39;
      ,&#39;<div class="layui-tab-item">内容6</div>&#39;
      ,&#39;</div>&#39;
      ,&#39;</div> &#39;].join(&#39;&#39;)
    });
  }

Other details are difficult to display because they involve project data.

Related recommendations:

Rich text editor Problems related to deleting pictures

A brief analysis of the Yii2 integrated rich text editor redactor Example tutorial php rich text editor java rich text editor jsp rich text editor

The above is the detailed content of Code implementation of uploading picture pop-up layer using rich text editor. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
使用PHP和CKEditor创建富文本编辑器使用PHP和CKEditor创建富文本编辑器May 11, 2023 pm 04:06 PM

随着Web应用程序的广泛使用,创建富文本编辑器变得越来越普遍。CKEditor被广泛认可为最好的富文本编辑器之一,因为它具有良好的可定制性和易用性。本文将介绍如何使用PHP和CKEditor创建富文本编辑器。CKEditor简介CKEditor是一个开源的、跨平台的富文本编辑器,通过JavaScript实现。它提供了直观易懂的工具栏,包括字体样式、格式化、图

如何使用PHP开发CMS中的富文本编辑器如何使用PHP开发CMS中的富文本编辑器Jun 21, 2023 am 11:20 AM

随着互联网的发展,越来越多的网站开始采用CMS(内容管理系统)来管理自己的内容。而富文本编辑器则是这些CMS不可或缺的一部分,它使得用户可以方便地编辑、排版和发布内容。在本文中,我们将介绍如何使用PHP开发CMS中的富文本编辑器。一、什么是富文本编辑器富文本编辑器是一种可以呈现多种格式的文本编辑器,使用户可以使用各种样式进行排版操作,而不需要学习HTML或C

Go语言Web开发框架中常见的富文本编辑器控件Go语言Web开发框架中常见的富文本编辑器控件Jun 04, 2023 am 09:10 AM

随着Web应用程序的普及,富文本编辑器成为Web开发中必不可少的一个工具。而在使用Go语言进行Web开发时,我们也需要选择一个适合的富文本编辑器控件来丰富我们的网站和应用程序。在本文中,我们将会探讨Go语言Web开发常见的富文本编辑器控件。FroalaEditorFroalaEditor是一款流行的富文本编辑器控件,被广泛应用于Web开发中。它具有现代化

如何使用Java编写CMS系统的富文本编辑器模块如何使用Java编写CMS系统的富文本编辑器模块Aug 04, 2023 pm 06:57 PM

如何使用Java编写CMS系统的富文本编辑器模块在现代网站开发中,内容管理系统(ContentManagementSystem,简称CMS)扮演着至关重要的角色。而其中的富文本编辑器模块更是不可或缺的一部分,它能够让网站管理员方便地编辑和发布内容。本文将介绍如何使用Java编写CMS系统的富文本编辑器模块,并提供代码示例。一、选择合适的富文本编辑器在开始

uniapp中如何实现富文本编辑器uniapp中如何实现富文本编辑器Jul 04, 2023 pm 12:17 PM

uniapp中如何实现富文本编辑器在许多应用程序中,我们经常遇到需要用户输入富文本内容的情况,比如编辑文章、发布动态等。为了满足这个需求,我们可以使用富文本编辑器来实现。在uniapp中,我们可以使用一些开源的富文本编辑器组件,比如wangeditor、quill等。下面,我将以wangeditor为例,介绍在uniapp中如何实现富文本编

如何在uniapp中使用富文本编辑器插件实现富文本编辑功能如何在uniapp中使用富文本编辑器插件实现富文本编辑功能Oct 20, 2023 am 10:31 AM

如何在uniapp中使用富文本编辑器插件实现富文本编辑功能概述在现代应用中,富文本编辑器是一个必备的功能,因为它允许用户在应用中创建丰富多样的文本内容,包括字体样式、字号、颜色、插入图片等。而uniapp作为一个跨平台开发框架,也提供了使用富文本编辑器插件来实现这一功能的方式。本文将介绍如何在uniapp中使用富文本编辑器插件,并给出具体的代码示例。步骤导入

商城开发中的富文本编辑器技巧 (29个字)商城开发中的富文本编辑器技巧 (29个字)Jun 30, 2023 pm 09:03 PM

PHP开发商城中的富文本编辑器功能实现技巧随着互联网的快速发展,越来越多的商城采用在线编辑器来提供富文本编辑功能,使用户能够通过简单的操作设计自己的商品详情页面。在PHP开发商城时,如何实现富文本编辑器功能是一个关键的技术难题。本文将介绍一些实现富文本编辑器功能的技巧,帮助PHP开发人员更好地完成这个任务。一、选择合适的富文本编辑器在选择富文本编辑器时,我们

Vue组件开发:富文本编辑器的实现Vue组件开发:富文本编辑器的实现Nov 24, 2023 am 08:08 AM

Vue组件开发:富文本编辑器的实现随着互联网的快速发展,富文本编辑器成为了现代Web应用中不可或缺的一部分。富文本编辑器提供了更丰富的编辑功能,使用户可以轻松地修改文本样式、插入图片、创建链接等。在Vue.js中,我们可以使用各种插件和库来实现富文本编辑器。本文将介绍一个使用Vue.js和Quill.js库开发的富文本编辑器。Quill.js是一个基于Jav

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

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.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools