0

我想在不是 div 标签的每一行中放置一些文本,并通过鼠标单击来聚焦它们。默认情况下,ace 编辑器仅将鼠标光标聚焦在行文本内。我想专注于添加元素的线外。(https://github.com/ajaxorg/ace/issues/1342

我已经在 lib/ace/layer/text.js 中插入了我的代码,如下所示。(只注意 mingji 的评论)

this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {

var lineNumber = row;
if (!foldLine && foldLine != false)
    foldLine = this.session.getFoldLine(row);

if (foldLine)
    var tokens = this.$getFoldLineTokens(row, foldLine);
else
    var tokens = this.session.getTokens(row);


if (!onlyContents) {
    stringBuilder.push(
        "<div class='ace_line' style='height:", this.config.lineHeight, "px'>"
    );
}

if (tokens.length) {
    var splits = this.session.getRowSplitData(row);
    if (splits && splits.length)
        this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
    else
        this.$renderSimpleLine(stringBuilder, tokens);
}

if (this.showInvisibles) {
    if (foldLine)
        row = foldLine.end.row

    stringBuilder.push(
        "<span class='ace_invisible'>",
        row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
        "</span>"
    );
}

****//<<2013.03.30 mingji add this code for comment input
stringBuilder.push(
    "<table id='notegrid",lineNumber,"' border='0' class='ace_notecomment' cellpadding='0' cellspacing='0' style='height:", this.config.lineHeight-4, "px;'> \
    <tr id='R",lineNumber,"'> \
    <td class='ace_notecomment_cn' >//note_cn</td> \
    <td class='ace_notecomment_en' >//note_en</td> \
    </tr> \
    </table>"
);
//>>**

if (!onlyContents)
    stringBuilder.push("</div>");

};

像这样在我的编辑器的每一行中显示的一些表格文本。但我无法将鼠标光标集中在行的表 td 元素上。

4

0 回答 0