CKeditor - 编辑器窗口内的自定义标签和符号

发布于 2024-09-24 06:38:58 字数 1951 浏览 1 评论 0原文

当您将 Flash 对象插入 CKeditor 时,编辑器窗口将显示以下符号:

alt text

我想知道。当用户将此标签插入编辑器时是否可以执行类似的操作(使用正则表达式 {formbuilder=(\d+)}/ ):

{formbuilder=2}

如果是这样,有人可以解释一下如何做吗? :)

更新:

我一直在研究 PageBreak 插件,试图了解到底发生了什么。这个插件和我的插件最大的区别在于 HTML 插入编辑器的方式。

CKEDITOR.plugins.add('formbuilder',
{
    init: function(editor)
    {
        var pluginName = 'formbuilder';
        var windowObjectReference = null;

        editor.ui.addButton('Formbuilder',
            {

                label : editor.lang.common.form,
                command: pluginName,
                icon: 'http://' + top.location.host + '/publish/ckeditor/images/formbuilder.png',
                click: function (editor)
                    {     
                        if (windowObjectReference == null || windowObjectReference.closed){
                            var siteid = $('#siteid').val();

                            windowObjectReference = window.open('/publish/formbuilder/index.php?siteid='+siteid,'Formbuilder','scrollbars=0,width=974,height=650');
                        } else {
                            windowObjectReference.focus();
                        }
                    }
            });
    }
});

正如您所看到的,我的插件打开一个新窗口,并且插入标签:

function InsertForm(form_id)
        {
            // Get the editor instance that we want to interact with.
            var oEditor = CKEDITOR.instances.page_content;

            // Check the active editing mode.
            if ( oEditor.mode == 'wysiwyg' )
            {
                // Insert the desired HTML.
                oEditor.insertHtml( '{formbuilder='+form_id+'}' );
            }
            else
                alert( 'You must be on WYSIWYG mode!' );
        }

当您单击工具栏图标时,PageBreak 插件会执行所有操作。这使得在插件文件中制作 fakeImage 成为可能。另一方面,对我来说,我不明白这是怎么可能的:\

When you insert a flash object into the CKeditor the editor window will show this symbol:

alt text

I was wondering. Is it possible to do something similar when users inserts this tag into the editor (using regex {formbuilder=(\d+)}/ ):

{formbuilder=2}

If so, could someone please explain how to? :)

UPDATE:

I've been looking at the PageBreak plugin to try and understand what the hell is going on. The big difference between this plugin and mine is the way the HTML is inserted into the editor.

CKEDITOR.plugins.add('formbuilder',
{
    init: function(editor)
    {
        var pluginName = 'formbuilder';
        var windowObjectReference = null;

        editor.ui.addButton('Formbuilder',
            {

                label : editor.lang.common.form,
                command: pluginName,
                icon: 'http://' + top.location.host + '/publish/ckeditor/images/formbuilder.png',
                click: function (editor)
                    {     
                        if (windowObjectReference == null || windowObjectReference.closed){
                            var siteid = $('#siteid').val();

                            windowObjectReference = window.open('/publish/formbuilder/index.php?siteid='+siteid,'Formbuilder','scrollbars=0,width=974,height=650');
                        } else {
                            windowObjectReference.focus();
                        }
                    }
            });
    }
});

As you can see, my plugin opens a new window and the tag is inserted with:

function InsertForm(form_id)
        {
            // Get the editor instance that we want to interact with.
            var oEditor = CKEDITOR.instances.page_content;

            // Check the active editing mode.
            if ( oEditor.mode == 'wysiwyg' )
            {
                // Insert the desired HTML.
                oEditor.insertHtml( '{formbuilder='+form_id+'}' );
            }
            else
                alert( 'You must be on WYSIWYG mode!' );
        }

The PageBreak plugin does everything when you click on the toolbar icon. This makes it possible to make the fakeImage inside the plugin file. For me on ther other hand, I don't see how this is possible :\

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

铜锣湾横着走 2024-10-01 06:38:58

我正在寻求解决类似的问题,只不过我的所有内容看起来都像 XML。就像,。在您的情况下,您将能够复制占位符插件并更改占位符正则表达式以匹配您的标签。就我而言,看起来我将修改 iframe 插件或其他东西,并希望弄清楚如何将每个标签添加为自动关闭......

I'm looking to solve a similar issue, except that all my stuff looks like XML. So like, <cms:include page="whatever" />. In your case, you would be able to copy the placeholder plugin and change the placeholder regex to match your tags. In my case, looks like I'll be modifying the iframe plugin or something, and hopefully figuring out how to add each of my tags as self-closing...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文