|
|
@@ -2,10 +2,20 @@
|
|
|
* Utility for grid editor
|
|
|
*/
|
|
|
class GridEditorUtil {
|
|
|
-
|
|
|
constructor() {
|
|
|
+ // regex101 の url
|
|
|
+ this.linePartOfTableRE = /(<div>.*)(</div>)$/;
|
|
|
+ this.isInRow = this.isInRow.bind(this);
|
|
|
this.replaceGridWithHtmlWithEditor = this.replaceGridWithHtmlWithEditor.bind(this);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * return boolean value whether the cursor position is in a row
|
|
|
+ */
|
|
|
+ isInRow(editor) {
|
|
|
+ const curPos = editor.getCursor();
|
|
|
+ // return this.linePartOfTableRE.test(editor.getDoc().getLine(curPos.line));
|
|
|
+ return this.linePartOfRow.test(editor.getDoc().getLine(curPos.line));
|
|
|
+ }
|
|
|
|
|
|
replaceGridWithHtmlWithEditor(editor) {
|
|
|
const curPos = editor.getCursor();
|
|
|
@@ -16,10 +26,8 @@ class GridEditorUtil {
|
|
|
);
|
|
|
editor.getDoc().setCursor(curPos.line + 1, 2);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
// singleton pattern
|
|
|
const instance = new GridEditorUtil();
|
|
|
Object.freeze(instance);
|
|
|
-export default instance;
|
|
|
+export default instance;
|