Fix wrong post character counting in hyperscript (#476)

A newline `\n` will be normalized as `\r\n` in Django.
pull/477/head
TAKAHASHI Shuuji 2023-01-28 02:50:34 +09:00 zatwierdzone przez GitHub
rodzic 653ab07fd6
commit 8a06b3d78f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -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