Spaces:
Runtime error
Runtime error
Commit
·
9dac049
1
Parent(s):
bb6b6cc
Update app.py
Browse files
app.py
CHANGED
@@ -120,32 +120,74 @@ def form_page():
|
|
120 |
st.session_state.form = False
|
121 |
st.experimental_rerun()
|
122 |
|
|
|
|
|
123 |
# def editor_page():
|
|
|
|
|
|
|
124 |
# st.write("Use the editor below to edit the obituary:")
|
|
|
|
|
125 |
# quill_text = st.session_state.output_text
|
126 |
# edited_text = st_quill(quill_text)
|
|
|
|
|
127 |
# st.write("Here is the edited obituary:")
|
128 |
-
# st.write(edited_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
def editor_page():
|
131 |
-
#st.markdown("### Editor :smile:")
|
132 |
st.markdown("<h1 style='text-align: center; color: Red;'>Editor</h1>", unsafe_allow_html=True)
|
133 |
|
134 |
st.write("Use the editor below to edit the obituary:")
|
135 |
|
|
|
|
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
140 |
|
141 |
st.write("Here is the edited obituary:")
|
142 |
-
|
143 |
|
144 |
-
|
|
|
145 |
|
146 |
if st.button("Save as PDF"):
|
147 |
-
|
148 |
-
#save_as_pdf(st.session_state.output_text)
|
149 |
save_as_pdf(st.session_state.edited_text)
|
150 |
st.write("The custom obituary has been saved as a PDF.")
|
151 |
|
|
|
120 |
st.session_state.form = False
|
121 |
st.experimental_rerun()
|
122 |
|
123 |
+
|
124 |
+
|
125 |
# def editor_page():
|
126 |
+
# #st.markdown("### Editor :smile:")
|
127 |
+
# st.markdown("<h1 style='text-align: center; color: Red;'>Editor</h1>", unsafe_allow_html=True)
|
128 |
+
|
129 |
# st.write("Use the editor below to edit the obituary:")
|
130 |
+
|
131 |
+
|
132 |
# quill_text = st.session_state.output_text
|
133 |
# edited_text = st_quill(quill_text)
|
134 |
+
|
135 |
+
|
136 |
# st.write("Here is the edited obituary:")
|
137 |
+
# #st.write(edited_text)
|
138 |
+
|
139 |
+
# st.session_state.edited_text= edited_text
|
140 |
+
|
141 |
+
# if st.button("Save as PDF"):
|
142 |
+
# # Save the output text as a PDF
|
143 |
+
# #save_as_pdf(st.session_state.output_text)
|
144 |
+
# save_as_pdf(st.session_state.edited_text)
|
145 |
+
# st.write("The custom obituary has been saved as a PDF.")
|
146 |
+
|
147 |
+
# # Add some custom CSS to style the editor
|
148 |
+
# st.markdown("""
|
149 |
+
# <style>
|
150 |
+
# #toolbar {
|
151 |
+
# background-color: #f3f3f3;
|
152 |
+
# border-radius: 5px;
|
153 |
+
# padding: 5px;
|
154 |
+
# }
|
155 |
+
# .ql-container {
|
156 |
+
# border-radius: 5px;
|
157 |
+
# border: 1px solid #ccc;
|
158 |
+
# height: 400px;
|
159 |
+
# }
|
160 |
+
# .ql-editor {
|
161 |
+
# height: 100%;
|
162 |
+
# }
|
163 |
+
# </style>
|
164 |
+
# """, unsafe_allow_html=True)
|
165 |
+
|
166 |
+
|
167 |
+
from quill.delta import Delta, Renderer
|
168 |
|
169 |
def editor_page():
|
|
|
170 |
st.markdown("<h1 style='text-align: center; color: Red;'>Editor</h1>", unsafe_allow_html=True)
|
171 |
|
172 |
st.write("Use the editor below to edit the obituary:")
|
173 |
|
174 |
+
# Get the initial text to be edited
|
175 |
+
initial_text = st.session_state.output_text
|
176 |
|
177 |
+
# Create a Delta object from the edited text
|
178 |
+
edited_delta = Delta(st.text_input("Edited text", value=initial_text))
|
179 |
+
|
180 |
+
# Render the Delta object using the Renderer class
|
181 |
+
edited_html = Renderer().render(edited_delta)
|
182 |
|
183 |
st.write("Here is the edited obituary:")
|
184 |
+
st.write(edited_html, unsafe_allow_html=True)
|
185 |
|
186 |
+
# Store the edited text in session state
|
187 |
+
st.session_state.edited_text = edited_html
|
188 |
|
189 |
if st.button("Save as PDF"):
|
190 |
+
# Save the edited text as a PDF
|
|
|
191 |
save_as_pdf(st.session_state.edited_text)
|
192 |
st.write("The custom obituary has been saved as a PDF.")
|
193 |
|