|
@@ -1,44 +1,20 @@
|
|
|
import { useProjectSettingsContext } from '@/features/editor-left-menu/context/project-settings-context'
|
|
import { useProjectSettingsContext } from '@/features/editor-left-menu/context/project-settings-context'
|
|
|
import DropdownSetting from '../dropdown-setting'
|
|
import DropdownSetting from '../dropdown-setting'
|
|
|
-import getMeta from '@/utils/meta'
|
|
|
|
|
-import { useMemo } from 'react'
|
|
|
|
|
-import type { Option } from '../dropdown-setting'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
+import { useEditorThemesOptionGroups } from '@/features/editor-left-menu/hooks/use-editor-theme-option-groups'
|
|
|
|
|
|
|
|
export default function EditorThemeSetting() {
|
|
export default function EditorThemeSetting() {
|
|
|
- const editorThemes = getMeta('ol-editorThemes')
|
|
|
|
|
- const legacyEditorThemes = getMeta('ol-legacyEditorThemes')
|
|
|
|
|
const { editorTheme, setEditorTheme } = useProjectSettingsContext()
|
|
const { editorTheme, setEditorTheme } = useProjectSettingsContext()
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
- const options = useMemo(() => {
|
|
|
|
|
- const editorThemeOptions: Array<Option> =
|
|
|
|
|
- editorThemes?.map(theme => ({
|
|
|
|
|
- value: theme.name,
|
|
|
|
|
- label: theme.name.replace(/_/g, ' '),
|
|
|
|
|
- })) ?? []
|
|
|
|
|
-
|
|
|
|
|
- const dividerOption: Option = {
|
|
|
|
|
- value: '-',
|
|
|
|
|
- label: '—————————————————',
|
|
|
|
|
- disabled: true,
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const legacyEditorThemeOptions: Array<Option> =
|
|
|
|
|
- legacyEditorThemes?.map(theme => ({
|
|
|
|
|
- value: theme.name,
|
|
|
|
|
- label: theme.name.replace(/_/g, ' ') + ' (Legacy)',
|
|
|
|
|
- })) ?? []
|
|
|
|
|
-
|
|
|
|
|
- return [...editorThemeOptions, dividerOption, ...legacyEditorThemeOptions]
|
|
|
|
|
- }, [editorThemes, legacyEditorThemes])
|
|
|
|
|
|
|
+ const optGroups = useEditorThemesOptionGroups()
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<DropdownSetting
|
|
<DropdownSetting
|
|
|
id="editorTheme"
|
|
id="editorTheme"
|
|
|
label={t('editor_theme')}
|
|
label={t('editor_theme')}
|
|
|
description={t('the_code_editor_color_scheme')}
|
|
description={t('the_code_editor_color_scheme')}
|
|
|
- options={options}
|
|
|
|
|
|
|
+ optgroups={optGroups}
|
|
|
onChange={setEditorTheme}
|
|
onChange={setEditorTheme}
|
|
|
value={editorTheme}
|
|
value={editorTheme}
|
|
|
translateOptions="no"
|
|
translateOptions="no"
|