Currently, if one needs to get the content of code editor as set by the user, modify it with some internal logic, and then return it in the same code editor, one has to rely on st.rerun() and manual state tracking.
However, many streamlit elements, like text_area provide on_change callbacks. Instead of checking the code_editor_dict and issuing a rerun, one simply registers a callback that is executed on a submit press.
Is such a feature possible for streamlit-code-editor?
This issue is superficially related to #12 but the solution shown there is not providing a callback, only an automated rerun.
Note: text_area's on_change is a misnomer -- it is more of an on_submit. It follows these semantics: https://docs.streamlit.io/develop/api-reference/caching-and-state/st.session_state#use-callbacks-to-update-session-state
The reason I am asking for this is that it will make it possible to change the session state after a submit but before a new render of the code editor.
Currently, if one needs to get the content of
code editoras set by the user, modify it with some internal logic, and then return it in the samecode editor, one has to rely onst.rerun()and manual state tracking.However, many streamlit elements, like
text_areaprovideon_changecallbacks. Instead of checking thecode_editor_dictand issuing arerun, one simply registers a callback that is executed on a submit press.Is such a feature possible for
streamlit-code-editor?This issue is superficially related to #12 but the solution shown there is not providing a callback, only an automated rerun.
Note:
text_area'son_changeis a misnomer -- it is more of anon_submit. It follows these semantics: https://docs.streamlit.io/develop/api-reference/caching-and-state/st.session_state#use-callbacks-to-update-session-stateThe reason I am asking for this is that it will make it possible to change the session state after a submit but before a new render of the code editor.