Skip to content

Commit

Permalink
use new code editor
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-work committed Jul 17, 2024
1 parent eb6d1c3 commit 0de8c92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 16 additions & 0 deletions gooey_ui/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,22 @@ def text_area(
return value or ""


def code_editor(
value: str = "",
key: str = None,
**props,
) -> typing.Any:
value = str(state.session_state.setdefault(key, value) or "")
return state.RenderTreeNode(
name="code-editor",
props=dict(
name=key,
defaultValue=value,
**props,
),
).mount()


def nrows_for_text(
text: str,
max_height_px: int,
Expand Down
6 changes: 2 additions & 4 deletions recipes/Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ def run_v2(
response.error = data.get("error")

def render_form_v2(self):
st.text_area(
"##### " + field_title_desc(self.RequestModel, "code"),
key="code",
)
st.caption("##### " + field_title_desc(self.RequestModel, "code"))
st.code_editor(key="code", language="javascript", height=300)

def render_variables(self):
variables_input(template_keys=["code"], allow_add=True)
Expand Down

0 comments on commit 0de8c92

Please sign in to comment.