streamlit-lexical 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit_lexical-0.0.1/LICENSE +19 -0
- streamlit_lexical-0.0.1/MANIFEST.in +1 -0
- streamlit_lexical-0.0.1/PKG-INFO +44 -0
- streamlit_lexical-0.0.1/README.md +25 -0
- streamlit_lexical-0.0.1/setup.cfg +4 -0
- streamlit_lexical-0.0.1/setup.py +37 -0
- streamlit_lexical-0.0.1/streamlit_lexical/__init__.py +72 -0
- streamlit_lexical-0.0.1/streamlit_lexical/example.py +29 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/asset-manifest.json +18 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/bootstrap.min.css +9501 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/index.html +1 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/css/main.b0581e46.css +2 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/css/main.b0581e46.css.map +1 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/js/main.1d3f0525.js +3 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/js/main.1d3f0525.js.LICENSE.txt +72 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/js/main.1d3f0525.js.map +1 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/media/arrow-clockwise.2ba775456dd603357519.svg +4 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/media/arrow-counterclockwise.48745dc8e6d9b1a2f8ec.svg +4 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/media/type-bold.b3bec3f33045771f9484.svg +3 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/media/type-italic.d3971b39b0fe39a09b1b.svg +3 -0
- streamlit_lexical-0.0.1/streamlit_lexical/frontend/build/static/media/type-underline.b41f84ace38d530f30b9.svg +3 -0
- streamlit_lexical-0.0.1/streamlit_lexical.egg-info/PKG-INFO +44 -0
- streamlit_lexical-0.0.1/streamlit_lexical.egg-info/SOURCES.txt +24 -0
- streamlit_lexical-0.0.1/streamlit_lexical.egg-info/dependency_links.txt +1 -0
- streamlit_lexical-0.0.1/streamlit_lexical.egg-info/requires.txt +9 -0
- streamlit_lexical-0.0.1/streamlit_lexical.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018-2021 Streamlit Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include streamlit_lexical/frontend/build *
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: streamlit_lexical
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Streamlit component that allows you to do use Lexical's rich text editor
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: Ben Fox
|
|
7
|
+
Author-email: ben@musubilabs.ai
|
|
8
|
+
Requires-Python: >=3.7
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: streamlit==1.36.0
|
|
12
|
+
Provides-Extra: devel
|
|
13
|
+
Requires-Dist: wheel; extra == "devel"
|
|
14
|
+
Requires-Dist: pytest==7.4.0; extra == "devel"
|
|
15
|
+
Requires-Dist: playwright==1.39.0; extra == "devel"
|
|
16
|
+
Requires-Dist: requests==2.31.0; extra == "devel"
|
|
17
|
+
Requires-Dist: pytest-playwright-snapshot==1.0; extra == "devel"
|
|
18
|
+
Requires-Dist: pytest-rerunfailures==12.0; extra == "devel"
|
|
19
|
+
|
|
20
|
+
# streamlit_lexical
|
|
21
|
+
|
|
22
|
+
Streamlit component that allows you to use Lexical's rich text plugin.
|
|
23
|
+
|
|
24
|
+
## Installation instructions
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
cd streamlit_lexical/frontend
|
|
28
|
+
npm install (or yarn install)
|
|
29
|
+
npm run build
|
|
30
|
+
cd ../..
|
|
31
|
+
pip install -e ./
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage instructions
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import streamlit as st
|
|
38
|
+
|
|
39
|
+
from streamlit_lexical import streamlit_lexical
|
|
40
|
+
|
|
41
|
+
rich_text_dict = streamlit_lexical("name")
|
|
42
|
+
|
|
43
|
+
st.markdown(rich_text_dict)
|
|
44
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# streamlit_lexical
|
|
2
|
+
|
|
3
|
+
Streamlit component that allows you to use Lexical's rich text plugin.
|
|
4
|
+
|
|
5
|
+
## Installation instructions
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
cd streamlit_lexical/frontend
|
|
9
|
+
npm install (or yarn install)
|
|
10
|
+
npm run build
|
|
11
|
+
cd ../..
|
|
12
|
+
pip install -e ./
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage instructions
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import streamlit as st
|
|
19
|
+
|
|
20
|
+
from streamlit_lexical import streamlit_lexical
|
|
21
|
+
|
|
22
|
+
rich_text_dict = streamlit_lexical("name")
|
|
23
|
+
|
|
24
|
+
st.markdown(rich_text_dict)
|
|
25
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import setuptools
|
|
4
|
+
|
|
5
|
+
this_directory = Path(__file__).parent
|
|
6
|
+
long_description = (this_directory / "README.md").read_text()
|
|
7
|
+
|
|
8
|
+
setuptools.setup(
|
|
9
|
+
name="streamlit_lexical",
|
|
10
|
+
version="0.0.1",
|
|
11
|
+
author="Ben Fox",
|
|
12
|
+
author_email="ben@musubilabs.ai",
|
|
13
|
+
description="Streamlit component that allows you to do use Lexical's rich text editor",
|
|
14
|
+
long_description=long_description,
|
|
15
|
+
long_description_content_type="text/markdown",
|
|
16
|
+
url="",
|
|
17
|
+
packages=setuptools.find_packages(),
|
|
18
|
+
include_package_data=True,
|
|
19
|
+
classifiers=[],
|
|
20
|
+
python_requires=">=3.7",
|
|
21
|
+
install_requires=[
|
|
22
|
+
# By definition, a Custom Component depends on Streamlit.
|
|
23
|
+
# If your component has other Python dependencies, list
|
|
24
|
+
# them here.
|
|
25
|
+
"streamlit == 1.36.0",
|
|
26
|
+
],
|
|
27
|
+
extras_require={
|
|
28
|
+
"devel": [
|
|
29
|
+
"wheel",
|
|
30
|
+
"pytest==7.4.0",
|
|
31
|
+
"playwright==1.39.0",
|
|
32
|
+
"requests==2.31.0",
|
|
33
|
+
"pytest-playwright-snapshot==1.0",
|
|
34
|
+
"pytest-rerunfailures==12.0",
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import streamlit.components.v1 as components
|
|
3
|
+
|
|
4
|
+
# Create a _RELEASE constant. We'll set this to False while we're developing
|
|
5
|
+
# the component, and True when we're ready to package and distribute it.
|
|
6
|
+
# (This is, of course, optional - there are innumerable ways to manage your
|
|
7
|
+
# release process.)
|
|
8
|
+
_RELEASE = True
|
|
9
|
+
# Declare a Streamlit component. `declare_component` returns a function
|
|
10
|
+
# that is used to create instances of the component. We're naming this
|
|
11
|
+
# function "_component_func", with an underscore prefix, because we don't want
|
|
12
|
+
# to expose it directly to users. Instead, we will create a custom wrapper
|
|
13
|
+
# function, below, that will serve as our component's public API.
|
|
14
|
+
|
|
15
|
+
# It's worth noting that this call to `declare_component` is the
|
|
16
|
+
# *only thing* you need to do to create the binding between Streamlit and
|
|
17
|
+
# your component frontend. Everything else we do in this file is simply a
|
|
18
|
+
# best practice.
|
|
19
|
+
|
|
20
|
+
if not _RELEASE:
|
|
21
|
+
_component_func = components.declare_component(
|
|
22
|
+
# We give the component a simple, descriptive name ("my_component"
|
|
23
|
+
# does not fit this bill, so please choose something better for your
|
|
24
|
+
# own component :)
|
|
25
|
+
"streamlit_lexical",
|
|
26
|
+
# Pass `url` here to tell Streamlit that the component will be served
|
|
27
|
+
# by the local dev server that you run via `npm run start`.
|
|
28
|
+
# (This is useful while your component is in development.)
|
|
29
|
+
url="http://localhost:3001",
|
|
30
|
+
)
|
|
31
|
+
else:
|
|
32
|
+
# When we're distributing a production version of the component, we'll
|
|
33
|
+
# replace the `url` param with `path`, and point it to the component's
|
|
34
|
+
# build directory:
|
|
35
|
+
parent_dir = os.path.dirname(os.path.abspath(__file__))
|
|
36
|
+
build_dir = os.path.join(parent_dir, "frontend/build")
|
|
37
|
+
_component_func = components.declare_component("streamlit_lexical", path=build_dir)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Create a wrapper function for the component. This is an optional
|
|
41
|
+
# best practice - we could simply expose the component function returned by
|
|
42
|
+
# `declare_component` and call it done. The wrapper allows us to customize
|
|
43
|
+
# our component's API: we can pre-process its input args, post-process its
|
|
44
|
+
# output value, and add a docstring for users.
|
|
45
|
+
def streamlit_lexical(height=960, value="", placeholder="", debounce=500, key=None, on_change=None):
|
|
46
|
+
"""Create a new instance of "streamlit_lexical".
|
|
47
|
+
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
height: int
|
|
51
|
+
Optional specification for height, in pixels of lexical text box.
|
|
52
|
+
value: str
|
|
53
|
+
Optional initial value to pass to editor
|
|
54
|
+
placeholder: str
|
|
55
|
+
Optional initial placeholder text to display in editor
|
|
56
|
+
debounce:
|
|
57
|
+
Time delay to save editor contents. Default is 500 ms/
|
|
58
|
+
key: str or None
|
|
59
|
+
An optional key that uniquely identifies this component. If this is
|
|
60
|
+
None, and the component's arguments are changed, the component will
|
|
61
|
+
be re-mounted in the Streamlit frontend and lose its current state.
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
str
|
|
66
|
+
Markdown string of content in editor
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
assert debounce > 0, "Debounce must be greater than 0."
|
|
70
|
+
assert height > 0, "The min_height must be greater than 0."
|
|
71
|
+
component_value = _component_func(min_height=height, key=key, value=value, placeholder=placeholder, debounce=debounce, on_change=on_change)
|
|
72
|
+
return component_value
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import streamlit as st
|
|
2
|
+
from __init__ import streamlit_lexical
|
|
3
|
+
# Add some test code to play with the component while it's in development.
|
|
4
|
+
# During development, we can run this just as we would any other Streamlit
|
|
5
|
+
# app: `$ streamlit run my_component/example.py`
|
|
6
|
+
def update_val():
|
|
7
|
+
new_content = "# New Heading\n\nThis is updated content in **Markdown**."
|
|
8
|
+
st.session_state['key'] = new_content
|
|
9
|
+
|
|
10
|
+
st.write("#") # if this isnt here, for some reason, if you change the heading prior to entering any text, the page jumps to the bottom
|
|
11
|
+
st.header("Lexical Rich Text Editor")
|
|
12
|
+
|
|
13
|
+
if st.session_state.get('key') is None:
|
|
14
|
+
st.session_state['key'] = 'initial value'
|
|
15
|
+
|
|
16
|
+
# Create an instance of our component with a constant `name` arg, and
|
|
17
|
+
markdown = streamlit_lexical(value=st.session_state.get('key'), placeholder="Enter some rich text", key='1234', height=800)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Button to update content
|
|
21
|
+
st.button("Update Editor Content", on_click=update_val)
|
|
22
|
+
|
|
23
|
+
#markdown = streamlit_lexical(value=new_content, placeholder="Enter some rich text", height=800)
|
|
24
|
+
|
|
25
|
+
#st.markdown(markdown)
|
|
26
|
+
#markdown = streamlit_lexical(value="", placeholder="Enter some rich text", height=800, on_change=None)
|
|
27
|
+
|
|
28
|
+
st.markdown(markdown)
|
|
29
|
+
st.markdown("---")
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": {
|
|
3
|
+
"main.css": "./static/css/main.b0581e46.css",
|
|
4
|
+
"main.js": "./static/js/main.1d3f0525.js",
|
|
5
|
+
"index.html": "./index.html",
|
|
6
|
+
"static/media/type-bold.svg": "./static/media/type-bold.b3bec3f33045771f9484.svg",
|
|
7
|
+
"static/media/arrow-counterclockwise.svg": "./static/media/arrow-counterclockwise.48745dc8e6d9b1a2f8ec.svg",
|
|
8
|
+
"static/media/arrow-clockwise.svg": "./static/media/arrow-clockwise.2ba775456dd603357519.svg",
|
|
9
|
+
"static/media/type-italic.svg": "./static/media/type-italic.d3971b39b0fe39a09b1b.svg",
|
|
10
|
+
"static/media/type-underline.svg": "./static/media/type-underline.b41f84ace38d530f30b9.svg",
|
|
11
|
+
"main.b0581e46.css.map": "./static/css/main.b0581e46.css.map",
|
|
12
|
+
"main.1d3f0525.js.map": "./static/js/main.1d3f0525.js.map"
|
|
13
|
+
},
|
|
14
|
+
"entrypoints": [
|
|
15
|
+
"static/css/main.b0581e46.css",
|
|
16
|
+
"static/js/main.1d3f0525.js"
|
|
17
|
+
]
|
|
18
|
+
}
|