|
@@ -5,7 +5,7 @@ import { UncontrolledTooltip } from 'reactstrap';
|
|
|
|
|
|
|
|
/* eslint-disable react/prop-types */
|
|
/* eslint-disable react/prop-types */
|
|
|
const PageEditorModeButtonWrapper = React.memo(({
|
|
const PageEditorModeButtonWrapper = React.memo(({
|
|
|
- editorMode, isBtnDisabled, onClick, targetMode, icon, label,
|
|
|
|
|
|
|
+ editorMode, isBtnDisabled, onClick, targetMode, icon, label, id
|
|
|
}) => {
|
|
}) => {
|
|
|
const classNames = [`btn btn-outline-primary ${targetMode}-button px-1`];
|
|
const classNames = [`btn btn-outline-primary ${targetMode}-button px-1`];
|
|
|
if (editorMode === targetMode) {
|
|
if (editorMode === targetMode) {
|
|
@@ -20,6 +20,7 @@ const PageEditorModeButtonWrapper = React.memo(({
|
|
|
type="button"
|
|
type="button"
|
|
|
className={classNames.join(' ')}
|
|
className={classNames.join(' ')}
|
|
|
onClick={() => { onClick(targetMode) }}
|
|
onClick={() => { onClick(targetMode) }}
|
|
|
|
|
+ id={id}
|
|
|
>
|
|
>
|
|
|
<span className="d-flex flex-column flex-md-row justify-content-center">
|
|
<span className="d-flex flex-column flex-md-row justify-content-center">
|
|
|
<span className="grw-page-editor-mode-manager-icon mr-md-1">{icon}</span>
|
|
<span className="grw-page-editor-mode-manager-icon mr-md-1">{icon}</span>
|
|
@@ -32,12 +33,12 @@ const PageEditorModeButtonWrapper = React.memo(({
|
|
|
|
|
|
|
|
function PageEditorModeManager(props) {
|
|
function PageEditorModeManager(props) {
|
|
|
const {
|
|
const {
|
|
|
- t, editorMode, onPageEditorModeButtonClicked, isBtnDisabled, isDeviceSmallerThanMd,
|
|
|
|
|
|
|
+ t, editorMode, onPageEditorModeButtonClicked, isBtnDisabled, isHackMDBtnDisabled, isDeviceSmallerThanMd,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
|
|
|
const pageEditorModeButtonClickedHandler = useCallback((viewType) => {
|
|
const pageEditorModeButtonClickedHandler = useCallback((viewType) => {
|
|
|
- if (isBtnDisabled) {
|
|
|
|
|
|
|
+ if (isBtnDisabled || isHackMDBtnDisabled && viewType === "hackmd") {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (onPageEditorModeButtonClicked != null) {
|
|
if (onPageEditorModeButtonClicked != null) {
|
|
@@ -76,11 +77,12 @@ function PageEditorModeManager(props) {
|
|
|
{(!isDeviceSmallerThanMd || editorMode === 'view') && (
|
|
{(!isDeviceSmallerThanMd || editorMode === 'view') && (
|
|
|
<PageEditorModeButtonWrapper
|
|
<PageEditorModeButtonWrapper
|
|
|
editorMode={editorMode}
|
|
editorMode={editorMode}
|
|
|
- isBtnDisabled={isBtnDisabled}
|
|
|
|
|
|
|
+ isBtnDisabled={isBtnDisabled || isHackMDBtnDisabled}
|
|
|
onClick={pageEditorModeButtonClickedHandler}
|
|
onClick={pageEditorModeButtonClickedHandler}
|
|
|
targetMode="hackmd"
|
|
targetMode="hackmd"
|
|
|
icon={<i className="fa fa-file-text-o" />}
|
|
icon={<i className="fa fa-file-text-o" />}
|
|
|
label={t('hackmd.hack_md')}
|
|
label={t('hackmd.hack_md')}
|
|
|
|
|
+ id="grw-page-editor-mode-manager-hackmd-button"
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
@@ -89,6 +91,11 @@ function PageEditorModeManager(props) {
|
|
|
{t('Not available for guest')}
|
|
{t('Not available for guest')}
|
|
|
</UncontrolledTooltip>
|
|
</UncontrolledTooltip>
|
|
|
)}
|
|
)}
|
|
|
|
|
+ {!isBtnDisabled && isHackMDBtnDisabled && (
|
|
|
|
|
+ <UncontrolledTooltip placement="top" target="grw-page-editor-mode-manager-hackmd-button" fade={false}>
|
|
|
|
|
+ {t('HackMD editor is not available')}
|
|
|
|
|
+ </UncontrolledTooltip>
|
|
|
|
|
+ )}
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
|
|
|
|
@@ -98,12 +105,14 @@ PageEditorModeManager.propTypes = {
|
|
|
t: PropTypes.func.isRequired, // i18next
|
|
t: PropTypes.func.isRequired, // i18next
|
|
|
onPageEditorModeButtonClicked: PropTypes.func,
|
|
onPageEditorModeButtonClicked: PropTypes.func,
|
|
|
isBtnDisabled: PropTypes.bool,
|
|
isBtnDisabled: PropTypes.bool,
|
|
|
|
|
+ isHackMDBtnDisabled: PropTypes.bool,
|
|
|
editorMode: PropTypes.string,
|
|
editorMode: PropTypes.string,
|
|
|
isDeviceSmallerThanMd: PropTypes.bool,
|
|
isDeviceSmallerThanMd: PropTypes.bool,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
PageEditorModeManager.defaultProps = {
|
|
PageEditorModeManager.defaultProps = {
|
|
|
isBtnDisabled: false,
|
|
isBtnDisabled: false,
|
|
|
|
|
+ isHackMDBtnDisabled: false,
|
|
|
isDeviceSmallerThanMd: false,
|
|
isDeviceSmallerThanMd: false,
|
|
|
};
|
|
};
|
|
|
|
|
|