|
|
@@ -17,7 +17,28 @@ class GridEditorUtil {
|
|
|
getBog(editor) {
|
|
|
const curPos = editor.getCursor();
|
|
|
const firstLine = editor.getDoc().firstLine();
|
|
|
- return { line: firstLine, ch: curPos.ch };
|
|
|
+
|
|
|
+ let line = curPos.line - 1;
|
|
|
+ let isFound = false;
|
|
|
+ for (; line >= firstLine; line--) {
|
|
|
+ const strLine = editor.getDoc().getLine(line);
|
|
|
+ if (this.linePartOfGridRE.test(strLine)) {
|
|
|
+ isFound = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.linePartOfGridRE.test(strLine)) {
|
|
|
+ isFound = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isFound) {
|
|
|
+ return { line: curPos.line, ch: curPos.ch };
|
|
|
+ }
|
|
|
+
|
|
|
+ const bodLine = Math.max(firstLine, line);
|
|
|
+ return { line: bodLine, ch: 0 };
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -26,11 +47,38 @@ class GridEditorUtil {
|
|
|
getEog(editor) {
|
|
|
const curPos = editor.getCursor();
|
|
|
const lastLine = editor.getDoc().lastLine();
|
|
|
- return { line: lastLine, ch: curPos.ch };
|
|
|
+
|
|
|
+ let line = curPos.line + 1;
|
|
|
+ let isFound = false;
|
|
|
+ for (; line <= lastLine; line++) {
|
|
|
+ const strLine = editor.getDoc().getLine(line);
|
|
|
+ if (this.linePartOfGridRE.test(strLine)) {
|
|
|
+ isFound = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.lineBeginPartOfDrawioRE.test(strLine)) {
|
|
|
+ isFound = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isFound) {
|
|
|
+ return { line: curPos.line, ch: curPos.ch };
|
|
|
+ }
|
|
|
+
|
|
|
+ const eodLine = Math.min(line, lastLine);
|
|
|
+ const lineLength = editor.getDoc().getLine(eodLine).length;
|
|
|
+ return { line: eodLine, ch: lineLength };
|
|
|
+ // return { line: lastLine, ch: curPos.ch };
|
|
|
}
|
|
|
|
|
|
replaceGridWithHtmlWithEditor(editor, grid) {
|
|
|
const curPos = editor.getCursor();
|
|
|
+ console.log('getBog');
|
|
|
+ console.log(this.getBog(editor));
|
|
|
+ console.log('getEog');
|
|
|
+ console.log(this.getEog(editor));
|
|
|
editor.getDoc().replaceRange(grid.toString(), this.getBog(editor), this.getEog(editor));
|
|
|
editor.getDoc().setCursor(curPos.line + 1, 2);
|
|
|
}
|