1

我正在编辑Slightly Modded Options Framework。我正在将脚本排入functions.interface.php. 这是功能

function of_load_only() {
    // add_action('admin_head', 'smof_admin_head');
    wp_enqueue_script("jquery-ui-core");
    wp_enqueue_script("jquery-ui-sortable");
    wp_enqueue_script("jquery-ui-slider");
    wp_enqueue_script("jquery-input-mask", ADMIN_DIR ."assets/js/jquery.maskedinput-1.2.2.js", array("jquery"), false, true);
    wp_enqueue_script("tipsy", ADMIN_DIR ."assets/js/jquery.tipsy.js", array("jquery"), false, true);

    // enqueue codemirror
    wp_enqueue_script("codemirror", ADMIN_DIR . "assets/js/codemirror/codemirror.min.js", array(), "3.15", true);

    // wp_enqueue_script('color-picker', ADMIN_DIR .'assets/js/colorpicker.js', array('jquery'));
    wp_enqueue_script("cookie", ADMIN_DIR . "assets/js/cookie.js", array("jquery"), false, true);
    wp_enqueue_script("smof", ADMIN_DIR ."assets/js/smof.js", array("jquery"), false, true);
    // Enqueue colorpicker scripts for versions below 3.5 for compatibility
    if(!wp_script_is("wp-color-picker", "registered")) {
        wp_register_script("iris", ADMIN_DIR ."assets/js/iris.min.js", array("jquery-ui-draggable", "jquery-ui-slider", "jquery-touch-punch"), false, 1);
        wp_register_script("wp-color-picker", ADMIN_DIR ."assets/js/color-picker.min.js", array("jquery", "iris"));
    }
    wp_enqueue_script("wp-color-picker");

    // Enqueue scripts for file uploader
    if(function_exists("wp_enqueue_media")) {
        wp_enqueue_media();
    }
    do_action("of_load_only_after");
}

这是相关源代码的链接

问题

到目前为止,CodeMirror 处理起来比 Ace 简单得多。我遇到的问题是 CodeMirror 最初是隐藏的,直到我在编辑器本身中按下一个键。我在这里阅读了“解决方案”:

我试过的

这是代码

$("#custom_css").val("/* Write code here */");
var codemirror_editor = CodeMirror.fromTextArea(document.getElementById("custom_css"), {
    lineNumbers: true,
    matchBrackets: true,
    styleActiveLine: true,
    lineWrapping: true,
    autoCloseBrackets: true,
    showTrailingSpace: true,
    indentUnit: 4,
    indentWithTabs: true,
    viewportMargin: Infinity,
    autofocus: true
});
// codemirror_editor.refresh(); // does not work even on the CodeMirror instance
// setTimeout(codemirror_editor.refresh, 0) // does not work per the CodeMirror has content but won't display until keypress solution

这是在编辑器中按键之前和按键之后显示的两张图像。

按键前 按键后

4

1 回答 1

0

这是第 422 行中的 CSS 问题admin-style.css。将其注释掉,它解决了我的问题!

于 2013-08-22T18:00:01.517 回答