Skip to content

How to reset state of code editor?  #42

@RafalSkolasinski

Description

@RafalSkolasinski

I am wondering how I could reset state of the editor. I found that I could set initial text with value key but updating it later does not seem to change anything. Here is my attempt

import streamlit as st
from streamlit_ace import st_ace


LANGUAGE = "yaml"
THEME = "twilight"

if 'manifest' not in st.session_state:
    st.session_state.manifest = ""

reset = st.button("Reset!")
if reset:
    st.session_state.manifest = ""

print(st.session_state.manifest == "")

content = st_ace(
    value=st.session_state.manifest,
    placeholder="# Paste your manifest here",
    language=LANGUAGE,
    theme=THEME,
    font_size=14,
    tab_size=4,
    min_lines=45,
    auto_update=True,
    key="ace",
)

if content:
    st.session_state.manifest = content
    st.subheader("Content")
    st.code(content, language=LANGUAGE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions