百度编辑器UEditor实现自动保存

简介: 百度编辑器UEditor实现自动保存
<?php

namespace App\Admin\Extensions;

use Encore\Admin\Form\Field;

class NEditor extends Field
{
    protected $view = 'admin.neditor';

    protected static $css = [
        '/neditor/themes/notadd/css/neditor.css',
    ];

    protected static $js = [
        '/neditor/neditor.config.js',
        '/neditor/neditor.all.js'
    ];

    public function render()
    {


        $this->script = <<<EOT
        UE.delEditor("{$this->id}");

        var ue = UE.getEditor('{$this->id}',{
            initialFrameWidth:null,
            initialFrameHeight:400,
            autoHeight: false,
            elementPathEnabled: false,
            enableContextMenu: true,
            autoClearEmptyNode: true,
            wordCount: true,
            imagePopup: false,
            autotypeset: {indent: true, imageBlockLine: 'center'},
            allowDivTransTop: false,
            enterTag: 'br',
            autoHeightEnabled:false,
            enableAutoSave: true, //启用自动保存
            saveInterval: 500 //自动保存间隔时间, 单位ms
        });
        ue.ready(function () {
             ue.setHeight(400);
             ue.execCommand('serverparam', '_token', '{{ csrf_token() }}');
             
             //获取草稿内容
             var html = ue.getContent();
             if (html == '' || html == 'undefined') {
                 console.log('editor is null');
                 ue.execCommand('drafts');
             } else {
                 console.log('editor not null');
             }
        });

EOT;
        return parent::render();
    }
}
目录
相关文章
|
3月前
|
开发框架 JavaScript 前端开发
百度富文本编辑器配置(vue3)
百度富文本编辑器配置(vue3)
|
3月前
|
Ubuntu Linux
百度搜索:蓝易云【Linux设置默认编辑器(qbit)】
现在,你已经成功将默认编辑器设置为qbit。在终端中输入 `editor`命令或打开文本文件时,系统将使用qbit作为默认编辑器来打开文件。请注意,`update-alternatives`命令还可以用于设置其他默认应用程序。
95 3
|
2月前
ueditor1.5 百度富文本 编辑器增加字间距功能及按钮
ueditor1.5 百度富文本 编辑器增加字间距功能及按钮
24 0
|
资源调度 JavaScript
vue项目:集成富文本编辑器 - 百度ueditor(vue-ueditor-wrap)
vue项目:集成富文本编辑器 - 百度ueditor(vue-ueditor-wrap)
410 0
|
3月前
|
开发工具
百度搜索:蓝易云【使用vim编辑器,进行保存时报错:E382: Cannot write, ‘buftype‘ option is set详解。】
请注意,'buftype'选项的设置通常是由于某些插件或配置文件导致的。如果您在Vim的配置文件(如.vimrc)或使用的插件中设置了'buftype'选项,请检查相关配置并确保设置正确。
66 0
|
3月前
|
Linux 开发工具
百度搜索:蓝易云【Linux如何使用Nano编辑器教程。】
需要注意的是,Nano是一款轻量级的文本编辑器,适用于简单的编辑任务。如果你需要进行更复杂的编辑或编程任务,可能需要使用更强大的编辑器,如Vim或Emacs。
55 0
|
9月前
ueditor编辑器初始化
ueditor编辑器初始化
|
10月前
|
Ubuntu 数据安全/隐私保护
百度搜索:蓝易云【如何在 Ubuntu 22.04 LTS 上安装分区编辑器 GParted?】
希望这些步骤能够帮助您在Ubuntu 22.04 LTS上安装GParted并顺利使用它进行分区管理。
89 0
|
前端开发
ueditor 百度富文本编辑器后端配置(上传图片)
ueditor 百度富文本编辑器后端配置(上传图片)
407 0
|
JavaScript API
fast admin 使用百度富文本编辑器添加赋值
fast admin 使用百度富文本编辑器添加赋值
152 0