(function (utils, eventHandle) {

    /**
     * 输入事件
     */
    utils.MyRoot.addEventListener('input', styleCmd.inputHandle);
    utils.MyRoot.addEventListener('compositionstart', styleCmd.compositionstartHandle);
    utils.MyRoot.addEventListener('compositionend', styleCmd.compositionendHandle);


    //窗口撤销事件
    window.addEventListener('keydown', styleCmd.windowsCtrZHandle, true);
    // window.onkeydown = styleCmd.windowsCtrZHandle

    //样式事件
    document.getElementById("myPlusB").addEventListener('click', styleCmd.surroundContentsByStyle);
    document.getElementById("myPlusI").addEventListener('click', styleCmd.surroundContentsByStyle);
    document.getElementById("myPlusU").addEventListener('click', styleCmd.surroundContentsByStyle);
    document.getElementById("myPlusDel").addEventListener('click', styleCmd.surroundContentsByStyle);
    document.getElementById("myPlusC").addEventListener('click', styleCmd.surroundContentsByStyle);

    //窗口初始化完成事件
    window.onload = function () {//do something
        // yanxuelu.style.outline = 'none'
        // yanxuelu.onkeydown = fn  // 注册keydown事件处理函数,键盘按下
        // key.onkeyup = fn  // 注册keyup事件处理函数,键盘松开
        // key.onkeypress = fn  // 注册keypress事件处理函数,不推荐使用

        var newParagraph = document.createElement("p")
        newParagraph.setAttribute("contenteditable", "true")
        let uuid = utils.uuid()
        let curOrder = ++utils.num
        newParagraph.setAttribute("data-id", uuid)
        newParagraph.setAttribute("id", uuid)
        newParagraph.setAttribute("data-order", curOrder)
        newParagraph.onkeydown = styleCmd.onkeydownHandle
        newParagraph.focus()
        newParagraph.innerHTML = "<br>"
        utils.MyRoot.appendChild(newParagraph)

        // MyDocMap[curOrder] = new Map()

        utils.MyDocMap.set(curOrder, new utils.MyNode(uuid))


        //收起选区到一个点,光标落在一个可编辑元素上
        window.getSelection().setPosition(newParagraph, 0);
    }

})(utils, styleCmd)