reiji-h před 1 rokem
rodič
revize
989e4be78f

+ 2 - 2
apps/app/src/client/components/PageEditor/OptionsSelector.tsx

@@ -3,7 +3,7 @@ import React, {
 } from 'react';
 } from 'react';
 
 
 import {
 import {
-  type EditorTheme, type KeyMapMode, type PasteMode, AllPasteMode, DEFAULT_KEYMAP, DEFAULT_PASTE_MODE, DEFAULT_THEME,
+  type EditorTheme, type KeyMapMode, 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';
@@ -357,7 +357,7 @@ export const OptionsSelector = (): JSX.Element => {
               <ChangeStateButton
               <ChangeStateButton
                 onClick={() => setStatus(OptionsStatus.Paste)}
                 onClick={() => setStatus(OptionsStatus.Paste)}
                 header={t('page_edit.paste.title')}
                 header={t('page_edit.paste.title')}
-                data={t(`page_edit.paste.${editorSettings.pasteMode ?? 'both'}`) ?? ''}
+                data={t(`page_edit.paste.${editorSettings.pasteMode ?? PasteMode.both}`) ?? ''}
               />
               />
               <hr className="my-1" />
               <hr className="my-1" />
               <ConfigurationSelector />
               <ConfigurationSelector />

+ 5 - 4
packages/editor/src/client/stores/use-editor-settings.ts

@@ -7,8 +7,9 @@ import {
   EditorView,
   EditorView,
 } from '@codemirror/view';
 } from '@codemirror/view';
 
 
-import type {
-  EditorSettings, KeyMapMode, EditorTheme,
+import {
+  type EditorSettings, type KeyMapMode, type EditorTheme,
+  PasteMode,
 } from '../../consts';
 } from '../../consts';
 import type { UseCodeMirrorEditor } from '../services';
 import type { UseCodeMirrorEditor } from '../services';
 import {
 import {
@@ -108,7 +109,7 @@ export const useEditorSettings = (
         return;
         return;
       }
       }
 
 
-      if (editorSetings?.pasteMode !== 'file' && event.clipboardData.types.includes('text/plain')) {
+      if (editorSetings?.pasteMode !== PasteMode.file && event.clipboardData.types.includes('text/plain')) {
 
 
         const textData = event.clipboardData.getData('text/plain');
         const textData = event.clipboardData.getData('text/plain');
 
 
@@ -118,7 +119,7 @@ export const useEditorSettings = (
         codeMirrorEditor?.replaceText(adjusted);
         codeMirrorEditor?.replaceText(adjusted);
       }
       }
 
 
-      if (editorSetings?.pasteMode !== 'text' && onUpload != null && event.clipboardData.types.includes('Files')) {
+      if (editorSetings?.pasteMode !== PasteMode.text && onUpload != null && event.clipboardData.types.includes('Files')) {
         onUpload(Array.from(event.clipboardData.files));
         onUpload(Array.from(event.clipboardData.files));
       }
       }
 
 

+ 2 - 2
packages/editor/src/consts/paste-mode.ts

@@ -1,10 +1,10 @@
 
 
-const PasteMode = {
+export const PasteMode = {
   both: 'both',
   both: 'both',
   text: 'text',
   text: 'text',
   file: 'file',
   file: 'file',
 } as const;
 } as const;
 
 
-export const DEFAULT_PASTE_MODE = 'both';
+export const DEFAULT_PASTE_MODE = PasteMode.both;
 export const AllPasteMode = Object.values(PasteMode);
 export const AllPasteMode = Object.values(PasteMode);
 export type PasteMode = typeof PasteMode[keyof typeof PasteMode];
 export type PasteMode = typeof PasteMode[keyof typeof PasteMode];