1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| getSelectedText(editor: any) { if (editor.somethingSelected()) { let cursorStart = editor.getCursor(true); let cursorEnd = editor.getCursor(false); let content = editor.getRange( { line: cursorStart.line, ch: 0 }, { line: cursorEnd.line, ch: editor.getLine(cursorEnd.line).length } ); return { start: { line: cursorStart.line, ch: 0 }, end: { line: cursorEnd.line, ch: editor.getLine(cursorEnd.line).length, }, content: content, }; } else { var lineNr = editor.getCursor().line; var contents = editor.getDoc().getLine(lineNr); let cursorStart = { line: lineNr, ch: 0, }; let cursorEnd = { line: lineNr, ch: contents.length, }; let content = editor.getRange(cursorStart, cursorEnd); return { start: cursorStart, end: cursorEnd, content: content }; } }
|