function (e) {
        // 点击菜单将触发这里
        
        const editor = this.editor
        const isSeleEmpty = editor.selection.isSelectionEmpty()

        if (isSeleEmpty) {
            // 选区是空的，插入并选中一个“空白”
            editor.selection.createEmptyRange()
        }

        // 执行 italic 命令
        editor.cmd.do('italic')

        if (isSeleEmpty) {
            // 需要将选取折叠起来
            editor.selection.collapseRange()
            editor.selection.restoreSelection()
        }
    }
function (e) {
        // 点击菜单将触发这里
        
        const editor = this.editor
        const isSeleEmpty = editor.selection.isSelectionEmpty()

        if (isSeleEmpty) {
            // 选区是空的，插入并选中一个“空白”
            editor.selection.createEmptyRange()
        }

        // 执行 italic 命令
        editor.cmd.do('italic')

        if (isSeleEmpty) {
            // 需要将选取折叠起来
            editor.selection.collapseRange()
            editor.selection.restoreSelection()
        }
    }
function ( e ) { // 点击菜单将触发这里 const editor = this . editor const isSeleEmpty = editor . selection . isSelectionEmpty ( ) if ( isSeleEmpty ) { // 选区是空的，插入并选中一个“空白” editor . selection . createEmptyRange ( ) } // 执行 italic 命令 editor . cmd . do ( 'italic' ) if ( isSeleEmpty ) { // 需要将选取折叠起来 editor . selection . collapseRange ( ) editor . selection . restoreSelection ( ) } }
点击事件
点击事件
on keydown