|
|
@@ -3,7 +3,7 @@ import { useCallback } from 'react';
|
|
|
import { useForm } from 'react-hook-form';
|
|
|
|
|
|
import { GlobalCodeMirrorEditorKey } from '../../consts';
|
|
|
-import { AllEditorTheme } from '../../services';
|
|
|
+import { AllEditorTheme, AllKeyMap } from '../../services';
|
|
|
import { useCodeMirrorEditorIsolated } from '../../stores';
|
|
|
|
|
|
export const InitEditorValueRow = (): JSX.Element => {
|
|
|
@@ -69,38 +69,35 @@ export const SetCaretLineRow = (): JSX.Element => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-type SetThemeRowProps = {
|
|
|
- setEditorTheme: (value: string) => void,
|
|
|
+
|
|
|
+type SetParamRowProps = {
|
|
|
+ update: (value: string) => void,
|
|
|
+ items: string[],
|
|
|
}
|
|
|
-const SetThemeRow = (props: SetThemeRowProps): JSX.Element => {
|
|
|
-
|
|
|
- const { setEditorTheme } = props;
|
|
|
-
|
|
|
- const createItems = (items: string[]): JSX.Element => {
|
|
|
- return (
|
|
|
- <div>
|
|
|
- { items.map((theme) => {
|
|
|
- return (
|
|
|
- <button
|
|
|
- type="button"
|
|
|
- className="btn btn-outline-secondary"
|
|
|
- onClick={() => {
|
|
|
- setEditorTheme(theme);
|
|
|
- }}
|
|
|
- >{theme}
|
|
|
- </button>
|
|
|
- );
|
|
|
- }) }
|
|
|
- </div>
|
|
|
- );
|
|
|
- };
|
|
|
|
|
|
+const SetParamRow = (
|
|
|
+ props: SetParamRowProps,
|
|
|
+): JSX.Element => {
|
|
|
+ const { update, items } = props;
|
|
|
return (
|
|
|
<>
|
|
|
<div className="row mt-3">
|
|
|
<h2>default</h2>
|
|
|
<div className="col">
|
|
|
- {createItems(AllEditorTheme)}
|
|
|
+ <div>
|
|
|
+ { items.map((item) => {
|
|
|
+ return (
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ className="btn btn-outline-secondary"
|
|
|
+ onClick={() => {
|
|
|
+ update(item);
|
|
|
+ }}
|
|
|
+ >{item}
|
|
|
+ </button>
|
|
|
+ );
|
|
|
+ }) }
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</>
|
|
|
@@ -110,15 +107,17 @@ const SetThemeRow = (props: SetThemeRowProps): JSX.Element => {
|
|
|
|
|
|
type PlaygroundControllerProps = {
|
|
|
setEditorTheme: (value: string) => void
|
|
|
+ setEditorKeymap: (value: string) => void
|
|
|
};
|
|
|
|
|
|
export const PlaygroundController = (props: PlaygroundControllerProps): JSX.Element => {
|
|
|
- const { setEditorTheme } = props;
|
|
|
+ const { setEditorTheme, setEditorKeymap } = props;
|
|
|
return (
|
|
|
<div className="container mt-5">
|
|
|
<InitEditorValueRow />
|
|
|
<SetCaretLineRow />
|
|
|
- <SetThemeRow setEditorTheme={setEditorTheme} />
|
|
|
+ <SetParamRow update={setEditorTheme} items={AllEditorTheme} />
|
|
|
+ <SetParamRow update={setEditorKeymap} items={AllKeyMap} />
|
|
|
</div>
|
|
|
);
|
|
|
};
|