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 () { return tinymce.activeEditor.getContent(); } t.setContent = function (content) { return tinymce.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);