Răsfoiți Sursa

135396 rename util file

soumaeda 2 ani în urmă
părinte
comite
74352a93a6

+ 1 - 1
apps/app/src/client/services/side-effects/handsontable-modal-launcher-for-view.ts

@@ -4,7 +4,7 @@ import EventEmitter from 'events';
 
 import MarkdownTable from '~/client/models/MarkdownTable';
 import { useSaveOrUpdate } from '~/client/services/page-operation';
-import { getMarkdownTableFromLine, replaceMarkdownTableInMarkdown } from '~/components/PageEditor/MarkdownTableUtilForView';
+import { getMarkdownTableFromLine, replaceMarkdownTableInMarkdown } from '~/components/PageEditor/markdown-table-util-for-view';
 import type { OptionsToSave } from '~/interfaces/page-operation';
 import { useShareLinkId } from '~/stores/context';
 import { useHandsontableModal } from '~/stores/modal';

+ 1 - 1
apps/app/src/components/PageEditor/HandsontableModal.tsx

@@ -11,7 +11,7 @@ import {
 import { debounce } from 'throttle-debounce';
 
 import MarkdownTable from '~/client/models/MarkdownTable';
-import { replaceFocusedMarkdownTableWithEditor } from '~/components/PageEditor/MarkdownTableUtilForEditor';
+import { replaceFocusedMarkdownTableWithEditor } from '~/components/PageEditor/markdown-table-util-for-editor';
 import { useHandsontableModal } from '~/stores/modal';
 
 import ExpandOrContractButton from '../ExpandOrContractButton';

+ 3 - 4
apps/app/src/components/PageEditor/MarkdownTableInterceptor.js

@@ -3,8 +3,9 @@ import { BasicInterceptor } from '@growi/core/dist/utils';
 import MarkdownTable from '~/client/models/MarkdownTable';
 
 import {
-  getStrFromBot, addRowToMarkdownTable, getStrToEot, isEndOfLine, mergeMarkdownTable, replaceFocusedMarkdownTableWithEditor, isInTable,
-} from './MarkdownTableUtilForEditor';
+  getStrFromBot, addRowToMarkdownTable, getStrToEot, isEndOfLine, mergeMarkdownTable, replaceFocusedMarkdownTableWithEditor,
+  isInTable, emptyLineOfTableRE,
+} from './markdown-table-util-for-editor';
 
 /**
  * Interceptor for markdown table
@@ -61,8 +62,6 @@ export default class MarkdownTableInterceptor extends BasicInterceptor {
     const editor = context.editor; // AbstractEditor instance
     // "autoFormatMarkdownTable" may be undefined, so it is compared to true and converted to bool.
     const noIntercept = (context.autoFormatMarkdownTable === false);
-    // https://regex101.com/r/1UuWBJ/3
-    const emptyLineOfTableRE = /^([^\r\n|]*)\|((\s*\|)+)$/;
 
     // do nothing if editor is not a CodeMirrorEditor or no intercept
     if (editor == null || editor.getCodeMirror() == null || noIntercept) {

+ 2 - 4
apps/app/src/components/PageEditor/MarkdownTableUtilForEditor.ts → apps/app/src/components/PageEditor/markdown-table-util-for-editor.ts

@@ -2,12 +2,10 @@ import { EditorView } from '@codemirror/view';
 
 import MarkdownTable from '~/client/models/MarkdownTable';
 
-/**
- * Utility for markdown table
- */
-
 // https://regex101.com/r/7BN2fR/10
 const linePartOfTableRE = /^([^\r\n|]*)\|(([^\r\n|]*\|)+)$/;
+// https://regex101.com/r/1UuWBJ/3
+export const emptyLineOfTableRE = /^([^\r\n|]*)\|((\s*\|)+)$/;
 
 const curPos = (editor: EditorView): number => {
   return editor.state.selection.main.head;

+ 0 - 4
apps/app/src/components/PageEditor/MarkdownTableUtilForView.ts → apps/app/src/components/PageEditor/markdown-table-util-for-view.ts

@@ -1,9 +1,5 @@
 import MarkdownTable from '~/client/models/MarkdownTable';
 
-/**
- * Utility for markdown table
- */
-
 export const getMarkdownTableFromLine = (markdown: string, bol: number, eol: number): MarkdownTable => {
   const tableLines = markdown.split(/\r\n|\r|\n/).slice(bol - 1, eol).join('\n');
   return MarkdownTable.fromMarkdownString(tableLines);

+ 1 - 1
packages/editor/src/components/CodeMirrorEditor/Toolbar/TableButton.tsx

@@ -14,7 +14,7 @@ export const TableButton = (props: Props): JSX.Element => {
   const editor = codeMirrorEditor?.view;
   const openTableModalHandler = useCallback(() => {
     openTableModal(editor);
-  }, [editor]);
+  }, [editor, openTableModal]);
 
   return (
     <button type="button" className="btn btn-toolbar-button" onClick={openTableModalHandler}>