|
@@ -3,7 +3,7 @@ import React, {
|
|
|
} from 'react';
|
|
} from 'react';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
- type EditorTheme, type KeyMapMode, DEFAULT_KEYMAP, DEFAULT_THEME,
|
|
|
|
|
|
|
+ type EditorTheme, type KeyMapMode, type PasteMode, AllPasteMode, DEFAULT_KEYMAP, DEFAULT_PASTE_MODE, DEFAULT_THEME,
|
|
|
} from '@growi/editor';
|
|
} from '@growi/editor';
|
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useTranslation } from 'next-i18next';
|
|
|
import Image from 'next/image';
|
|
import Image from 'next/image';
|
|
@@ -174,6 +174,29 @@ const IndentSizeSelector = memo(({ onClickBefore }: {onClickBefore: () => void})
|
|
|
IndentSizeSelector.displayName = 'IndentSizeSelector';
|
|
IndentSizeSelector.displayName = 'IndentSizeSelector';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+const PasteSelector = memo(({ onClickBefore }: {onClickBefore: () => void}): JSX.Element => {
|
|
|
|
|
+
|
|
|
|
|
+ const { t } = useTranslation();
|
|
|
|
|
+ const { data: editorSettings, update } = useEditorSettings();
|
|
|
|
|
+ const selectedPasteMode = editorSettings?.pasteMode ?? DEFAULT_PASTE_MODE;
|
|
|
|
|
+
|
|
|
|
|
+ const listItems = useMemo(() => (
|
|
|
|
|
+ <>
|
|
|
|
|
+ { (AllPasteMode).map((pasteMode) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <RadioListItem onClick={() => update({ pasteMode })} text={t(`page_edit.paste.${pasteMode}`) ?? ''} checked={pasteMode === selectedPasteMode} />
|
|
|
|
|
+ );
|
|
|
|
|
+ }) }
|
|
|
|
|
+ </>
|
|
|
|
|
+ ), [update, t, selectedPasteMode]);
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Selector header={t('page_edit.paste.title')} onClickBefore={onClickBefore} items={listItems} />
|
|
|
|
|
+ );
|
|
|
|
|
+});
|
|
|
|
|
+PasteSelector.displayName = 'PasteSelector';
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
type SwitchItemProps = {
|
|
type SwitchItemProps = {
|
|
|
inputId: string,
|
|
inputId: string,
|
|
|
onChange: () => void,
|
|
onChange: () => void,
|
|
@@ -269,6 +292,7 @@ const OptionsStatus = {
|
|
|
Theme: 'Theme',
|
|
Theme: 'Theme',
|
|
|
Keymap: 'Keymap',
|
|
Keymap: 'Keymap',
|
|
|
Indent: 'Indent',
|
|
Indent: 'Indent',
|
|
|
|
|
+ Paste: 'Paste',
|
|
|
} as const;
|
|
} as const;
|
|
|
type OptionStatus = typeof OptionsStatus[keyof typeof OptionsStatus];
|
|
type OptionStatus = typeof OptionsStatus[keyof typeof OptionsStatus];
|
|
|
|
|
|
|
@@ -330,6 +354,12 @@ export const OptionsSelector = (): JSX.Element => {
|
|
|
data={currentIndentSize.toString() ?? ''}
|
|
data={currentIndentSize.toString() ?? ''}
|
|
|
/>
|
|
/>
|
|
|
<hr className="my-1" />
|
|
<hr className="my-1" />
|
|
|
|
|
+ <ChangeStateButton
|
|
|
|
|
+ onClick={() => setStatus(OptionsStatus.Paste)}
|
|
|
|
|
+ header={t('page_edit.paste.title')}
|
|
|
|
|
+ data={t(`page_edit.paste.${editorSettings.pasteMode ?? 'both'}`) ?? ''}
|
|
|
|
|
+ />
|
|
|
|
|
+ <hr className="my-1" />
|
|
|
<ConfigurationSelector />
|
|
<ConfigurationSelector />
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
@@ -346,6 +376,9 @@ export const OptionsSelector = (): JSX.Element => {
|
|
|
<IndentSizeSelector onClickBefore={() => setStatus(OptionsStatus.Home)} />
|
|
<IndentSizeSelector onClickBefore={() => setStatus(OptionsStatus.Home)} />
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
+ { status === OptionsStatus.Paste && (
|
|
|
|
|
+ <PasteSelector onClickBefore={() => setStatus(OptionsStatus.Home)} />
|
|
|
|
|
+ )}
|
|
|
</DropdownMenu>
|
|
</DropdownMenu>
|
|
|
</Dropdown>
|
|
</Dropdown>
|
|
|
);
|
|
);
|