From 4d139e5e45f591d4ed3a102ea3d0bf83f5dd8bbf Mon Sep 17 00:00:00 2001 From: Erik Brommers <1458944+eb1@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:58:22 -0700 Subject: [PATCH] Bump version, fix punctuation issue - New version 1.17.0 - Found a couple more places where punctuation wasn't being stripped out properly, leading to duplicate punctuation when the user moved the cursor. --- config.xml | 2 +- package.json | 2 +- www/js/Application.js | 2 +- www/js/views/AdaptViews.js | 24 +++++++++++++++--------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/config.xml b/config.xml index cedecf3a..406d1e82 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + Adapt It Mobile An open source application for translating between related languages. diff --git a/package.json b/package.json index df946b9c..e29724c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "adapt-it-mobile", - "version": "1.16.6", + "version": "1.17.0", "description": "Adapt It Mobile", "repository": { "type": "git", diff --git a/www/js/Application.js b/www/js/Application.js index 46982954..73f18f5c 100755 --- a/www/js/Application.js +++ b/www/js/Application.js @@ -79,7 +79,7 @@ define(function (require) { searchIndex: 0, currentProject: null, localURLs: [], - version: "1.16.6", // appended with Android / iOS build info + version: "1.17.0", // appended with Android / iOS build info AndroidBuild: "59", // (was milestone release #) iOSBuild: "1", // iOS uploaded build number for this release (increments from 1 for each release) importingURL: "", // for other apps in Android-land sending us files to import diff --git a/www/js/views/AdaptViews.js b/www/js/views/AdaptViews.js index df3439ec..a517c9a5 100644 --- a/www/js/views/AdaptViews.js +++ b/www/js/views/AdaptViews.js @@ -746,6 +746,10 @@ define(function (require) { // move to the next pile and append the source nextObj = thisObj.nextElementSibling; if (nextObj !== null) { + if ($(nextObj).children(".target").html().length > 0) { + // exit -- we hit some target text in our processing + break; + } tmpStr = sourceText + ONE_SPACE + $(nextObj).children(".source").html(); sourceText = this.stripPunctuation(this.autoRemoveCaps(tmpStr, true), true); // is there a match for this phrase? @@ -2182,7 +2186,7 @@ define(function (require) { $("#PrevSP").prop('disabled', false); // enable toolbar button $("#NextSP").prop('disabled', false); // enable toolbar button isEditing = true; - // Is this an auto-merge? + // auto-phrase (select and start typing) handling - target text is just whatever the user typed in. if (isAutoPhrase === true) { isAutoPhrase = false; // clear out flag // clear out the existing text (if any) @@ -2204,7 +2208,8 @@ define(function (require) { var e = jQuery.Event( "keydown", { keyCode: kbEvent.keyCode, key : kbEvent.key, code: kbEvent.code, shiftKey: kbEvent.shiftKey } ); $(event.currentTarget).trigger(e); kbEvent = null; // clear out event - return; // don't continue processing here + // we're done with auto-phrase processing -- exit + return; } // Is the target field empty? if ($(event.currentTarget).text().trim().length === 0) { @@ -2227,7 +2232,7 @@ define(function (require) { isMergingFromKB = false; } else { // check for a possible KB phrase that needs merging - if ((this.possibleKBPhrase(this.autoRemoveCaps(sourceText, true), 0) === true) && (selectedEnd === selectedStart)) { + if ((this.possibleKBPhrase(this.stripPunctuation(this.autoRemoveCaps(sourceText, true), true), 0) === true) && (selectedEnd === selectedStart)) { // we have a possible phrase -- see if it's a real one selectedEnd = this.findLargestPhrase(selectedStart, 0); if (selectedEnd !== selectedStart) { @@ -2239,7 +2244,7 @@ define(function (require) { } } } - tu = this.findInKB(this.autoRemoveCaps(sourceText, true), 0); + tu = this.findInKB(this.stripPunctuation(this.autoRemoveCaps(sourceText, true), true), 0); console.log("Target is empty; tu for \"" + this.autoRemoveCaps(sourceText, true) + "\" = " + tu); if (tu !== null) { // found at least one match -- populate the target with the first match @@ -2419,7 +2424,7 @@ define(function (require) { // skip the KB check if this is a retranslation or placeholder (there won't be a KB entry) if ((strID.indexOf("ret") === -1) && (strID.indexOf("plc") === -1)) { // not a retranslation or placeholder - tu = this.findInKB(this.autoRemoveCaps(sourceText, true), 0); + tu = this.findInKB(this.stripPunctuation(this.autoRemoveCaps(sourceText, true), true), 0); if (tu !== null) { refstrings = tu.get('refstring'); // first, make sure these refstrings are actually being used @@ -2557,7 +2562,8 @@ define(function (require) { strID = strID.substr(strID.indexOf("-") + 1); // remove "pile-" model = this.collection.findWhere({spid: strID}); sourceText = model.get('source'); - tu = this.findInKB(this.autoRemoveCaps(sourceText, true), 1); + // find in the glossing KB + tu = this.findInKB(this.stripPunctuation(this.autoRemoveCaps(sourceText, true), true), 1); console.log("Target is empty; tu for \"" + this.autoRemoveCaps(sourceText, true) + "\" = " + tu); if (tu !== null) { // found at least one match -- populate the target with the first match @@ -2734,8 +2740,8 @@ define(function (require) { sourceText = model.get('source'); // skip the KB check if this is a retranslation or placeholder (there won't be a KB entry) if ((strID.indexOf("ret") === -1) && (strID.indexOf("plc") === -1)) { - // not a retranslation or placeholder - tu = this.findInKB(this.autoRemoveCaps(sourceText, true), 1); + // find in the glossing KB + tu = this.findInKB(this.stripPunctuation(this.autoRemoveCaps(sourceText, true), true), 1); if (tu !== null) { refstrings = tu.get('refstring'); // first, make sure these refstrings are actually being used @@ -2994,7 +3000,7 @@ define(function (require) { model = this.collection.findWhere({spid: strID}); // re-add autocaps if necessary if (trimmedValue.length > 0) { - trimmedValue = this.autoAddCaps(model, trimmedValue); + trimmedValue = this.stripPunctuation(this.autoAddCaps(model, trimmedValue), false); } // check for changes in the edit field isEditing = false;