最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

kindeditor修復(fù)會替換script內(nèi)容的問題

 更新時(shí)間:2015年04月03日 10:04:24   投稿:hebedich  
這里給大家分享的是個(gè)人修改的kindeditor的代碼,主要是修復(fù)了一些BUG,添加了些常用功能,推薦給大家,有需要的小伙伴可以參考下。

kindeditor一些個(gè)人修改

1.替換script里面的內(nèi)容的問題
2.顏色選擇器擴(kuò)展,復(fù)制的fck編輯器選顏色
3.swfupload.swf上傳前圖片預(yù)覽功能

kindeditor.js

function _formatHtml(html, htmlTags, urlType, wellFormatted, indentChar) {
    if (html == null) {
      html = '';
    }
    //2015-03-25
    html = html.replace(/textarea__/ig, "textarea");
    urlType = urlType || '';
    wellFormatted = _undef(wellFormatted, false);
    indentChar = _undef(indentChar, '\t');
    var fontSizeList = 'xx-small,x-small,small,medium,large,x-large,xx-large'.split(',');
 
    //2015-04-02將script里面的數(shù)據(jù)讀取處理
    var obj = {};
    var index = 0;
    html = html.replace(/(<script\s[^>]*>)([\s\S]*?)(<\/script>)/ig, function ($0, $1, $2, $3) {
      var value = $2 + '';
      if (value) {
        var key = "{$script__" + index + "$}";
        obj[key] = value;
        index++;
        return $1 + key + $3;
      } else {
        return $0;
      }
    });
    html = html.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig, function ($0, $1, $2, $3) {
      return $1 + $2.replace(/<(?:br|br\s[^>]*)>/ig, '\n') + $3;
    });
    html = html.replace(/<(?:br|br\s[^>]*)\s*\/?>\s*<\/p>/ig, '</p>');
    html = html.replace(/(<(?:p|p\s[^>]*)>)\s*(<\/p>)/ig, '$1<br />$2');
    html = html.replace(/\u200B/g, '');
    html = html.replace(/\u00A9/g, '&copy;');
    html = html.replace(/\u00AE/g, '&reg;');
    html = html.replace(/<[^>]+/g, function ($0) {
      return $0.replace(/\s+/g, ' ');
    });
    var htmlTagMap = {};
    if (htmlTags) {
      _each(htmlTags, function (key, val) {
        var arr = key.split(',');
        for (var i = 0, len = arr.length; i < len; i++) {
          htmlTagMap[arr[i]] = _toMap(val);
        }
      });
      if (!htmlTagMap.script) {
        html = html.replace(/(<(?:script|script\s[^>]*)>)([\s\S]*?)(<\/script>)/ig, '');
      }
      if (!htmlTagMap.style) {
        html = html.replace(/(<(?:style|style\s[^>]*)>)([\s\S]*?)(<\/style>)/ig, '');
      }
    }
    var re = /(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"'<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+='[^']*'))*)(\/)?>(\s*)/g;
    var tagStack = [];
    html = html.replace(re, function ($0, $1, $2, $3, $4, $5, $6) {
      var full = $0,
      startNewline = $1 || '',
      startSlash = $2 || '',
      tagName = $3.toLowerCase(),
      attr = $4 || '',
      endSlash = $5 ? ' ' + $5 : '',
      endNewline = $6 || '';
      if (htmlTags && !htmlTagMap[tagName]) {
        return '';
      }
      if (endSlash === '' && _SINGLE_TAG_MAP[tagName]) {
        endSlash = ' /';
      }
      if (_INLINE_TAG_MAP[tagName]) {
        if (startNewline) {
          startNewline = ' ';
        }
        if (endNewline) {
          endNewline = ' ';
        }
      }
      if (_PRE_TAG_MAP[tagName]) {
        if (startSlash) {
          endNewline = '\n';
        } else {
          startNewline = '\n';
        }
      }
      if (wellFormatted && tagName == 'br') {
        endNewline = '\n';
      }
      if (_BLOCK_TAG_MAP[tagName] && !_PRE_TAG_MAP[tagName]) {
        if (wellFormatted) {
          if (startSlash && tagStack.length > 0 && tagStack[tagStack.length - 1] === tagName) {
            tagStack.pop();
          } else {
            tagStack.push(tagName);
          }
          startNewline = '\n';
          endNewline = '\n';
          for (var i = 0, len = startSlash ? tagStack.length : tagStack.length - 1; i < len; i++) {
            startNewline += indentChar;
            if (!startSlash) {
              endNewline += indentChar;
            }
          }
          if (endSlash) {
            tagStack.pop();
          } else if (!startSlash) {
            endNewline += indentChar;
          }
        } else {
          startNewline = endNewline = '';
        }
      }
      if (attr !== '') {
        var attrMap = _getAttrList(full);
        if (tagName === 'font') {
          var fontStyleMap = {}, fontStyle = '';
          _each(attrMap, function (key, val) {
            if (key === 'color') {
              fontStyleMap.color = val;
              delete attrMap[key];
            }
            if (key === 'size') {
              fontStyleMap['font-size'] = fontSizeList[parseInt(val, 10) - 1] || '';
              delete attrMap[key];
            }
            if (key === 'face') {
              fontStyleMap['font-family'] = val;
              delete attrMap[key];
            }
            if (key === 'style') {
              fontStyle = val;
            }
          });
          if (fontStyle && !/;$/.test(fontStyle)) {
            fontStyle += ';';
          }
          _each(fontStyleMap, function (key, val) {
            if (val === '') {
              return;
            }
            if (/\s/.test(val)) {
              val = "'" + val + "'";
            }
            fontStyle += key + ':' + val + ';';
          });
          attrMap.style = fontStyle;
        }
        _each(attrMap, function (key, val) {
          if (_FILL_ATTR_MAP[key]) {
            attrMap[key] = key;
          }
          if (_inArray(key, ['src', 'href']) >= 0) {
            attrMap[key] = _formatUrl(val, urlType);
          }
          if (htmlTags && key !== 'style' && !htmlTagMap[tagName]['*'] && !htmlTagMap[tagName][key] ||
          tagName === 'body' && key === 'contenteditable' ||
          /^kindeditor_\d+$/.test(key)) {
            delete attrMap[key];
          }
          if (key === 'style' && val !== '') {
            var styleMap = _getCssList(val);
            _each(styleMap, function (k, v) {
              if (htmlTags && !htmlTagMap[tagName].style && !htmlTagMap[tagName]['.' + k]) {
                delete styleMap[k];
              }
            });
            var style = '';
            _each(styleMap, function (k, v) {
              style += k + ':' + v + ';';
            });
            attrMap.style = style;
          }
        });
        attr = '';
        _each(attrMap, function (key, val) {
          if (key === 'style' && val === '') {
            return;
          }
          val = val.replace(/"/g, '&quot;');
          attr += ' ' + key + '="' + val + '"';
        });
      }
      if (tagName === 'font') {
        tagName = 'span';
      }
      return startNewline + '<' + startSlash + tagName + attr + endSlash + '>' + endNewline;
    });
    html = html.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig, function ($0, $1, $2, $3) {
      return $1 + $2.replace(/\n/g, '<span id="__kindeditor_pre_newline__">\n') + $3;
    });
    html = html.replace(/\n\s*\n/g, '\n');
    html = html.replace(/<span id="__kindeditor_pre_newline__">\n/g, '\n');
    for (var key in obj) {
      html = html.replace(key, obj[key]);
    }
    //alert(html);
    return _trim(html);
  }

