I wrapped the Monaco editor (the one from Visual Studio Code) in a Streamlit component.
Source: GitHub - marcusschiesser/streamlit-monaco: Monaco editor (Visual Studio Code) for Streamlit
PyPi: streamlit-monaco · PyPI
from streamlit_monaco import st_monaco
import streamlit as st
st.title("Streamlit Markdown Editor")
content = st_monaco(value="# Hello world", height="600px", language="markdown")
if st.button("Show editor's content"):
Does anyone know how I can add it to https://streamlit.io/components?
That is so good!!
The components page gets populated automatically by looking in github, pypi and on the community tracker (Streamlit Components - Community Tracker) – I would recommend posting it on the community tracker, and then you can expect it to be added to the components page automatically when the next update happens.
Thanks @blackary , couldn’t edit the wiki post, so I left a new reply: Streamlit Components - Community Tracker - #31 by Marcus_Schiesser - I hope it works!
Brilliant component. I’d like to use this but curious about the syntax and if the following is possible:
- How would I inject text into the component with a streamlit button? Would I update a session_state variable and do a st.rerun populating the session_state into the value?
- Is there a way to configure the monaco box via the streamlit parameters (i.e. add/remove line numbers, add menu items to the monaco component? etc…)
Thanks Joseph. I hope the following helps:
- Here’s a complicated example. The state is stored in a
dataclass, which is stored again in the
- Yes, I already passed a couple of parameters, see https://github.com/marcusschiesser/streamlit-monaco/blob/main/streamlit_monaco/__init__.py#L8-L12 - These are the ones I needed, happy to merge your PR with more parameters