trying to simplify things a bit more... will get rid of 'onResolve'
This commit is contained in:
parent
897824e07d
commit
9c0c2dab90
7 changed files with 85 additions and 45 deletions
|
|
@ -62,6 +62,10 @@ export function Editor({state, setState, onResolve, onCancel, filter}: EditorPro
|
|||
}, [needCommand]);
|
||||
const onMyResolve = (editorState: EditorState) => {
|
||||
setState(editorState);
|
||||
onResolve(editorState);
|
||||
return;
|
||||
|
||||
|
||||
if (editorState.resolved) {
|
||||
setNeedCommand(true);
|
||||
}
|
||||
|
|
@ -74,8 +78,9 @@ export function Editor({state, setState, onResolve, onCancel, filter}: EditorPro
|
|||
|
||||
const globalContext = useContext(CommandContext);
|
||||
const onCommand = (e: React.KeyboardEvent) => {
|
||||
const type = getType(state.resolved);
|
||||
const commands = getCommands(type);
|
||||
// const type = getType(state.resolved);
|
||||
// const commands = getCommands(type);
|
||||
const commands = ['e', 't', 'Enter', 'Backspace', 'ArrowLeft', 'ArrowRight', 'Tab', 'l', '=', '.', 'c'];
|
||||
if (!commands.includes(e.key)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -172,19 +177,16 @@ export function Editor({state, setState, onResolve, onCancel, filter}: EditorPro
|
|||
(state.resolved)
|
||||
? <div className="typeSignature">
|
||||
:: <Type type={getType(state.resolved)} />
|
||||
{ (needCommand)
|
||||
? <input
|
||||
ref={commandInputRef}
|
||||
spellCheck={false}
|
||||
className="editable commandInput"
|
||||
placeholder={`<command: ${getShortCommands(getType(state.resolved))}>`}
|
||||
onKeyDown={onCommand}
|
||||
value={""}
|
||||
onChange={() => {}} /> /* gets rid of React warning */
|
||||
: <></>
|
||||
}
|
||||
</div>
|
||||
: <></>
|
||||
}
|
||||
<input
|
||||
ref={commandInputRef}
|
||||
spellCheck={false}
|
||||
className="editable commandInput"
|
||||
placeholder={`<command>`}
|
||||
onKeyDown={onCommand}
|
||||
value={""}
|
||||
onChange={() => {}} />
|
||||
</>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue