Explorar el Código

add regex101 link

kosei-n hace 2 años
padre
commit
0b326d9ff4

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

@@ -369,7 +369,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
   // set handler to focus
   useLayoutEffect(() => {
     if (editorMode === EditorMode.Editor) {
-      codeMirrorEditor?.focus();
+      // codeMirrorEditor?.focus();
     }
   }, [codeMirrorEditor, editorMode]);
 

+ 4 - 3
apps/app/src/components/PageHeader/PageTitleHeader.tsx

@@ -29,6 +29,7 @@ export const PageTitleHeader: FC<Props> = (props) => {
 
   const currentPagePath = currentPage.path;
 
+  // https://regex101.com/r/Wg2Hh6/1
   const untitledPageRegex = /^Untitled-\d+$/;
 
   const isNewlyCreatedPage = currentPage.wip && currentPage.latestRevision == null && untitledPageRegex.test(nodePath.basename(currentPagePath));
@@ -38,11 +39,11 @@ export const PageTitleHeader: FC<Props> = (props) => {
   const dPagePath = new DevidedPagePath(currentPage.path, true);
   const pageTitle = dPagePath.latter;
 
-  const [isRenameInputShown, setRenameInputShown] = useState(true);
+  const [isRenameInputShown, setRenameInputShown] = useState(isNewlyCreatedPage);
   const [editedPagePath, setEditedPagePath] = useState(currentPagePath);
 
   // console.log(isNewlyCreatedPage);
-  // console.log(isRenameInputShown);
+  console.log(isRenameInputShown);
 
   const pagePathRenameHandler = usePagePathRenameHandler(currentPage);
 
@@ -100,7 +101,7 @@ export const PageTitleHeader: FC<Props> = (props) => {
               onPressEnter={onPressEnter}
               onPressEscape={onPressEscape}
               onChange={onInputChange}
-              onClickOutside={() => setRenameInputShown(false)}
+              onClickOutside={() => { setRenameInputShown(false) }}
               validationTarget={ValidationTarget.PAGE}
             />
           </div>