惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - 小摘

针对TianvCms的搜索优化文章源码(无版权, 随便用) 针对C#的正规表达式测试程序源码下载(无版权, 随便用) 简易的可视化自定义表单程序源码下载(无版权, 随便用) 主要手段 - 浅谈搜索优化 为什么要优化 - 浅谈搜索优化 TianvCMS后台截图 从“铁道部12306网站被曝出现SQL漏洞”想到 TianvCMS部分官方插件 分享T4代码生成及源码(sqlite版),欢迎新手参考、修改(无版权) 小议数据框架的封装 想要开源了 - 发布在tianvcms发布以前 对IE9浏览器开发者预览版的一些感觉 大家帮忙看看如果面对这个升级文档该怎么处理,或者怎样才能处理得快一些(问在tianvcms改版前) 好久没更新了, 等待着把项目做简单 贴图不说话 从Windows Mac版想到 何去何从 快速开发之我见 - 送给开发效率不断下降的朋友们(二)
多编辑器支持的实现方式
小摘 · 2012-05-12 · via 博客园 - 小摘

多编辑支持已知都不是什么复杂的问题,

主要的问题主要发生在于编辑器本身的尺寸不小, 如果同时加载将很耗资源, 并可能冲突。

如果通过在aspx页面内判断, 则又可能因为新增加编辑而修改代码。

为了解决这两个问题, 参考了接口的方式, 

为每个编辑制作一个调用的js并都继承(js动态,并不需要真正去继承)相同的接口。

参考常用功能,主要有以下几个接口4个接口:为el生成编辑器、为el删除编辑器,更新编辑器内容到el,往el插入内容(上传文件用)

代码如下: 

Interface

(function ($) {

$.extend({
Editor: {
Create: function (el) { },
Destroy: function (el) { },
Sync: function (el) { },
InsertHtml: function (el, result) { }
}
});

})(jQuery);

为每个编辑器做好接口以后, 只需要用lab.js(一个js异步框架),按配置调用各自接口即可,

最后, 附上几个编辑器制作好的接口,(针对tianvcms系统进行了处理, 仅供参考)

KingEditor

(function ($) {

    $LAB
        .script(Config.Paths.Editor + "kindeditor/kindeditor-min.js")
        .script(Config.Paths.Editor + "kindeditor/lang/zh_CN.js");

    var tools_mini = [
        'source', '|',
        'bold', 'italic', 'underline', '|',
        'fontname', 'fontsize', '|',
        'forecolor', 'hilitecolor', '|',
        'formatblock', 'insertorderedlist', '|',
        'preview', 'fullscreen'];
    var tools_normal = [
        'source', '|',
        'undo', 'redo', '|',
        'cut', 'copy', 'paste', 'plainpaste', '|',
        'justifyleft', 'justifycenter', 'justifyright', '|',
        'link', 'unlink', 'anchor', '|',
        'template', 'hr', 'table', '/',
        'removeformat', '|',
        'bold', 'italic', 'underline', 'strikethrough', '|',
        'fontname', 'fontsize', '|',
        'forecolor', 'hilitecolor', '|',
        'formatblock', 'insertorderedlist', '|',
        'preview', 'fullscreen'];

    function EditorCreate(el) {

        $LAB
            .script(Config.Paths.Editor + "kindeditor/kindeditor-min.js")
            .wait()
            .script(Config.Paths.Editor + "kindeditor/lang/zh_CN.js")
            .wait(function () {
                var miniMode = el.hasClass('input_editor_mini');
                var tools = miniMode ? tools_mini : tools_normal;

                KindEditor.basePath = Config.Paths.Editor + 'kindeditor/';
                var editor = KindEditor.create('#' + el.attr('id'), {
                    width: el.width(),
                    height: el.height(),
                    cssPath: Config.Editor.ContentsCss,
                    items: tools
                });
                el.data('editor', editor);
            });
    }

    function EditorDestroy(el) {
        var editor = el.data('editor');
        if (editor) {
            editor.remove();
            editor = null;
        }
    }

    function EditorInsertHtml(el, result) {
        var editor = el.data('editor');
        if (editor) {
            //editor.toggleSource( false );
            editor.insertHtml(result);
        }
    }

    function EditorSync(el) {
        var editor = el.data('editor');
        if (editor) {
            editor.sync();
        }
    }

    $.extend({
        Editor: {
            Create: EditorCreate,
            Destroy: EditorDestroy,
            Sync: EditorSync,
            InsertHtml: EditorInsertHtml
        }
    });

})(jQuery);

XhEditor

(function ($) {

    $LAB
        .script(Config.Paths.Editor + "xheditor/xheditor-1.1.13-zh-cn.min.js");

    var tools_mini = 'Source,|,Removeformat,|,Bold,Italic,Underline,|,Fontface,FontSize,|,FontColor,BackColor,|,Blocktag,List,|,Preview,Fullscreen';
    var tools_normal = 'Cut,Copy,Paste,Pastetext,|,Align,Outdent,Indent,|,Link,Unlink,Anchor,|,Hr,Table' + ',/,' +
        'Source,|,Removeformat,|,Bold,Italic,Underline,Strikethrough,|,Fontface,FontSize,|,FontColor,BackColor,|,Blocktag,List,|,Preview,Fullscreen';

    function EditorCreate(el) {

        $LAB
            .script(Config.Paths.Editor + "xheditor/xheditor-1.1.13-zh-cn.min.js")
            .wait(function () {
                var miniMode = el.hasClass('input_editor_mini');
                var tools = miniMode ? tools_mini : tools_normal;
                var editor = el.xheditor({
                    skin: 'nostyle',
                    tools: tools,
                    width: el.width(),
                    height: el.height(),
                    editorRoot: Config.Paths.Editor + 'xheditor/',
                    loadCSS: Config.Editor.ContentsCss
                });
                el.data('editor', editor);

            });
    }

    function EditorDestroy(el) {
        var editor = el.data('editor');
        if (editor) {
            el.xheditor(false);
        }
    }

    function EditorInsertHtml(el, result) {
        var editor = el.data('editor');
        if (editor) {
            editor.toggleSource(false);
            editor.pasteHTML(result);
        }
    }

    function EditorSync(el) {
        return;
    }

    $.extend({
        Editor: {
            Create: EditorCreate,
            Destroy: EditorDestroy,
            Sync: EditorSync,
            InsertHtml: EditorInsertHtml
        }
    });

})(jQuery);

CkEditor