Update jquery.ime from upstream

Update to:
35c7df6049

jquery.uls was updated in I245b4dd68151d9d680368d0cc5750cee4a167f50

Bug: T355104
Change-Id: I49d806c8fbfbede0e8071d31eec39099ed63d1d2
This commit is contained in:
Abijeet
2024-01-22 14:56:16 +05:30
committed by jenkins-bot
parent 48de278a85
commit 46d59295c8
7 changed files with 27 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
/*! jquery.ime - v0.2.0+20231025
/*! jquery.ime - v0.2.0+20240122
* https://github.com/wikimedia/jquery.ime
* Copyright (c) 2023 Santhosh Thottingal; License: (GPL-2.0-or-later OR MIT) */
* Copyright (c) 2024 Santhosh Thottingal; License: (GPL-2.0-or-later OR MIT) */
( function ( $ ) {
'use strict';
@@ -163,12 +163,12 @@
* @param {string} input
* @param {string} context
* @param {boolean} altGr whether altGr key is pressed or not
* @return {Object} Transliteration object
* @return {boolean} return.noop Whether to consider input processed or passed through.
* @return {string} return.output The transliterated input or input unmodified.
* @return {Object} Transliteration object, with the following fields:
* "noop": boolean, whether to consider input processed or passed through;
* "output": string, the transliterated input or input unmodified.
*/
transliterate: function ( input, context, altGr ) {
var patterns, regex, rule, replacement, i, retval;
var patterns, regex, contextRegex, rule, replacement, i, retval;
if ( altGr ) {
patterns = this.inputmethod.patterns_x || [];
@@ -198,6 +198,7 @@
for ( i = 0; i < patterns.length; i++ ) {
rule = patterns[ i ];
// eslint-disable-next-line security/detect-non-literal-regexp
regex = new RegExp( rule[ 0 ] + '$' );
// Last item in the rules.
@@ -209,7 +210,9 @@
if ( regex.test( input ) ) {
// Context test required?
if ( rule.length === 3 ) {
if ( new RegExp( rule[ 1 ] + '$' ).test( context ) ) {
// eslint-disable-next-line security/detect-non-literal-regexp
contextRegex = new RegExp( rule[ 1 ] + '$' );
if ( contextRegex.test( context ) ) {
return { noop: false, output: input.replace( regex, replacement ) };
}
} else {
@@ -285,7 +288,7 @@
if ( this.context.length > this.inputmethod.contextLength ) {
// The buffer is longer than needed, truncate it at the front
this.context = this.context.substring(
this.context = this.context.slice(
this.context.length - this.inputmethod.contextLength
);
}
@@ -358,7 +361,6 @@
* Set the current input method
*
* @param {string} inputmethodId
* @fires imeLanguageChange
*/
setIM: function ( inputmethodId ) {
this.inputmethod = $.ime.inputmethods[ inputmethodId ];
@@ -370,7 +372,6 @@
* Set the current Language
*
* @param {string} languageCode
* @fires imeLanguageChange
* @return {boolean}
*/
setLanguage: function ( languageCode ) {
@@ -534,7 +535,7 @@
*/
FormWidgetEntry.prototype.getTextBeforeSelection = function ( maxLength ) {
var element = this.$element.get( 0 );
return this.$element.val().substring(
return this.$element.val().slice(
Math.max( 0, element.selectionStart - maxLength ),
element.selectionStart
);
@@ -554,9 +555,9 @@
// But for complex scripts, browsers place cursor in unexpected places
// and it's not possible to fix cursor programmatically.
// Ref Bug https://bugs.webkit.org/show_bug.cgi?id=66630
element.value = element.value.substring( 0, start - precedingCharCount ) +
element.value = element.value.slice( 0, start - precedingCharCount ) +
newText +
element.value.substring( element.selectionEnd, element.value.length );
element.value.slice( element.selectionEnd, element.value.length );
// Emit an event so that input fields that rely on events
// work properly
@@ -604,7 +605,7 @@
if ( !range || !range.collapsed || range.startContainer.nodeType !== Node.TEXT_NODE ) {
return '';
}
return range.startContainer.nodeValue.substring(
return range.startContainer.nodeValue.slice(
Math.max( 0, range.startOffset - maxLength ),
range.startOffset
);
@@ -641,9 +642,9 @@
textNode = range.startContainer;
textOffset = range.startOffset;
textNode.nodeValue =
textNode.nodeValue.substr( 0, textOffset - precedingCharCount ) +
textNode.nodeValue.slice( 0, Math.max( 0, textOffset - precedingCharCount ) ) +
newText +
textNode.nodeValue.substr( textOffset );
textNode.nodeValue.slice( textOffset );
newOffset = textOffset - precedingCharCount + newText.length;
newRange.setStart( range.startContainer, newOffset );
newRange.setEnd( range.startContainer, newOffset );
@@ -1068,7 +1069,6 @@
/**
* Keydown event handler. Handles shortcut key presses
*
* @this HTMLElement
* @param {jQuery.Event} e
* @return {boolean}
*/

View File

@@ -74,7 +74,7 @@ Any valid regular expression is possible as first element of each array item.
ex: `[ '([ക-ഹ])a', '$1ാ' ]`
ex: `[ '(([ൺ-ൿം])\u200c+)?I', '$2ഐ' ]`
In the above example, $1, $1 etc are according to the normal regular expression
In the above example, $1, $2 etc are according to the normal regular expression
replace syntax.
The second member of the pattern can be a function as well.

View File

@@ -66,7 +66,7 @@
[ 'V', '᯦' ],
[ 'B', 'ᯆ' ],
[ 'N', 'ᯊ' ],
[ 'M', 'ᯕ' ],
[ 'M', 'ᯕ' ]
],
patterns_x: [
[ '4', '᯼' ],

View File

@@ -61,6 +61,7 @@
maxKeyLength: 5,
patterns: [
/* eslint-disable max-statements-per-line */
/* eslint-disable brace-style */
[ ' ', function () { reinit(); return '་'; } ],
[ '\\.', function () { reinit(); return ' '; } ],
[ ',', function () { reinit(); return '།'; } ],
@@ -183,6 +184,7 @@
[ '8', function () { reinit(); return '༨'; } ],
[ '9', function () { reinit(); return '༩'; } ]
/* eslint-enable max-statements-per-line */
/* eslint-enable brace-style */
]
};

View File

@@ -1,4 +1,4 @@
( function ( $ ) {
( function ( $ ) {
'use strict';
var mandailingTransliteration = {

View File

@@ -1,4 +1,4 @@
( function ( $ ) {
( function ( $ ) {
'use strict';
var jvKeyboard = {

View File

@@ -1,4 +1,4 @@
( function ( $ ) {
( function ( $ ) {
'use strict';
var suKeyboard = {