Skip to main content

Use Toast UI Editor ui.toast.com/tui-editor in your streamlit project.

Project description

st-tui-editor

A Streamlit component that integrates the powerful Toast UI Editor, a Markdown editor that provides both Markdown and WYSIWYG editing modes.

TUI Editor in Streamlit

See demo at: https://toastui-markdown-editor.streamlit.app

Features

  • Dual Modes: Support for both Markdown and WYSIWYG editing.
  • Live Preview: Real-time rendering of Markdown content.
  • Theming: Built-in support for Light and Dark themes.
  • Customization: Configurable height, preview style (vertical/tab), and more.
  • Streamlit Integration:
    • Integrated "Save" toolbar button to sync content back to Streamlit.
    • Returns the edited markdown as a JSON object.

Installation

Install via pip:

pip install st-tui-editor

Usage

Here's a simple example of how to use st-tui-editor in your Streamlit app:

import streamlit as st
from st_tui_editor import st_tui_editor

st.title("Streamlit TUI Editor")

# Initialize with some default text
initial_text = """
# Hello Streamlit!
This is the **Toast UI Editor** component.
"""

# Render the editor
output = st_tui_editor(
    initial_value=initial_text,
    height="600px",
    initial_edit_type="markdown",
    theme="dark",
    key="my_editor"
)

# Access the value
if output:
    st.write("### Output Preview")
    st.markdown(output.get("markdown"))
    
    st.write("### Raw JSON")
    st.json(output)

API Reference

st_tui_editor

st_tui_editor(
    initial_value="",
    height="500px",
    initial_edit_type="markdown",
    preview_style="vertical",
    theme="light",
    usage_statistics=True,
    key=None
)
Parameter Type Default Description
initial_value str "" The initial markdown content to display in the editor.
height str "500px" The CSS height of the editor (e.g., "600px", "auto").
initial_edit_type str "markdown" The initial editing mode. Options: "markdown" or "wysiwyg".
preview_style str "vertical" The preview style for Markdown mode. Options: "vertical" (side-by-side) or "tab".
theme str "light" The UI theme. Options: "light" or "dark".
usage_statistics bool True Whether to send hostname to Google Analytics (TUI Editor default behavior).
key str None An optional key that uniquely identifies this component instance.

Return Value

The component returns a dictionary (JSON) containing the editor's state.

{
  "markdown": "The content of the editor..."
}

The content is updated when the user clicks the Save icon in the toolbar.

Development

If you want to contribute or modify the component locally:

  1. Clone the repository
  2. Install Python dependencies (in editable mode):
    pip install -e .
    
  3. Build the frontend:
    cd st_tui_editor/frontend
    npm install
    npm run build
    
  4. Run the example:
    streamlit run example.py
    

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

st_tui_editor-0.0.3.tar.gz (531.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

st_tui_editor-0.0.3-py3-none-any.whl (533.5 kB view details)

Uploaded Python 3

File details

Details for the file st_tui_editor-0.0.3.tar.gz.

File metadata

  • Download URL: st_tui_editor-0.0.3.tar.gz
  • Upload date:
  • Size: 531.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for st_tui_editor-0.0.3.tar.gz
Algorithm Hash digest
SHA256 60d947c2417ec06065fa5796ceda30352411b57a100cd837c26d55476469c102
MD5 92e96d55369631e5e038f908979c20f9
BLAKE2b-256 cbbef06f299ac60475ba3d25e2c90bac6337cdd4069d8389ff7f49568f649e6f

See more details on using hashes here.

File details

Details for the file st_tui_editor-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: st_tui_editor-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 533.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for st_tui_editor-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 48820a5ab3271238a8bff57627f341883d978afe1626f0c38ae69c5759474517
MD5 0ced9ad41e3e763d5a25a95b045cbd82
BLAKE2b-256 4309ac13fe72487d991db13b0c06eac210bff8565f9cd902119c9973c403454b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page