1
1
/*
2
- Trix 2.1.7
2
+ Trix 2.1.8
3
3
Copyright © 2024 37signals, LLC
4
4
*/
5
5
( function ( global , factory ) {
@@ -9,7 +9,7 @@ Copyright © 2024 37signals, LLC
9
9
} ) ( this , ( function ( ) { 'use strict' ;
10
10
11
11
var name = "trix" ;
12
- var version = "2.1.7 " ;
12
+ var version = "2.1.8 " ;
13
13
var description = "A rich text editor for everyday writing" ;
14
14
var main = "dist/trix.umd.min.js" ;
15
15
var module = "dist/trix.esm.min.js" ;
@@ -1089,6 +1089,19 @@ $\
1089
1089
return event => event . ctrlKey ;
1090
1090
}
1091
1091
} ( ) ;
1092
+ function shouldRenderInmmediatelyToDealWithIOSDictation ( inputEvent ) {
1093
+ if ( / i P h o n e | i P a d / . test ( navigator . userAgent ) ) {
1094
+ // Handle garbled content and duplicated newlines when using dictation on iOS 18+. Upon dictation completion, iOS sends
1095
+ // the list of insertText / insertParagraph events in a quick sequence. If we don't render
1096
+ // the editor synchronously, the internal range fails to update and results in garbled content or duplicated newlines.
1097
+ //
1098
+ // This workaround is necessary because iOS doesn't send composing events as expected while dictating:
1099
+ // https://bugs.webkit.org/show_bug.cgi?id=261764
1100
+ return ! inputEvent . inputType || inputEvent . inputType === "insertParagraph" ;
1101
+ } else {
1102
+ return false ;
1103
+ }
1104
+ }
1092
1105
1093
1106
const defer = fn => setTimeout ( fn , 1 ) ;
1094
1107
@@ -10651,14 +10664,15 @@ $\
10651
10664
} ,
10652
10665
beforeinput ( event ) {
10653
10666
const handler = this . constructor . inputTypes [ event . inputType ] ;
10654
-
10655
- // Handles bug with Siri dictation on iOS 18+.
10656
- if ( ! event . inputType ) {
10657
- this . render ( ) ;
10658
- }
10667
+ const immmediateRender = shouldRenderInmmediatelyToDealWithIOSDictation ( event ) ;
10659
10668
if ( handler ) {
10660
10669
this . withEvent ( event , handler ) ;
10661
- this . scheduleRender ( ) ;
10670
+ if ( ! immmediateRender ) {
10671
+ this . scheduleRender ( ) ;
10672
+ }
10673
+ }
10674
+ if ( immmediateRender ) {
10675
+ this . render ( ) ;
10662
10676
}
10663
10677
} ,
10664
10678
input ( event ) {
0 commit comments