ryohek 5 лет назад
Родитель
Сommit
616b393845
1 измененных файлов с 12 добавлено и 4 удалено
  1. 12 4
      src/client/js/components/PageEditor/GridEditorUtil.js

+ 12 - 4
src/client/js/components/PageEditor/GridEditorUtil.js

@@ -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;