WYSIHTML5 编辑器在 Chrome 中插入无序列表时不聚焦可编辑区域

WYSIHTML5 editor does not focus the editable area while inserting unordered list in Chrome

在WYSIHTML5编辑器中,当我们添加无序列表时,在Google Chrome浏览器中不会聚焦到可编辑区域。但是,对于其他选项(如粗体、斜体等),它工作正常。我已经搜索过,但一直无法找到解决此错误的方法。

在 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; 永远不会变为真,因为我们插入了无序列表并且之后可编辑区域不是空白。祝你好运..!!