以上所述就是修改的kindeditor的全部代碼了,希望大家能夠喜歡。

相關(guān)文章

  • JS異步的執(zhí)行順序分析

    JS異步的執(zhí)行順序分析

    這篇文章介紹了JS異步的執(zhí)行順序,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • JavaScript簡單下拉菜單特效

    JavaScript簡單下拉菜單特效

    這篇文章主要為大家詳細(xì)介紹了JavaScript簡單下拉菜單特效,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • js 獲取瀏覽器版本以此來調(diào)整CSS的樣式

    js 獲取瀏覽器版本以此來調(diào)整CSS的樣式

    判斷當(dāng)前使用的是那個(gè)瀏覽器及瀏覽器的那個(gè)版本,根據(jù)瀏覽器版本來調(diào)整CSS的樣式,下面是獲取當(dāng)前瀏覽器的代碼,需要的朋友可以參考下
    2014-06-06
  • 解決layui數(shù)據(jù)表格table的橫向滾動條顯示問題

    解決layui數(shù)據(jù)表格table的橫向滾動條顯示問題

    今天小編就為大家分享一篇解決layui數(shù)據(jù)表格table的橫向滾動條顯示問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-09-09
  • 搞定immutable.js詳細(xì)說明

    搞定immutable.js詳細(xì)說明

    Immutable Data是指一旦被創(chuàng)造后,就不可以被改變的數(shù)據(jù)。通過使用Immutable Data,可以讓我們更容易的去處理緩存、回退、數(shù)據(jù)變化檢測等問題,簡化我們的開發(fā)
    2016-05-05
  • 深入理解移動前端開發(fā)之viewport

    深入理解移動前端開發(fā)之viewport

    這篇文章主要介紹了移動前端開發(fā)之viewport的相關(guān)知識,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-10-10
  • js焦點(diǎn)文字滾動效果代碼分享

    js焦點(diǎn)文字滾動效果代碼分享

    這篇文章主要介紹了js焦點(diǎn)文字滾動效果,功能實(shí)現(xiàn)非常簡單,推薦給大家,有需要的小伙伴可以參考下。
    2015-08-08
  • Echarts圖表如何利用formatter自定義tooltip的內(nèi)容和樣式

    Echarts圖表如何利用formatter自定義tooltip的內(nèi)容和樣式

    這篇文章主要給大家介紹了關(guān)于Echarts圖表如何利用formatter自定義tooltip的內(nèi)容和樣式的相關(guān)資料,echarts的圖表配置非常的靈活自由,但是不熟悉的時(shí)候容易不知道怎么配置,需要的朋友可以參考下
    2023-06-06
  • javascript 異步頁面查詢實(shí)現(xiàn)代碼(asp.net)

    javascript 異步頁面查詢實(shí)現(xiàn)代碼(asp.net)

    異步頁面查詢,其實(shí)與自動完成時(shí)一樣的原理,根據(jù)用戶輸入的關(guān)鍵詞自動的與數(shù)據(jù)庫中的匹配,并顯示出來,提高用戶體驗(yàn),但主要搜索量大的話,增加服務(wù)器開銷。
    2010-05-05
  • indexOf 和 lastIndexOf 使用示例介紹

    indexOf 和 lastIndexOf 使用示例介紹

    indexOf是在一個(gè)字符串中尋找一個(gè)字的位置,lastIndexOf 也是找字 , 它們倆的區(qū)別是前者從字符串頭開始找,后者是從字符串末端開始找
    2014-09-09

最新評論

景洪市| 甘肃省| 耒阳市| 邵武市| 土默特右旗| 华坪县| 潞城市| 司法| 西丰县| 德阳市| 南涧| 霍邱县| 全椒县| 成武县| 平塘县| 扎赉特旗| 东方市| 乐平市| 龙井市| 陕西省| 万宁市| 广宁县| 永顺县| 林周县| 方城县| 邓州市| 子长县| 洛浦县| 安丘市| 泰宁县| 兖州市| 哈巴河县| 仁化县| 内丘县| 昌都县| 行唐县| 伊春市| 灵台县| 胶南市| 中方县| 邹平县|