TinyMCE 6 编辑器+ Layui 2.8.2+单页面

x33g5p2x  于5个月前 转载在 其他  
字(1.0k)|赞(0)|评价(0)|浏览(609)

TinyMCE 6 编辑器+ Layui 2.8.2+单页面

TinyMCE 6 编辑器+ Layui 2.8.2  拓展 tinymce.js

目录结构 

layui.define(function(exports) {

    var t ={};

    //初始化
t.bulid = function(options) {
        if (typeof tinymce == 'undefined') {
           
            var script = document.createElement('script');
            script.src = '.././lib/layui_exts/tinymce/tinymce.min.js';
            script.onload = function() {
                tinymce.init(options);               
            };
            document.head.appendChild(script);
        } else{          
            tinymce.activeEditor.destroy();
            tinymce.init(options);  
           
        }
    }

    t.getContent = function() {
        returntinymce.activeEditor.getContent();
    }

    t.setContent = function(content) {
        returntinymce.activeEditor.setContent(content);
    }

    exports('tinymce', t);

});

单页面  入口:

layui.extend({
    setter: "config",
    admin: "lib/admin",
    view: "lib/view",
    tinymce: '{/}/lib/layui_exts/tinymce'}).define(["setter", "admin"], function (e) {

页面 调用:

layui.use([ "tinymce"], function(t) {     
            , layedit =layui.tinymce

  //编辑器
        layedit.bulid({ selector: "textarea#mycontent", height: 800, language: "zh-Hans" });

获取 编辑器内容:

layedit.getContent();

设置内容

layedit.setContent(content);

相关文章