⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 un-format.js

📁 Hippo CMS是一个以信息为中心的开源内容管理系统。Hippo CMS目标是供中,大型企业来管理其发布在互连网
💻 JS
字号:
// Unormat plugin for HTMLArea


function UnFormat(editor) {
  this.editor = editor;
  var cfg = editor.config;
  var self = this;

  cfg.registerButton({
    id       : "unformat",
    tooltip  : this._lc("Page Cleaner"),
    image    : editor.imgURL("unformat.gif", "UnFormat"),
    textMode : false,
    action   : function(editor) {
                 self.buttonPress(editor);
               }
  });

  cfg.addToolbarElement("unformat", "killword", 1);
}

UnFormat._pluginInfo = {
  name          : "UnFormat",
  version       : "1.0",
  license       : "htmlArea"
};


UnFormat.prototype._lc = function(string) {
  return HTMLArea._lc(string, 'UnFormat');
};

UnFormat.prototype.buttonPress = function(editor){
  editor._popupDialog( "plugin://UnFormat/unformat", function( param){
    if (param) {
      if (param["cleaning_area"] == "all") {
        var html = editor._doc.body.innerHTML;
      } else {
        var html = editor.getSelectedHTML();
      }

      if (param["html_all"]== true) {
        html = html.replace(/<[\!]*?[^<>]*?>/g, ""); 				
      }

      if (param["formatting"] == true) {
        html = html.replace(/style="[^"]*"/gi, "");
        html = html.replace(/<\/?font[^>]*>/gi,"");
        html = html.replace(/<\/?b>/gi,"");
        html = html.replace(/<\/?strong[^>]*>/gi,"");
        html = html.replace(/<\/?i>/gi,"");
        html = html.replace(/<\/?em[^>]*>/gi,"");
        html = html.replace(/<\/?u[^>]*>/gi,"");
        html = html.replace(/<\/?strike[^>]*>/gi,"");
        html = html.replace(/ align=[^\s|>]*/gi,"");
        html = html.replace(/ class=[^\s|>]*/gi,"");
      }
      if (param["cleaning_area"] == "all") {
        editor._doc.body.innerHTML = html;
      } else	{
        editor.insertHTML(html);
      }
    } else { return false; }
  }, null);
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -