nl_tokens: 配置和初始化工具栏 Set toolbar and Initialization
pl_tokens: function ( ) { var settings = this . settings ; if ( settings . readOnly ) { return this ; } var editor = this . editor ; var preview = this . preview ; var classPrefix = this . classPrefix ; var toolbar = this . toolbar = editor . children ( "." + classPrefix + "toolbar" ) ; if ( settings . toolbar && toolbar . length < 1 ) { var toolbarHTML = "<div class=\"" + classPrefix + "toolbar\"><div class=\"" + classPrefix + "toolbar-container\"><ul class=\"" + classPrefix + "menu\"></ul></div></div>" ; editor . append ( toolbarHTML ) ; toolbar = this . toolbar = editor . children ( "." + classPrefix + "toolbar" ) ; } if ( ! settings . toolbar ) { toolbar . hide ( ) ; return this ; } toolbar . show ( ) ; var icons = ( typeof settings . toolbarIcons === "function" ) ? settings . toolbarIcons ( ) : ( ( typeof settings . toolbarIcons === "string" ) ? editormd . toolbarModes [ settings . toolbarIcons ] : settings . toolbarIcons ) ; var toolbarMenu = toolbar . find ( "." + this . classPrefix + "menu" ) , menu = "" ; var pullRight = false ; for ( var i = 0 , len = icons . length ; i < len ; i ++ ) { var <mask> = icons [ i ] ; if ( name === "||" ) { pullRight = true ; } else if ( name === "|" ) { menu += "<li class=\"divider\" unselectable=\"on\">|</li>" ; } else { var isHeader = ( / h(\d) / . test ( name ) ) ; var index = name ; if ( name === "watch" && ! settings . watch ) { index = "unwatch" ; } var title = settings . lang . toolbar [ index ] ; var iconTexts = settings . toolbarIconTexts [ index ] ; var iconClass = settings . toolbarIconsClass [ index ] ; title = ( typeof title === "undefined" ) ? "" : title ; iconTexts = ( typeof iconTexts === "undefined" ) ? "" : iconTexts ; iconClass = ( typeof iconClass === "undefined" ) ? "" : iconClass ; var menuItem = pullRight ? "<li class=\"pull-right\">" : "<li>" ; if ( typeof settings . toolbarCustomIcons [ name ] !== "undefined" && typeof settings . toolbarCustomIcons [ name ] !== "function" ) { menuItem += settings . toolbarCustomIcons [ name ] ; } else { menuItem += "<a href=\"javascript:;\" title=\"" + title + "\" unselectable=\"on\">" ; menuItem += "<i class=\"fa " + iconClass + "\" name=\"" + name + "\" unselectable=\"on\">" + ( ( isHeader ) ? name . toUpperCase ( ) : ( ( iconClass === "" ) ? iconTexts : "" ) ) + "</i>" ; menuItem += "</a>" ; } menuItem += "</li>" ; menu = pullRight ? menuItem + menu : menu + menuItem ; } } toolbarMenu . html ( menu ) ; toolbarMenu . find ( "[title=\"Lowercase\"]" ) . attr ( "title" , settings . lang . toolbar . lowercase ) ; toolbarMenu . find ( "[title=\"ucwords\"]" ) . attr ( "title" , settings . lang . toolbar . ucwords ) ; this . setToolbarHandler ( ) ; this . setToolbarAutoFixed ( ) ; return this ; }