将自定义按钮添加到CKEditor

时间:2014-06-02 12:24:54

标签: javascript asp.net ckeditor

您好我正在尝试学习CKEditor。想要添加自定义按钮。我正在学习本教程

http://docs.cksource.com/CKEditor_3.x/Tutorials/Timestamp_Plugin

这是一个非常简单的教程,但我最后卡住了看不到我的按钮。

这是我的网络表单

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb"   Inherits="WebApplication1.WebForm1" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <CKEditor:CKEditorControl ID="CKEditor1" BasePath="/ckeditor/" ExtraPlugins="timestamp" runat="server">
        </CKEditor:CKEditorControl>
    </div>
    </form>
</body>
</html>

这是我的plugin.js文件

CKEDITOR.plugins.add('timestamp',
{
init: function (editor) {
    editor.addCommand('insertTimestamp',
        {
            exec: function (editor) {
                var timestamp = new Date();
                editor.insertHtml('The current date and time is: <em>' + timestamp.toString() + '</em>');
            }
        });
    editor.ui.addButton('Timestamp',
    {
        label: 'Insert Timestamp',
        command: 'insertTimestamp',
        icon: this.path + 'images/timestamp.png'
    });
}
});

我正在使用Microsoft Visual Studio 2012,CKEditor 3.6.4 for ASP.net,尝试过CKEditor版本3.6.6.1和4.4.1没有任何改变。还检查了这里的问题,但没有一个帮助。还要将extralugin添加到config.js

config.extraPlugins = 'timestamp';

1 个答案:

答案 0 :(得分:0)

代码是正确的,这是一个视觉工作室错误。清理解决方案,然后重建项目。它现在完美无缺。