|
|
@@ -4,10 +4,9 @@
|
|
|
class GridEditorUtil {
|
|
|
|
|
|
constructor() {
|
|
|
- // TODO url
|
|
|
- this.lineBeginPartOfGridRE = /(<[^/].*>)/;
|
|
|
- this.lineEndPartOfGridRE = /(<\/.*>)/;
|
|
|
- this.linePartOfGridRE = /(<[^/].*>)[\s\S]*<\/.*>$/;
|
|
|
+ // https://regex101.com/r/7BN2fR/11
|
|
|
+ this.lineBeginPartOfGridRE = /^:::(\s.*)editable-row$/;
|
|
|
+ this.lineEndPartOfGridRE = /^:::$/;
|
|
|
this.replaceGridWithHtmlWithEditor = this.replaceGridWithHtmlWithEditor.bind(this);
|
|
|
}
|
|
|
|
|
|
@@ -18,6 +17,10 @@ class GridEditorUtil {
|
|
|
const curPos = editor.getCursor();
|
|
|
const firstLine = editor.getDoc().firstLine();
|
|
|
|
|
|
+ if (this.lineBeginPartOfGridRE.test(editor.getDoc().getLine(curPos.line))) {
|
|
|
+ return { line: curPos.line, ch: 0 };
|
|
|
+ }
|
|
|
+
|
|
|
let line = curPos.line - 1;
|
|
|
let isFound = false;
|
|
|
for (; line >= firstLine; line--) {
|
|
|
@@ -27,7 +30,7 @@ class GridEditorUtil {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (this.lineBeginPartOfGridRE.test(strLine)) {
|
|
|
+ if (this.lineEndPartOfGridRE.test(strLine)) {
|
|
|
isFound = false;
|
|
|
break;
|
|
|
}
|
|
|
@@ -48,7 +51,11 @@ class GridEditorUtil {
|
|
|
const curPos = editor.getCursor();
|
|
|
const lastLine = editor.getDoc().lastLine();
|
|
|
|
|
|
- let line = curPos.line;
|
|
|
+ if (this.lineEndPartOfGridRE.test(editor.getDoc().getLine(curPos.line))) {
|
|
|
+ return { line: curPos.line, ch: editor.getDoc().getLine(curPos.line).length };
|
|
|
+ }
|
|
|
+
|
|
|
+ let line = curPos.line + 1;
|
|
|
let isFound = false;
|
|
|
for (; line <= lastLine; line++) {
|
|
|
const strLine = editor.getDoc().getLine(line);
|
|
|
@@ -57,7 +64,7 @@ class GridEditorUtil {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (this.lineEndPartOfGridRE.test(strLine)) {
|
|
|
+ if (this.lineBeginPartOfGridRE.test(strLine)) {
|
|
|
isFound = false;
|
|
|
break;
|
|
|
}
|
|
|
@@ -70,15 +77,10 @@ class GridEditorUtil {
|
|
|
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);
|
|
|
}
|