var cmd = function () { this.Name = "FormatLine"; }
cmd.prototype.Execute = function () {
    if (FCK.EditMode == FCK_EDITMODE_WYSIWYG) {
        var s = FCK.GetXHTML();
        s = s.replace(/<\/?([a-zA-Z0-9]+).*?>/g, function ($0, $1) {
            if ($1.match(/br|p/i) != null) return "\n";
            return $0;
        }).replace(/^\n+|\n+$/g, "").replace(/\n+/g, "\n");
        FCK.SetHTML(s.replace(/(^|\n)([^\n]+)($|\n)/g, "<p>$2</p>"));
    }
    else
        alert("You must be on WYSIWYG mode!");
};
cmd.prototype.GetState = function () { return FCK_TRISTATE_OFF; };
FCKCommands.RegisterCommand("FormatLine", new cmd());

var item = new FCKToolbarButton("FormatLine", "格式化行");
item.IconPath = FCKPlugins.Items["FormatLine"].Path + "formatline.gif";
FCKToolbarItems.RegisterItem("FormatLine", item);