|
|
@@ -3,6 +3,7 @@ import { useState, useCallback } from 'react';
|
|
|
|
|
|
import nodePath from 'path';
|
|
|
|
|
|
+import type { IPagePopulatedToShowRevision } from '@growi/core';
|
|
|
import { DevidedPagePath } from '@growi/core/dist/models';
|
|
|
import { pathUtils } from '@growi/core/dist/utils';
|
|
|
import { useTranslation } from 'next-i18next';
|
|
|
@@ -12,9 +13,16 @@ import { ValidationTarget } from '~/client/util/input-validator';
|
|
|
import ClosableTextInput from '../Common/ClosableTextInput';
|
|
|
import { CopyDropdown } from '../Common/CopyDropdown';
|
|
|
|
|
|
-import type { Props } from './PagePathHeader';
|
|
|
import { usePagePathRenameHandler } from './page-header-utils';
|
|
|
|
|
|
+import styles from './PageTitleHeader.module.scss';
|
|
|
+
|
|
|
+const moduleClass = styles['page-title-header'];
|
|
|
+
|
|
|
+type Props = {
|
|
|
+ currentPage: IPagePopulatedToShowRevision,
|
|
|
+ className?: string,
|
|
|
+};
|
|
|
|
|
|
export const PageTitleHeader: FC<Props> = (props) => {
|
|
|
const { t } = useTranslation();
|
|
|
@@ -63,38 +71,38 @@ export const PageTitleHeader: FC<Props> = (props) => {
|
|
|
|
|
|
|
|
|
return (
|
|
|
- <div className="d-flex align-items-center">
|
|
|
+ <div className={`d-flex align-items-center ${moduleClass} ${props.className ?? ''}`}>
|
|
|
<div className="me-1">
|
|
|
- {isRenameInputShown
|
|
|
- ? (
|
|
|
- <div className="page-title-header-input">
|
|
|
- <ClosableTextInput
|
|
|
- useAutosizeInput
|
|
|
- value={editedPageTitle}
|
|
|
- placeholder={t('Input page name')}
|
|
|
- onPressEnter={onPressEnter}
|
|
|
- onPressEscape={onPressEscape}
|
|
|
- onChange={onInputChange}
|
|
|
- onClickOutside={() => setRenameInputShown(false)}
|
|
|
- validationTarget={ValidationTarget.PAGE}
|
|
|
- />
|
|
|
- </div>
|
|
|
- )
|
|
|
- : (
|
|
|
- <h1 className="mb-0 fs-4" onClick={onClickPageTitle}>
|
|
|
- {pageTitle}
|
|
|
- </h1>
|
|
|
- )}
|
|
|
+ { isRenameInputShown && (
|
|
|
+ <div className="position-absolute">
|
|
|
+ <ClosableTextInput
|
|
|
+ useAutosizeInput
|
|
|
+ value={editedPageTitle}
|
|
|
+ placeholder={t('Input page name')}
|
|
|
+ inputClassName="fs-4"
|
|
|
+ onPressEnter={onPressEnter}
|
|
|
+ onPressEscape={onPressEscape}
|
|
|
+ onChange={onInputChange}
|
|
|
+ onClickOutside={() => setRenameInputShown(false)}
|
|
|
+ validationTarget={ValidationTarget.PAGE}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ ) }
|
|
|
+ <h1 className={`mb-0 fs-4 ${isRenameInputShown ? 'invisible' : ''}`} onClick={onClickPageTitle}>
|
|
|
+ {pageTitle}
|
|
|
+ </h1>
|
|
|
</div>
|
|
|
|
|
|
- <CopyDropdown
|
|
|
- pageId={currentPage._id}
|
|
|
- pagePath={currentPage.path}
|
|
|
- dropdownToggleId={`copydropdown-${currentPage._id}`}
|
|
|
- dropdownToggleClassName="ms-2 p-1"
|
|
|
- >
|
|
|
- <span className="material-symbols-outlined fs-6">content_paste</span>
|
|
|
- </CopyDropdown>
|
|
|
+ <div className={`${isRenameInputShown ? 'invisible' : ''}`}>
|
|
|
+ <CopyDropdown
|
|
|
+ pageId={currentPage._id}
|
|
|
+ pagePath={currentPage.path}
|
|
|
+ dropdownToggleId={`copydropdown-${currentPage._id}`}
|
|
|
+ dropdownToggleClassName="ms-2 p-1"
|
|
|
+ >
|
|
|
+ <span className="material-symbols-outlined fs-6">content_paste</span>
|
|
|
+ </CopyDropdown>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
);
|
|
|
};
|