Web5/Admin/ueditor/third-party/codemirror/codemirror.js

(开头部分) 158KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

// CodeMirror version 2.2
//
// All functions that need access to the editor's state live inside
// the CodeMirror function. Below that, at the bottom of the file,
// some utilities are defined.

// CodeMirror is the only global var we claim
var CodeMirror = (function() {
    // This is the function that produces an editor instance. It's
    // closure is used to store the editor state.
    function CodeMirror(place, givenOptions) {
        // Determine effective options based on given values and defaults.
        var options = {}, defaults = CodeMirror.defaults;
        for (var opt in defaults)
            if (defaults.hasOwnProperty(opt))
                options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];

        var targetDocument = options["document"];
        // The element in which the editor lives.
        var wrapper = targetDocument.createElement("div");
        wrapper.className = "CodeMirror" + (options.lineWrapping ? " CodeMirror-wrap" : "");
        // This mess creates the base DOM structure for the editor.
        wrapper.innerHTML =
            '<div style="overflow: hidden; position: relative; width: 3px; height: 0px;">' + // Wraps and hides input textarea
                '<textarea style="position: absolute; padding: 0; width: 1px;" wrap="off" ' +
                'autocorrect="off" autocapitalize="off"></textarea></div>' +
                '<div class="CodeMirror-scroll" tabindex="-1">' +
                '<div style="position: relative">' + // Set to the height of the text, causes scrolling
                '<div style="position: relative">' + // Moved around its parent to cover visible view
                '<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>' +
                // Provides positioning relative to (visible) text origin
                '<div class="CodeMirror-lines"><div style="position: relative">' +
                '<div style="position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden"></div>' +
                '<pre class="CodeMirror-cursor">&#160;</pre>' + // Absolutely positioned blinky cursor
                '<div></div>' + // This DIV contains the actual code
                '</div></div></div></div></div>';
        if (place.appendChild) place.appendChild(wrapper); else place(wrapper);
        // I've never seen more elegant code in my life.
        var inputDiv = wrapper.firstChild, input = inputDiv.firstChild,
            scroller = wrapper.lastChild, code = scroller.firstChild,
            mover = code.firstChild, gutter = mover.firstChild, gutterText = gutter.firstChild,
            lineSpace = gutter.nextSibling.firstChild, measure = lineSpace.firstChild,
            cursor = measure.nextSibling, lineDiv = cursor.nextSibling;
        themeChanged();
        // Needed to hide big blue blinking cursor on Mobile Safari
        if (/AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent)) input.style.width = "0px";
        if (!webkit) lineSpace.draggable = true;
        if (options.tabindex != null) input.tabIndex = options.tabindex;
        if (!options.gutter && !options.lineNumbers) gutter.style.display = "none";

        // Check for problem with IE innerHTML not working when we have a
        // P (or similar) parent node.
        try { stringWidth("x"); }
        catch (e) {
            if (e.message.match(/runtime/i))
                e = new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)");
            throw e;
        }

        // Delayed object wrap timeouts, making sure only one is active. blinker holds an interval.
后面还有 3521 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。