Skip to main content

Streamlit component that allows you to render a TinyMCE editor in your app.

Project description

st-tiny-editor

st-tiny-editor is a versatile Streamlit component designed to enhance your application's text editing capabilities. With st-tiny-editor, you can effortlessly integrate the robust TinyMCE editor into your Streamlit applications, providing users with a seamless and intuitive editing experience.

TinyMCE is a feature-rich WYSIWYG editor that offers a plethora of customization options, making it ideal for various text editing tasks. Whether you're building a blog, a content management system, or simply need a more interactive text input for your Streamlit app, st-tiny-editor has you covered.

With st-tiny-editor, you can:

  • Enable Rich Text Editing: Allow users to format text with a variety of styles, fonts, colors, and more.
  • Insert Images and Media: Easily insert images and media files into the editor to enrich content.
  • Customize Toolbar and Plugins: Tailor the editor's toolbar and enable/disable plugins to suit your application's specific needs.
  • Control Editor Height and Styling: Adjust the editor's height and apply custom CSS styles to seamlessly integrate with your app's design.

Enhance your Streamlit applications with st-tiny-editor and empower your users with an intuitive and feature-rich text editing experience.

Installation

You can install st-tiny-editor via pip:

pip install st-tiny-editor

Usage

The tiny_editor function initializes a text editor with specified parameters and default values if not provided.

Parameters

  • apiKey (str, optional): Specifies an API key for authentication. If no apiKey is provided, certain features of the editor will be disabled.
  • initialValue (str, optional): Specifies the initial content to be displayed in the editor. Defaults to an empty string if not provided.
  • key (str, optional): Specifies a unique identifier for the editor instance. Useful when working with multiple editor instances on the same page.
  • height (int, optional): Specifies the height of the editor in pixels. Defaults to 200 if not provided.
  • menubar (bool, optional): Specifies whether the editor should display a menu bar. Defaults to False.
  • plugins (list of str, optional): Specifies a list of plugins that should be enabled in the editor. Defaults to a standard set of plugins.
  • toolbar (str, optional): Specifies the toolbar configuration for the editor. Defaults to a standard toolbar configuration.
  • content_style (str, optional): Specifies the CSS styles that should be applied to the editor content. Defaults to a standard style.
  • disabled (bool, optional): Specifies whether the editor should be disabled. Defaults to False.

For more information on available options, refer to the TinyMCE documentation.

Example

Here's an example demonstrating the usage of the tiny_editor function:

from st_tiny_editor import tiny_editor
import streamlit as st

# Initialize the TinyMCE editor
editor_content = tiny_editor(
    apiKey=st.secrets["TINY_API_KEY"],
    height=1000,
    initialValue="<p>Hello World</p>",
    toolbar='undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table | align lineheight | numlist bullist indent outdent | emoticons charmap | removeformat'
)

# Display the content entered in the editor
st.write(editor_content, unsafe_allow_html=True)

In this example, we initialize the TinyMCE editor with a specified API key, height, initial content, and custom toolbar configuration. The content entered by the user in the editor is then displayed using Streamlit's write function.

Development

To contribute to st-tiny-editor, follow these steps:

  1. Clone this repository: git clone https://github.com/your_username/st-tiny-editor
  2. Navigate to the repository: cd st-tiny-editor
  3. Install the required dependencies: pip install -r requirements.txt
  4. Navigate to the streamlit_tiny_editor directory: cd streamlit_tiny_editor
  5. Install Yarn if you haven't already: Yarn Installation Guide
  6. Install the frontend dependencies by running yarn install in the frontend directory.
  7. Make changes and test them.
  8. Submit a pull request!

License

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

Acknowledgements

  • Streamlit - For providing an amazing platform for building data apps.
  • TinyMCE - For the rich text editing capabilities.

Feel free to customize this README to better fit your package's features and requirements.

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-tiny-editor-1.0.3.tar.gz (424.2 kB view details)

Uploaded Source

Built Distribution

st_tiny_editor-1.0.3-py3-none-any.whl (426.1 kB view details)

Uploaded Python 3

File details

Details for the file st-tiny-editor-1.0.3.tar.gz.

File metadata

  • Download URL: st-tiny-editor-1.0.3.tar.gz
  • Upload date:
  • Size: 424.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.18

File hashes

Hashes for st-tiny-editor-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9605fec769c1f51d4a41c3910eab0bdd83ac736e08ccf584a79678cbc2ab8828
MD5 163b9ffd17d6e5d7f73adebbdcf8b1b8
BLAKE2b-256 3d63ecdc3a7040e597048a53d0298127d1ea878ef0f8073e2c818e0a24762210

See more details on using hashes here.

File details

Details for the file st_tiny_editor-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for st_tiny_editor-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 53b06c89476b4e30683e207ab0ab908731f0fd330f0fedc90b8e37b4e45c457e
MD5 b1ebd977b37457c1d97f1c29e3a32a04
BLAKE2b-256 dee92d555bf6ddd5182d94213d5188780b00a5895c87be13d5543bc711279e9a

See more details on using hashes here.

Supported by

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