|
|
@@ -7,19 +7,38 @@ class GridEditorUtil {
|
|
|
// https://regex101.com/r/7BN2fR/11
|
|
|
this.lineBeginPartOfGridRE = /^:::(\s.*)editable-row$/;
|
|
|
this.lineEndPartOfGridRE = /^:::$/;
|
|
|
- this.isInRow = this.isInRow.bind(this);
|
|
|
+ this.isInGridBlock = this.isInGridBlock.bind(this);
|
|
|
this.replaceGridWithHtmlWithEditor = this.replaceGridWithHtmlWithEditor.bind(this);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * return boolean value whether the cursor position is in a row
|
|
|
+ * return boolean value whether the cursor position is in a grid block
|
|
|
*/
|
|
|
- isInRow(editor) {
|
|
|
+ isInGridBlock(editor) {
|
|
|
const bog = this.getBog(editor);
|
|
|
const eog = this.getEog(editor);
|
|
|
return (JSON.stringify(bog) !== JSON.stringify(eog));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * return grid html where the cursor is
|
|
|
+ */
|
|
|
+ getGridHtml(editor) {
|
|
|
+ const curPos = editor.getCursor();
|
|
|
+
|
|
|
+ if (this.isInGridBlock(editor)) {
|
|
|
+ const bog = this.getBog(editor);
|
|
|
+ const eog = this.getEog(editor);
|
|
|
+ // skip block begin sesion("::: editable-row")
|
|
|
+ bog.line++;
|
|
|
+ // skip block end sesion(":::")
|
|
|
+ eog.line--;
|
|
|
+ eog.ch = editor.getDoc().getLine(eog.line).length;
|
|
|
+ return editor.getDoc().getRange(bog, eog);
|
|
|
+ }
|
|
|
+ return editor.getDoc().getLine(curPos.line);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* return the postion of the BOD(beginning of grid)
|
|
|
*/
|
|
|
@@ -93,7 +112,6 @@ class GridEditorUtil {
|
|
|
const curPos = editor.getCursor();
|
|
|
editor.getDoc().replaceRange(grid.toString(), this.getBog(editor), this.getEog(editor));
|
|
|
editor.getDoc().setCursor(curPos.line + 1, 2);
|
|
|
- console.log(this.isInRow(editor));
|
|
|
}
|
|
|
|
|
|
}
|