Merge pull request #1862 from ONLYOFFICE/fix/fix-bugs

Fix/fix bugs
This commit is contained in:
Julia Radzhabova 2022-07-19 21:17:34 +03:00 committed by GitHub
commit 13df97c68f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 5 deletions

View file

@ -91,6 +91,11 @@ define([
dataHintDirection: 'left', dataHintDirection: 'left',
dataHintOffset: 'small' dataHintOffset: 'small'
}); });
this.inputReplace._input.on('keydown', _.bind(function (e) {
if (e.keyCode === Common.UI.Keys.RETURN && !this.btnReplace.isDisabled()) {
this.onReplaceClick('replace');
}
}, this));
this.btnBack = new Common.UI.Button({ this.btnBack = new Common.UI.Button({
parentEl: $('#search-adv-back'), parentEl: $('#search-adv-back'),

View file

@ -107,6 +107,7 @@ define([
this.api.asc_registerCallback('asc_onGetTextAroundSearchPack', _.bind(this.onApiGetTextAroundSearch, this)); this.api.asc_registerCallback('asc_onGetTextAroundSearchPack', _.bind(this.onApiGetTextAroundSearch, this));
this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this)); this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this));
this.api.asc_registerCallback('asc_onSearchEnd', _.bind(this.onApiSearchEnd, this)); this.api.asc_registerCallback('asc_onSearchEnd', _.bind(this.onApiSearchEnd, this));
this.api.asc_registerCallback('asc_onReplaceAll', _.bind(this.onApiTextReplaced, this));
} }
return this; return this;
}, },
@ -367,7 +368,8 @@ define([
viewport.searchBar.hide(); viewport.searchBar.hide();
} }
var text = typeof findText === 'string' ? findText : (this.api.asc_GetSelectedText() || this._state.searchText); var selectedText = this.api.asc_GetSelectedText(),
text = typeof findText === 'string' ? findText : (selectedText && selectedText.trim() || this._state.searchText);
if (this.resultItems && this.resultItems.length > 0 && if (this.resultItems && this.resultItems.length > 0 &&
(!this._state.matchCase && text && text.toLowerCase() === this.view.inputText.getValue().toLowerCase() || (!this._state.matchCase && text && text.toLowerCase() === this.view.inputText.getValue().toLowerCase() ||
this._state.matchCase && text === this.view.inputText.getValue())) { // show old results this._state.matchCase && text === this.view.inputText.getValue())) { // show old results
@ -432,8 +434,21 @@ define([
this.removeResultItems('stop'); this.removeResultItems('stop');
}, },
onApiTextReplaced: function(found, replaced) {
if (found) {
!(found - replaced > 0) ?
Common.UI.info( {msg: Common.Utils.String.format(this.textReplaceSuccess, replaced)} ) :
Common.UI.warning( {msg: Common.Utils.String.format(this.textReplaceSkipped, found-replaced)} );
} else {
Common.UI.info({msg: this.textNoTextFound});
}
},
notcriticalErrorTitle: 'Warning', notcriticalErrorTitle: 'Warning',
warnReplaceString: '{0} is not a valid special character for the Replace With box.' warnReplaceString: '{0} is not a valid special character for the Replace With box.',
textReplaceSuccess: 'Search has been done. {0} occurrences have been replaced',
textReplaceSkipped: 'The replacement has been made. {0} occurrences were skipped.',
textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.'
}, DE.Controllers.Search || {})); }, DE.Controllers.Search || {}));
}); });

View file

@ -936,6 +936,9 @@
"DE.Controllers.Navigation.txtGotoBeginning": "Go to the beginning of the document", "DE.Controllers.Navigation.txtGotoBeginning": "Go to the beginning of the document",
"DE.Controllers.Search.notcriticalErrorTitle": "Warning", "DE.Controllers.Search.notcriticalErrorTitle": "Warning",
"DE.Controllers.Search.warnReplaceString": "{0} is not a valid special character for the Replace With box.", "DE.Controllers.Search.warnReplaceString": "{0} is not a valid special character for the Replace With box.",
"DE.Controllers.Search.textReplaceSuccess": "Search has been done. {0} occurrences have been replaced",
"DE.Controllers.Search.textReplaceSkipped": "The replacement has been made. {0} occurrences were skipped.",
"DE.Controllers.Search.textNoTextFound": "The data you have been searching for could not be found. Please adjust your search options.",
"DE.Controllers.Statusbar.textDisconnect": "<b>Connection is lost</b><br>Trying to connect. Please check connection settings.", "DE.Controllers.Statusbar.textDisconnect": "<b>Connection is lost</b><br>Trying to connect. Please check connection settings.",
"DE.Controllers.Statusbar.textHasChanges": "New changes have been tracked", "DE.Controllers.Statusbar.textHasChanges": "New changes have been tracked",
"DE.Controllers.Statusbar.textSetTrackChanges": "You are in Track Changes mode", "DE.Controllers.Statusbar.textSetTrackChanges": "You are in Track Changes mode",

View file

@ -104,6 +104,7 @@ define([
this.api.asc_registerCallback('asc_onGetTextAroundSearchPack', _.bind(this.onApiGetTextAroundSearch, this)); this.api.asc_registerCallback('asc_onGetTextAroundSearchPack', _.bind(this.onApiGetTextAroundSearch, this));
this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this)); this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this));
this.api.asc_registerCallback('asc_onSearchEnd', _.bind(this.onApiSearchEnd, this)); this.api.asc_registerCallback('asc_onSearchEnd', _.bind(this.onApiSearchEnd, this));
this.api.asc_registerCallback('asc_onReplaceAll', _.bind(this.onApiTextReplaced, this));
} }
return this; return this;
}, },
@ -336,7 +337,8 @@ define([
viewport.searchBar.hide(); viewport.searchBar.hide();
} }
var text = typeof findText === 'string' ? findText : (this.api.asc_GetSelectedText() || this._state.searchText); var selectedText = this.api.asc_GetSelectedText(),
text = typeof findText === 'string' ? findText : (selectedText && selectedText.trim() || this._state.searchText);
if (text) { if (text) {
this.view.setFindText(text); this.view.setFindText(text);
} else if (text !== undefined) { // panel was opened from empty searchbar, clear to start new search } else if (text !== undefined) { // panel was opened from empty searchbar, clear to start new search
@ -385,8 +387,21 @@ define([
this.removeResultItems('stop'); this.removeResultItems('stop');
}, },
onApiTextReplaced: function(found, replaced) {
if (found) {
!(found - replaced > 0) ?
Common.UI.info( {msg: Common.Utils.String.format(this.textReplaceSuccess, replaced)} ) :
Common.UI.warning( {msg: Common.Utils.String.format(this.textReplaceSkipped, found-replaced)} );
} else {
Common.UI.info({msg: this.textNoTextFound});
}
},
notcriticalErrorTitle: 'Warning', notcriticalErrorTitle: 'Warning',
warnReplaceString: '{0} is not a valid special character for the Replace With box.' warnReplaceString: '{0} is not a valid special character for the Replace With box.',
textReplaceSuccess: 'Search has been done. {0} occurrences have been replaced',
textReplaceSkipped: 'The replacement has been made. {0} occurrences were skipped.',
textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.'
}, PE.Controllers.Search || {})); }, PE.Controllers.Search || {}));
}); });

View file

@ -997,6 +997,9 @@
"PE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "PE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.",
"PE.Controllers.Search.notcriticalErrorTitle": "Warning", "PE.Controllers.Search.notcriticalErrorTitle": "Warning",
"PE.Controllers.Search.warnReplaceString": "{0} is not a valid special character for the Replace With box.", "PE.Controllers.Search.warnReplaceString": "{0} is not a valid special character for the Replace With box.",
"PE.Controllers.Search.textReplaceSuccess": "Search has been done. {0} occurrences have been replaced",
"PE.Controllers.Search.textReplaceSkipped": "The replacement has been made. {0} occurrences were skipped.",
"PE.Controllers.Search.textNoTextFound": "The data you have been searching for could not be found. Please adjust your search options.",
"PE.Controllers.Statusbar.textDisconnect": "<b>Connection is lost</b><br>Trying to connect. Please check connection settings.", "PE.Controllers.Statusbar.textDisconnect": "<b>Connection is lost</b><br>Trying to connect. Please check connection settings.",
"PE.Controllers.Statusbar.zoomText": "Zoom {0}%", "PE.Controllers.Statusbar.zoomText": "Zoom {0}%",
"PE.Controllers.Toolbar.confirmAddFontName": "The font you are going to save is not available on the current device.<br>The text style will be displayed using one of the system fonts, the saved font will be used when it is available.<br>Do you want to continue?", "PE.Controllers.Toolbar.confirmAddFontName": "The font you are going to save is not available on the current device.<br>The text style will be displayed using one of the system fonts, the saved font will be used when it is available.<br>Do you want to continue?",

View file

@ -481,7 +481,8 @@ define([
viewport.searchBar.hide(); viewport.searchBar.hide();
} }
var text = typeof findText === 'string' ? findText : (this.api.asc_GetSelectedText() || this._state.searchText); var selectedText = this.api.asc_GetSelectedText(),
text = typeof findText === 'string' ? findText : (selectedText && selectedText.trim() || this._state.searchText);
if (this.resultItems && this.resultItems.length > 0 && if (this.resultItems && this.resultItems.length > 0 &&
(!text && !this.view.inputText.getValue() || (!text && !this.view.inputText.getValue() ||
!this._state.matchCase && text && text.toLowerCase() === this.view.inputText.getValue().toLowerCase() || !this._state.matchCase && text && text.toLowerCase() === this.view.inputText.getValue().toLowerCase() ||