Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
HSunboy committed May 29, 2024
1 parent 21d507e commit 111c2b5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/component/Input/Keymap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ const KeymapInput: React.FC<IProps> = (props) => {
ctrlKey && mod.push(KeyCode.Ctrl);
shiftKey && mod.push(KeyCode.Shift);
altKey && mod.push(KeyCode.Alt);
let isSpecialKey = [
KeyCode.Ctrl,
KeyCode.Shift,
KeyCode.Alt,
KeyCode.Meta,
KeyCode.Meta,
].includes(monacoKeyCode);
let isSpecialKey = [KeyCode.Ctrl, KeyCode.Shift, KeyCode.Alt, KeyCode.Meta].includes(
monacoKeyCode,
);

console.log(mod, keyCode, monacoKeyCode);
const value = isSpecialKey ? [...mod] : [...mod, monacoKeyCode];
setValue(value.join(','));
}
Expand Down
2 changes: 2 additions & 0 deletions src/component/ODCSetting/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import editorSettings from './config/editor';
import perferenceSettings from './config/preference';
import performanceSettings from './config/performance';
import accountSettings from './config/account';
import type { FormRule } from 'antd';

export interface ODCSettingGroup {
label: string;
Expand All @@ -35,6 +36,7 @@ export interface IODCSetting<T = any> {
* 渲染宽度
*/
span?: number;
rules?: FormRule[];
storeType: 'server' | 'local';
disabledInClient?: boolean;
hidden?: boolean;
Expand Down
15 changes: 15 additions & 0 deletions src/component/ODCSetting/config/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { IODCSetting, ODCSettingGroup } from '../config';
import InputItem from '../Item/InputItem';
import KeymapInput from '@/component/Input/Keymap';
import SelectItem from '../Item/SelectItem';
import { validForEditorKeymap } from '@/component/Input/Keymap/helper';

const editorGroup: ODCSettingGroup = {
label: formatMessage({ id: 'src.component.ODCSetting.config.239D3F16' }), //'编辑器'
Expand Down Expand Up @@ -107,6 +108,13 @@ const editorSettings: IODCSetting[] = [
group: editorGroup,
secondGroup: editorKeymapGroup,
storeType: 'server',
rules: [
{
validator(rule, value, callback) {
return validForEditorKeymap(value);
},
},
],
render: (value, onChange) => {
return <KeymapInput value={value} onChange={onChange} />;
},
Expand All @@ -116,6 +124,13 @@ const editorSettings: IODCSetting[] = [
key: 'odc.editor.shortcut.executeCurrentStatement',
group: editorGroup,
secondGroup: editorKeymapGroup,
rules: [
{
validator(rule, value, callback) {
return validForEditorKeymap(value);
},
},
],
storeType: 'server',
render: (value, onChange) => {
return <KeymapInput value={value} onChange={onChange} />;
Expand Down
1 change: 1 addition & 0 deletions src/component/ODCSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ const ODCSetting: React.FC<IProps> = ({ modalStore }) => {
}
name={set.key}
key={set.key}
rules={set.rules}
>
{set.render(null, async () => {})}
</Form.Item>
Expand Down

0 comments on commit 111c2b5

Please sign in to comment.