Update jquery.ime from upstream
Update to:
35c7df6049
jquery.uls was updated in I245b4dd68151d9d680368d0cc5750cee4a167f50
Bug: T355104
Change-Id: I49d806c8fbfbede0e8071d31eec39099ed63d1d2
This commit is contained in:
@@ -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}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user