Ace Editor get current selected line number and text

前端 未结 2 1949
死守一世寂寞
死守一世寂寞 2021-02-10 09:37

I\'m currently using Ace Editor, but I couldn\'t find anything in the docs along the lines of retrieving the current selected line number and its text.

Any ideas?

2条回答
  •  轮回少年
    2021-02-10 10:26

    You can do this:

    selectionRange = editor.getSelectionRange();
    
    startLine = selectionRange.start.row;
    endLine = selectionRange.end.row;
    
    content = editor.session.getTextRange(selectionRange);
    

提交回复
热议问题