|
@@ -176,6 +176,15 @@ export default class CodeMirrorEditor extends AbstractEditor {
|
|
|
return editor.getDoc().getRange(curPos, this.getEol());
|
|
return editor.getDoc().getRange(curPos, this.getEol());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritDoc
|
|
|
|
|
+ */
|
|
|
|
|
+ getStrFromBolToSelectedUpperPos() {
|
|
|
|
|
+ const editor = this.getCodeMirror();
|
|
|
|
|
+ const pos = this.selectUpperPos(editor.getCursor('from'), editor.getCursor('to'));
|
|
|
|
|
+ return editor.getDoc().getRange(this.getBol(), pos);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @inheritDoc
|
|
* @inheritDoc
|
|
|
*/
|
|
*/
|
|
@@ -211,6 +220,32 @@ export default class CodeMirrorEditor extends AbstractEditor {
|
|
|
return { line: curPos.line, ch: lineLength };
|
|
return { line: curPos.line, ch: lineLength };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * select the upper position of pos1 and pos2
|
|
|
|
|
+ * @param {{line: number, ch: number}} pos1
|
|
|
|
|
+ * @param {{line: number, ch: number}} pos2
|
|
|
|
|
+ */
|
|
|
|
|
+ selectUpperPos(pos1, pos2) {
|
|
|
|
|
+ // if both is in same line
|
|
|
|
|
+ if (pos1.line === pos2.line) {
|
|
|
|
|
+ return (pos1.ch < pos2.ch) ? pos1 : pos2;
|
|
|
|
|
+ }
|
|
|
|
|
+ return (pos1.line < pos2.line) ? pos1 : pos2;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * select the lower position of pos1 and pos2
|
|
|
|
|
+ * @param {{line: number, ch: number}} pos1
|
|
|
|
|
+ * @param {{line: number, ch: number}} pos2
|
|
|
|
|
+ */
|
|
|
|
|
+ selectLowerPos(pos1, pos2) {
|
|
|
|
|
+ // if both is in same line
|
|
|
|
|
+ if (pos1.line === pos2.line) {
|
|
|
|
|
+ return (pos1.ch < pos2.ch) ? pos2 : pos1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return (pos1.line < pos2.line) ? pos2 : pos1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
loadCss(source) {
|
|
loadCss(source) {
|
|
|
return new Promise((resolve) => {
|
|
return new Promise((resolve) => {
|
|
|
loadCssSync(source);
|
|
loadCssSync(source);
|