Hi, I'm trying get the updated contents of an editable CodeBlock, when it is updated, with no luck. I've tried with and without an enclosing Form tag. I've also tried getting content from body and from the form request, same result. With TextArea is working as expected.
Below is a sample code to reproduce the issue:
from fasthtml.common import *
from monsterui.all import *
app, rt = fast_app(hdrs=Theme.blue.headers())
@rt
def index():
return DivHStacked(
Div(
TextArea(
"Initial area here",
id="area-editor",
name="text-editor",
hx_post="/save-code",
hx_trigger="change, keyup delay:500ms changed",
)
),
Form(
CodeBlock(
"Initial code here",
contenteditable="true",
spellcheck=False,
id="code-editor",
name="text-editor",
hx_post="/save-code",
hx_trigger="keyup delay:500ms"
),
)
)
@rt("/save-code")
async def post(req):
form = await req.form()
print("FORM:", form)
code = form.get("text-editor")
# # body = await req.body()
# # code = body.decode('utf-8')
print("CODE:", code)
return f"{code} Saved!"
serve()
Hi, I'm trying get the updated contents of an editable CodeBlock, when it is updated, with no luck. I've tried with and without an enclosing Form tag. I've also tried getting content from body and from the form request, same result. With TextArea is working as expected.
Below is a sample code to reproduce the issue: