mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-21 23:01:00 +00:00
Fix wrong post character counting in hyperscript (#476)
A newline `\n` will be normalized as `\r\n` in Django.
This commit is contained in:
parent
653ab07fd6
commit
8a06b3d78f
1 changed files with 3 additions and 2 deletions
|
@ -59,7 +59,7 @@ class Compose(FormView):
|
|||
self.request = request
|
||||
self.fields["text"].widget.attrs[
|
||||
"_"
|
||||
] = f"""
|
||||
] = rf"""
|
||||
init
|
||||
-- Move cursor to the end of existing text
|
||||
set my.selectionStart to my.value.length
|
||||
|
@ -67,7 +67,8 @@ class Compose(FormView):
|
|||
|
||||
on load or input
|
||||
-- Unicode-aware counting to match Python
|
||||
set characters to Array.from(my.value.trim()).length
|
||||
-- <LF> will be normalized as <CR><LF> in Django
|
||||
set characters to Array.from(my.value.replaceAll('\n','\r\n').trim()).length
|
||||
put {Config.system.post_length} - characters into #character-counter
|
||||
|
||||
if characters > {Config.system.post_length} then
|
||||
|
|
Loading…
Reference in a new issue