2015-01-16 22 views

回答

0

在WYSIHTML5 JS,搜索線wysihtml5.commands.insertUnorderedList,並進一步查找

composer.commands.exec("formatBlock", "div", tempClassName); 
    tempElement = doc.querySelector("." + tempClassName); 
    isEmpty = tempElement.innerHTML === "" || tempElement.innerHTML === wysihtml5.INVISIBLE_SPACE; 
    composer.selection.executeAndRestoreSimple(function() { 
     list = wysihtml5.dom.convertToList(tempElement, "ul"); 
    }); 
    if (isEmpty) { 
     composer.selection.selectNode(list.querySelector("li")); 
    } 

和評論或刪除的條件部分,如:

composer.commands.exec("formatBlock", "div", tempClassName); 
     tempElement = doc.querySelector("." + tempClassName); 
     isEmpty = tempElement.innerHTML === "" || tempElement.innerHTML === wysihtml5.INVISIBLE_SPACE; 
     composer.selection.executeAndRestoreSimple(function() { 
      list = wysihtml5.dom.convertToList(tempElement, "ul"); 
     }); 
     //if (isEmpty) { 
      composer.selection.selectNode(list.querySelector("li")); 
     //} 

它的工作對我,因爲條件isEmpty = tempElement.innerHTML === "" || tempElement.innerHTML === wysihtml5.INVISIBLE_SPACE;永遠無法成爲真正的因爲我們已經插入了無序列表並且可編輯區域在此之後不是空白的。祝你好運..!!