change the way text suggestions are rendered + option to disable syntactic sugar
This commit is contained in:
parent
ea8c015eff
commit
2d81e42447
12 changed files with 357 additions and 291 deletions
|
|
@ -2,10 +2,10 @@ import { useContext, useEffect, useRef, useState } from "react";
|
|||
|
||||
import { getSymbol, getType, symbolFunction } from "dope2";
|
||||
|
||||
import { CallBlock, type CallBlockState } from "./CallBlock";
|
||||
import { CallBlock, CallBlockNoSugar, type CallBlockState } from "./CallBlock";
|
||||
import { InputBlock, type InputBlockState, type SuggestionType } from "./InputBlock";
|
||||
import { Type } from "./Type";
|
||||
import { DeepError, evalEditorBlock } from "./eval";
|
||||
import { evalEditorBlock } from "./eval";
|
||||
import { CommandContext } from "./CommandContext";
|
||||
import "./Editor.css";
|
||||
import { EnvContext } from "./EnvContext";
|
||||
|
|
@ -148,11 +148,20 @@ export function Editor({state, setState, onCancel, suggestionPriority}: EditorPr
|
|||
onCancel={onCancel}
|
||||
/>;
|
||||
case "call":
|
||||
return <CallBlock
|
||||
state={state}
|
||||
setState={setState as (callback:(p:CallBlockState)=>EditorState)=>void}
|
||||
suggestionPriority={suggestionPriority}
|
||||
/>;
|
||||
if (globalContext?.syntacticSugar) {
|
||||
return <CallBlock
|
||||
state={state}
|
||||
setState={setState as (callback:(p:CallBlockState)=>EditorState)=>void}
|
||||
suggestionPriority={suggestionPriority}
|
||||
/>;
|
||||
}
|
||||
else {
|
||||
return <CallBlockNoSugar
|
||||
state={state}
|
||||
setState={setState as (callback:(p:CallBlockState)=>EditorState)=>void}
|
||||
suggestionPriority={suggestionPriority}
|
||||
/>;
|
||||
}
|
||||
case "let":
|
||||
return <LetInBlock
|
||||
state={state}
|
||||
|
|
@ -165,20 +174,16 @@ export function Editor({state, setState, onCancel, suggestionPriority}: EditorPr
|
|||
const resolved = evalEditorBlock(state, env);
|
||||
return <>
|
||||
{renderBlock()}
|
||||
{
|
||||
(resolved && !(resolved instanceof DeepError))
|
||||
? <div className="typeSignature">
|
||||
:: <Type type={getType(resolved)} />
|
||||
</div>
|
||||
: <></>
|
||||
}
|
||||
<div className="typeSignature">
|
||||
:: <Type type={getType(resolved)} />
|
||||
</div>
|
||||
<input
|
||||
ref={commandInputRef}
|
||||
spellCheck={false}
|
||||
className="editable commandInput"
|
||||
placeholder={`<command>`}
|
||||
onKeyDown={onCommand}
|
||||
value={""}
|
||||
onChange={() => {}} />
|
||||
ref={commandInputRef}
|
||||
spellCheck={false}
|
||||
className="editable commandInput"
|
||||
placeholder={`<command>`}
|
||||
onKeyDown={onCommand}
|
||||
value={""}
|
||||
onChange={() => {}} />
|
||||
</>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue