简体   繁体   中英

Add custom button to CKEditor

Hello I am trying to learn CKEditor. Want to add custom button. I am following this tutorial

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

It's a very simple tutorial but I am stuck at the end can't see my button.

This is my Web Form

<%@ 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>

And this is my plugin.js file

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'
    });
}
});

I am using Microsoft Visual Studio 2012, CKEditor 3.6.4 for ASP.net, tried CKEditor version 3.6.6.1 and 4.4.1 nothing changed. Also checked the questions here but none of them helped. Also add the extralugin to the config.js

config.extraPlugins = 'timestamp';

The code is correct, It was a visual studio error. Cleaned the solution and then rebuild the project. It is now works perfect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM