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

Fix/fix bugs
This commit is contained in:
Julia Radzhabova 2022-06-27 11:53:40 +03:00 committed by GitHub
commit d619ecfdc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 16 deletions

View file

@ -326,7 +326,9 @@ define([
if (count > 300) { if (count > 300) {
text = this.textTooManyResults; text = this.textTooManyResults;
} else { } else {
text = current === 'no-results' ? this.textNoSearchResults : (!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count)); text = current === 'no-results' ? this.textNoSearchResults :
(current === 'stop' ? this.textSearchHasStopped :
(!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count)));
} }
this.$reaultsNumber.text(text); this.$reaultsNumber.text(text);
this.disableReplaceButtons(!count); this.disableReplaceButtons(!count);
@ -412,7 +414,8 @@ define([
textName: 'Name', textName: 'Name',
textCell: 'Cell', textCell: 'Cell',
textValue: 'Value', textValue: 'Value',
textFormula: 'Formula' textFormula: 'Formula',
textSearchHasStopped: 'Search has stopped'
}, Common.Views.SearchPanel || {})); }, Common.Views.SearchPanel || {}));
}); });

View file

@ -100,6 +100,7 @@ define([
this.api.asc_registerCallback('asc_onEndTextAroundSearch', _.bind(this.onEndTextAroundSearch, this)); this.api.asc_registerCallback('asc_onEndTextAroundSearch', _.bind(this.onEndTextAroundSearch, this));
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));
} }
return this; return this;
}, },
@ -215,7 +216,7 @@ define([
searchSettings.put_MatchCase(this._state.matchCase); searchSettings.put_MatchCase(this._state.matchCase);
searchSettings.put_WholeWords(this._state.matchWord); searchSettings.put_WholeWords(this._state.matchWord);
if (!this.api.asc_replaceText(searchSettings, textReplace, false)) { if (!this.api.asc_replaceText(searchSettings, textReplace, false)) {
this.allResultsWasRemoved(); this.removeResultItems();
} }
} }
}, },
@ -242,14 +243,14 @@ define([
searchSettings.put_WholeWords(this._state.matchWord); searchSettings.put_WholeWords(this._state.matchWord);
this.api.asc_replaceText(searchSettings, textReplace, true); this.api.asc_replaceText(searchSettings, textReplace, true);
this.allResultsWasRemoved(); this.removeResultItems();
} }
}, },
allResultsWasRemoved: function () { removeResultItems: function (type) {
this.resultItems = []; this.resultItems = [];
this.hideResults(); this.hideResults();
this.view.updateResultsNumber(undefined, 0); this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches
this.view.disableReplaceButtons(true); this.view.disableReplaceButtons(true);
this._state.currentResult = 0; this._state.currentResult = 0;
this._state.resultsNumber = 0; this._state.resultsNumber = 0;
@ -420,6 +421,10 @@ define([
} }
}, },
onApiSearchEnd: function () {
this.removeResultItems('stop');
},
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.'

View file

@ -480,6 +480,7 @@
"Common.Views.SearchPanel.textWholeWords": "Whole words only", "Common.Views.SearchPanel.textWholeWords": "Whole words only",
"Common.Views.SearchPanel.tipNextResult": "Next result", "Common.Views.SearchPanel.tipNextResult": "Next result",
"Common.Views.SearchPanel.tipPreviousResult": "Previous result", "Common.Views.SearchPanel.tipPreviousResult": "Previous result",
"Common.Views.SearchPanel.textSearchHasStopped": "Search has stopped",
"Common.Views.SelectFileDlg.textLoading": "Loading", "Common.Views.SelectFileDlg.textLoading": "Loading",
"Common.Views.SelectFileDlg.textTitle": "Select Data Source", "Common.Views.SelectFileDlg.textTitle": "Select Data Source",
"Common.Views.SignDialog.textBold": "Bold", "Common.Views.SignDialog.textBold": "Bold",

View file

@ -108,10 +108,13 @@ const Search = withTranslation()(props => {
f7.popover.close('.document-menu.modal-in', false); f7.popover.close('.document-menu.modal-in', false);
if (params.find && params.find.length) { if (params.find && params.find.length) {
var options = new AscCommon.CSearchSettings();
options.put_Text(params.find);
options.put_MatchCase(params.caseSensitive);
if (params.highlight) api.asc_selectSearchingResults(true); if (params.highlight) api.asc_selectSearchingResults(true);
api.asc_findText(params.find, params.forward, params.caseSensitive, function (resultCount) { api.asc_findText(options, params.forward, function (resultCount) {
!resultCount && f7.dialog.alert(null, _t.textNoTextFound); !resultCount && f7.dialog.alert(null, _t.textNoTextFound);
}); });
} }
@ -127,7 +130,10 @@ const Search = withTranslation()(props => {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
if (params.find && params.find.length) { if (params.find && params.find.length) {
api.asc_replaceText(params.find, params.replace || '', false, params.caseSensitive, params.highlight); var options = new AscCommon.CSearchSettings();
options.put_Text(params.find);
options.put_MatchCase(params.caseSensitive);
api.asc_replaceText(options, params.replace || '', false);
} }
} }
@ -135,7 +141,10 @@ const Search = withTranslation()(props => {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
if (params.find && params.find.length) { if (params.find && params.find.length) {
api.asc_replaceText(params.find, params.replace || '', true, params.caseSensitive, params.highlight); var options = new AscCommon.CSearchSettings();
options.put_Text(params.find);
options.put_MatchCase(params.caseSensitive);
api.asc_replaceText(options, params.replace || '', true);
} }
} }

View file

@ -97,6 +97,7 @@ define([
this.api.asc_registerCallback('asc_onEndTextAroundSearch', _.bind(this.onEndTextAroundSearch, this)); this.api.asc_registerCallback('asc_onEndTextAroundSearch', _.bind(this.onEndTextAroundSearch, this));
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));
} }
return this; return this;
}, },
@ -198,7 +199,7 @@ define([
searchSettings.put_MatchCase(this._state.matchCase); searchSettings.put_MatchCase(this._state.matchCase);
searchSettings.put_WholeWords(this._state.matchWord); searchSettings.put_WholeWords(this._state.matchWord);
if (!this.api.asc_replaceText(searchSettings, textReplace, false)) { if (!this.api.asc_replaceText(searchSettings, textReplace, false)) {
this.allResultsWasRemoved(); this.removeResultItems();
} }
} }
}, },
@ -211,14 +212,14 @@ define([
searchSettings.put_WholeWords(this._state.matchWord); searchSettings.put_WholeWords(this._state.matchWord);
this.api.asc_replaceText(searchSettings, textReplace, true); this.api.asc_replaceText(searchSettings, textReplace, true);
this.allResultsWasRemoved(); this.removeResultItems();
} }
}, },
allResultsWasRemoved: function () { removeResultItems: function (type) {
this.resultItems = []; this.resultItems = [];
this.hideResults(); this.hideResults();
this.view.updateResultsNumber(undefined, 0); this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches
this.view.disableReplaceButtons(true); this.view.disableReplaceButtons(true);
this._state.currentResult = 0; this._state.currentResult = 0;
this._state.resultsNumber = 0; this._state.resultsNumber = 0;
@ -373,6 +374,10 @@ define([
this.hideResults(); this.hideResults();
}, },
onApiSearchEnd: function () {
this.removeResultItems('stop');
},
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.'

View file

@ -88,7 +88,10 @@ const Search = withTranslation()(props => {
f7.popover.close('.document-menu.modal-in', false); f7.popover.close('.document-menu.modal-in', false);
if (params.find && params.find.length) { if (params.find && params.find.length) {
api.asc_findText(params.find, params.forward, params.caseSensitive, function(resultCount) { var options = new AscCommon.CSearchSettings();
options.put_Text(params.find);
options.put_MatchCase(params.caseSensitive);
api.asc_findText(options, params.forward, function(resultCount) {
!resultCount && f7.dialog.alert(null, _t.textNoTextFound); !resultCount && f7.dialog.alert(null, _t.textNoTextFound);
}); });
@ -105,7 +108,10 @@ const Search = withTranslation()(props => {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
if (params.find && params.find.length) { if (params.find && params.find.length) {
api.asc_replaceText(params.find, params.replace || '', false, params.caseSensitive); var options = new AscCommon.CSearchSettings();
options.put_Text(params.find);
options.put_MatchCase(params.caseSensitive);
api.asc_replaceText(options, params.replace || '', false);
} }
} }
@ -113,7 +119,10 @@ const Search = withTranslation()(props => {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
if (params.find && params.find.length) { if (params.find && params.find.length) {
api.asc_replaceText(params.find, params.replace || '', true, params.caseSensitive); var options = new AscCommon.CSearchSettings();
options.put_Text(params.find);
options.put_MatchCase(params.caseSensitive);
api.asc_replaceText(options, params.replace || '', true);
} }
} }

View file

@ -216,6 +216,7 @@ define([
if (this.panelSearch) { if (this.panelSearch) {
if (this.btnSearchBar.pressed) { if (this.btnSearchBar.pressed) {
this.panelSearch.show(); this.panelSearch.show();
this.panelSearch.focus();
} else { } else {
this.panelSearch.hide(); this.panelSearch.hide();
} }