ueditor編輯器顯示style標簽樣式


在使用ueditor編輯器中,想保存style標簽的樣式需要對js配置文件進行修改。官方為了安全考慮,默認會將style標簽轉為DIV標簽,導致樣式不能顯示出對應的效果。

基於1.4.3版本修改如下

1.找到ueditor.config.js文件

// 將下面3個參數值改為false

// xss 過濾是否開啟,inserthtml等操作
,xssFilterRules: false

//input xss過濾
,inputXssFilter: false

//output xss過濾
,outputXssFilter: false

2.確定頁面引入的是 ueditor.all.min.js  還是 ueditor.all.js ,並修改:

// 找到allowDivTransToP參數,這個參數會將DIV標簽轉為P標簽,設置為false
me.setOpt(
  {
    
'allowDivTransToP':false,
    'disabledTableInTable':true
  }
);
// 找到addInputRule方法,並將switch case 中的case style:刪除
me.addInputRule(function (root) {
        ...
        //進行默認的處理
        root.traversal(function (node) {
            if (node.type == 'element') {
               ...
                switch (node.tagName) {
                    case 'style': // 刪除這項
                    case 'script':
                    ....
                }
            }
        }
    })

3. 刷新文件,重新設置即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM