/* eslint-disable no-useless-escape */ import React, { useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem, } from 'reactstrap'; import AdminCustomizeContainer from '~/client/services/AdminCustomizeContainer'; import { toastSuccess, toastError } from '~/client/util/apiNotification'; import { withUnstatedContainers } from '../../UnstatedUtils'; import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow'; type Props = { adminCustomizeContainer: AdminCustomizeContainer } const CustomizeHighlightSetting = (props: Props): JSX.Element => { const { adminCustomizeContainer } = props; const { t } = useTranslation(); const [isDropdownOpen, setIsDropdownOpen] = useState(false); const options = adminCustomizeContainer.state.highlightJsCssSelectorOptions; const onToggleDropdown = useCallback(() => { setIsDropdownOpen(!isDropdownOpen); }, [isDropdownOpen]); const onClickSubmit = useCallback(async() => { try { await adminCustomizeContainer.updateHighlightJsStyle(); toastSuccess(t('toaster.update_successed', { target: t('admin:customize_setting.code_highlight') })); } catch (err) { toastError(err); } }, [t, adminCustomizeContainer]); const renderHljsDemo = () => { /* eslint-disable max-len */ const html = `function MersenneTwister(seed) { if (arguments.length == 0) { seed = new Date().getTime(); } this._mt = new Array(624); this.setSeed(seed); }`; /* eslint-enable max-len */ return (
{/* eslint-disable-next-line react/no-danger */}
);
};
const menuItem: React.ReactNode[] = [];
Object.entries(options).forEach((option) => {
const styleId = option[0];
const styleName = option[1].name;
const isBorderEnable = option[1].border;
menuItem.push(
{/* eslint-disable-next-line react/no-danger */}