@univerjs/find-replace 1.0.0-insiders.20260813-7c9aa50 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +0 -1
- package/lib/cjs/index.js +532 -17
- package/lib/cjs/locale/ar-SA.js +7 -2
- package/lib/cjs/locale/ca-ES.js +7 -2
- package/lib/cjs/locale/de-DE.js +7 -2
- package/lib/cjs/locale/en-US.js +7 -2
- package/lib/cjs/locale/es-ES.js +7 -2
- package/lib/cjs/locale/fa-IR.js +7 -2
- package/lib/cjs/locale/fr-FR.js +7 -2
- package/lib/cjs/locale/id-ID.js +7 -2
- package/lib/cjs/locale/it-IT.js +7 -2
- package/lib/cjs/locale/ja-JP.js +7 -2
- package/lib/cjs/locale/ko-KR.js +7 -2
- package/lib/cjs/locale/pl-PL.js +7 -2
- package/lib/cjs/locale/pt-BR.js +7 -2
- package/lib/cjs/locale/ru-RU.js +7 -2
- package/lib/cjs/locale/sk-SK.js +7 -2
- package/lib/cjs/locale/vi-VN.js +7 -2
- package/lib/cjs/locale/zh-CN.js +7 -2
- package/lib/cjs/locale/zh-HK.js +7 -2
- package/lib/cjs/locale/zh-TW.js +7 -2
- package/lib/es/index.js +531 -23
- package/lib/es/locale/ar-SA.js +7 -1
- package/lib/es/locale/ca-ES.js +7 -1
- package/lib/es/locale/de-DE.js +7 -1
- package/lib/es/locale/en-US.js +7 -1
- package/lib/es/locale/es-ES.js +7 -1
- package/lib/es/locale/fa-IR.js +7 -1
- package/lib/es/locale/fr-FR.js +7 -1
- package/lib/es/locale/id-ID.js +7 -1
- package/lib/es/locale/it-IT.js +7 -1
- package/lib/es/locale/ja-JP.js +7 -1
- package/lib/es/locale/ko-KR.js +7 -1
- package/lib/es/locale/pl-PL.js +7 -1
- package/lib/es/locale/pt-BR.js +7 -1
- package/lib/es/locale/ru-RU.js +7 -1
- package/lib/es/locale/sk-SK.js +7 -1
- package/lib/es/locale/vi-VN.js +7 -1
- package/lib/es/locale/zh-CN.js +7 -1
- package/lib/es/locale/zh-HK.js +7 -1
- package/lib/es/locale/zh-TW.js +7 -1
- package/lib/index.css +204 -0
- package/lib/index.js +531 -23
- package/lib/locale/ar-SA.js +7 -1
- package/lib/locale/ca-ES.js +7 -1
- package/lib/locale/de-DE.js +7 -1
- package/lib/locale/en-US.js +7 -1
- package/lib/locale/es-ES.js +7 -1
- package/lib/locale/fa-IR.js +7 -1
- package/lib/locale/fr-FR.js +7 -1
- package/lib/locale/id-ID.js +7 -1
- package/lib/locale/it-IT.js +7 -1
- package/lib/locale/ja-JP.js +7 -1
- package/lib/locale/ko-KR.js +7 -1
- package/lib/locale/pl-PL.js +7 -1
- package/lib/locale/pt-BR.js +7 -1
- package/lib/locale/ru-RU.js +7 -1
- package/lib/locale/sk-SK.js +7 -1
- package/lib/locale/vi-VN.js +7 -1
- package/lib/locale/zh-CN.js +7 -1
- package/lib/locale/zh-HK.js +7 -1
- package/lib/locale/zh-TW.js +7 -1
- package/lib/types/commands/operations/find-replace.operation.d.ts +1 -0
- package/lib/types/const.d.ts +17 -0
- package/lib/types/controllers/find-replace.controller.d.ts +1 -0
- package/lib/types/controllers/mobile/components.controller.d.ts +20 -0
- package/lib/types/controllers/mobile/find-replace.controller.d.ts +21 -0
- package/lib/types/index.d.ts +2 -1
- package/lib/types/locale/en-US.d.ts +7 -1
- package/lib/types/menu/mobile-schema.d.ts +17 -0
- package/lib/types/mobile-plugin.d.ts +28 -0
- package/lib/types/services/find-replace.service.d.ts +2 -0
- package/lib/types/views/mobile/MobileFindReplaceBar.d.ts +16 -0
- package/lib/types/views/mobile/MobileFindReplaceSettings.d.ts +16 -0
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +9 -9
package/lib/cjs/index.js
CHANGED
|
@@ -5,8 +5,8 @@ let _univerjs_ui = require("@univerjs/ui");
|
|
|
5
5
|
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
6
6
|
let rxjs = require("rxjs");
|
|
7
7
|
let _univerjs_icons = require("@univerjs/icons");
|
|
8
|
-
let react = require("react");
|
|
9
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let react = require("react");
|
|
10
10
|
|
|
11
11
|
//#region src/services/context-keys.ts
|
|
12
12
|
/**
|
|
@@ -37,7 +37,7 @@ const FIND_REPLACE_REPLACE_REVEALED = "FIND_REPLACE_REPLACE_REVEALED";
|
|
|
37
37
|
const FIND_REPLACE_AVAILABLE = "FIND_REPLACE_AVAILABLE";
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
|
-
//#region \0@oxc-project+runtime@0.
|
|
40
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
41
41
|
function _typeof(o) {
|
|
42
42
|
"@babel/helpers - typeof";
|
|
43
43
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -48,7 +48,7 @@ function _typeof(o) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region \0@oxc-project+runtime@0.
|
|
51
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
52
52
|
function toPrimitive(t, r) {
|
|
53
53
|
if ("object" != _typeof(t) || !t) return t;
|
|
54
54
|
var e = t[Symbol.toPrimitive];
|
|
@@ -61,14 +61,14 @@ function toPrimitive(t, r) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
//#endregion
|
|
64
|
-
//#region \0@oxc-project+runtime@0.
|
|
64
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
65
65
|
function toPropertyKey(t) {
|
|
66
66
|
var i = toPrimitive(t, "string");
|
|
67
67
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
//#endregion
|
|
71
|
-
//#region \0@oxc-project+runtime@0.
|
|
71
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
72
72
|
function _defineProperty(e, r, t) {
|
|
73
73
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
74
74
|
value: t,
|
|
@@ -79,7 +79,7 @@ function _defineProperty(e, r, t) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
//#endregion
|
|
82
|
-
//#region \0@oxc-project+runtime@0.
|
|
82
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
83
83
|
function __decorateParam(paramIndex, decorator) {
|
|
84
84
|
return function(target, key) {
|
|
85
85
|
decorator(target, key, paramIndex);
|
|
@@ -87,7 +87,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
//#endregion
|
|
90
|
-
//#region \0@oxc-project+runtime@0.
|
|
90
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
91
91
|
function __decorate(decorators, target, key, desc) {
|
|
92
92
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
93
93
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -650,6 +650,13 @@ let FindReplaceService = class FindReplaceService extends _univerjs_core.Disposa
|
|
|
650
650
|
});
|
|
651
651
|
this._toggleRevealReplace(true);
|
|
652
652
|
}
|
|
653
|
+
hideReplace() {
|
|
654
|
+
this._state.changeState({
|
|
655
|
+
replaceRevealed: false,
|
|
656
|
+
findString: this._state.inputtingFindString
|
|
657
|
+
});
|
|
658
|
+
this._toggleRevealReplace(false);
|
|
659
|
+
}
|
|
653
660
|
focusSelection() {
|
|
654
661
|
var _this$_model2;
|
|
655
662
|
(_this$_model2 = this._model) === null || _this$_model2 === void 0 || _this$_model2.focusSelection();
|
|
@@ -775,6 +782,14 @@ const OpenReplaceDialogOperation = {
|
|
|
775
782
|
return true;
|
|
776
783
|
}
|
|
777
784
|
};
|
|
785
|
+
const CloseFindDialogOperation = {
|
|
786
|
+
id: "ui.operation.close-find-dialog",
|
|
787
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
788
|
+
handler: (accessor) => {
|
|
789
|
+
accessor.get(IFindReplaceService).terminate();
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
};
|
|
778
793
|
const GoToNextMatchOperation = {
|
|
779
794
|
type: _univerjs_core.CommandType.OPERATION,
|
|
780
795
|
id: "ui.operation.go-to-next-match",
|
|
@@ -810,7 +825,11 @@ function FindReplaceMenuItemFactory(accessor) {
|
|
|
810
825
|
tooltip: "find-replace.toolbar",
|
|
811
826
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
812
827
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
813
|
-
disabled$: (0, rxjs.combineLatest)([
|
|
828
|
+
disabled$: (0, rxjs.combineLatest)([
|
|
829
|
+
contextService.subscribeContextValue$(_univerjs_core.EDITOR_ACTIVATED),
|
|
830
|
+
contextService.subscribeContextValue$(_univerjs_core.FOCUSING_SHEET),
|
|
831
|
+
contextService.subscribeContextValue$(FIND_REPLACE_AVAILABLE).pipe((0, rxjs.startWith)(contextService.getContextValue(FIND_REPLACE_AVAILABLE)))
|
|
832
|
+
]).pipe((0, rxjs.map)(([editorActivated, focusingSheet, available]) => editorActivated || !focusingSheet || !available))
|
|
814
833
|
};
|
|
815
834
|
}
|
|
816
835
|
|
|
@@ -939,6 +958,7 @@ let FindReplaceController = class FindReplaceController extends _univerjs_core.R
|
|
|
939
958
|
[
|
|
940
959
|
OpenFindDialogOperation,
|
|
941
960
|
OpenReplaceDialogOperation,
|
|
961
|
+
CloseFindDialogOperation,
|
|
942
962
|
GoToNextMatchOperation,
|
|
943
963
|
GoToPreviousMatchOperation,
|
|
944
964
|
ReplaceAllMatchesCommand,
|
|
@@ -962,6 +982,7 @@ let FindReplaceController = class FindReplaceController extends _univerjs_core.R
|
|
|
962
982
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
963
983
|
this._findReplaceService.stateUpdates$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((newState) => {
|
|
964
984
|
if (newState.revealed === true) this._openPanel();
|
|
985
|
+
else if (newState.revealed === false) this._closePanel(false);
|
|
965
986
|
});
|
|
966
987
|
}
|
|
967
988
|
_openPanel() {
|
|
@@ -984,11 +1005,14 @@ let FindReplaceController = class FindReplaceController extends _univerjs_core.R
|
|
|
984
1005
|
}));
|
|
985
1006
|
}
|
|
986
1007
|
closePanel() {
|
|
1008
|
+
this._closePanel(true);
|
|
1009
|
+
}
|
|
1010
|
+
_closePanel(terminateSession) {
|
|
987
1011
|
if (!this._closingListenerDisposable) return;
|
|
988
1012
|
this._closingListenerDisposable.dispose();
|
|
989
1013
|
this._closingListenerDisposable = null;
|
|
990
1014
|
this._dialogService.close(FIND_REPLACE_DIALOG_ID);
|
|
991
|
-
this._findReplaceService.terminate();
|
|
1015
|
+
if (terminateSession) this._findReplaceService.terminate();
|
|
992
1016
|
queueMicrotask(() => this._layoutService.focus());
|
|
993
1017
|
}
|
|
994
1018
|
};
|
|
@@ -1013,7 +1037,7 @@ function getFindReplaceDialogDefaultPosition(direction) {
|
|
|
1013
1037
|
//#endregion
|
|
1014
1038
|
//#region package.json
|
|
1015
1039
|
var name = "@univerjs/find-replace";
|
|
1016
|
-
var version = "1.0.0
|
|
1040
|
+
var version = "1.0.0";
|
|
1017
1041
|
|
|
1018
1042
|
//#endregion
|
|
1019
1043
|
//#region src/config/config.ts
|
|
@@ -1021,6 +1045,478 @@ const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
|
|
|
1021
1045
|
const configSymbol = Symbol(FIND_REPLACE_PLUGIN_CONFIG_KEY);
|
|
1022
1046
|
const defaultPluginConfig = {};
|
|
1023
1047
|
|
|
1048
|
+
//#endregion
|
|
1049
|
+
//#region src/const.ts
|
|
1050
|
+
/**
|
|
1051
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1052
|
+
*
|
|
1053
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1054
|
+
* you may not use this file except in compliance with the License.
|
|
1055
|
+
* You may obtain a copy of the License at
|
|
1056
|
+
*
|
|
1057
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1058
|
+
*
|
|
1059
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1060
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1061
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1062
|
+
* See the License for the specific language governing permissions and
|
|
1063
|
+
* limitations under the License.
|
|
1064
|
+
*/
|
|
1065
|
+
const MOBILE_FIND_REPLACE_SETTINGS_COMPONENT = "MobileFindReplaceSettings";
|
|
1066
|
+
const MOBILE_FIND_REPLACE_SETTINGS_DIALOG_ID = "MOBILE_FIND_REPLACE_SETTINGS_DIALOG";
|
|
1067
|
+
|
|
1068
|
+
//#endregion
|
|
1069
|
+
//#region src/views/mobile/MobileFindReplaceSettings.tsx
|
|
1070
|
+
const FIND_SCOPE_OPTIONS$1 = [{
|
|
1071
|
+
label: "find-replace.dialog.find-scope.current-sheet",
|
|
1072
|
+
value: "subunit"
|
|
1073
|
+
}, {
|
|
1074
|
+
label: "find-replace.dialog.find-scope.workbook",
|
|
1075
|
+
value: "unit"
|
|
1076
|
+
}];
|
|
1077
|
+
const FIND_DIRECTION_OPTIONS$1 = [{
|
|
1078
|
+
label: "find-replace.dialog.find-direction.row",
|
|
1079
|
+
value: "row"
|
|
1080
|
+
}, {
|
|
1081
|
+
label: "find-replace.dialog.find-direction.column",
|
|
1082
|
+
value: "column"
|
|
1083
|
+
}];
|
|
1084
|
+
const FIND_BY_OPTIONS$1 = [{
|
|
1085
|
+
label: "find-replace.dialog.find-by.value",
|
|
1086
|
+
value: "value"
|
|
1087
|
+
}, {
|
|
1088
|
+
label: "find-replace.dialog.find-by.formula",
|
|
1089
|
+
value: "formula"
|
|
1090
|
+
}];
|
|
1091
|
+
function MobileFindReplaceSettings() {
|
|
1092
|
+
const findReplaceService = (0, _univerjs_ui.useDependency)(IFindReplaceService);
|
|
1093
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1094
|
+
const state = (0, _univerjs_ui.useObservable)(findReplaceService.state$, void 0, true);
|
|
1095
|
+
const capabilities = (0, _univerjs_ui.useObservable)(findReplaceService.providerCapabilities$, null, true);
|
|
1096
|
+
function refreshSearch(force = false) {
|
|
1097
|
+
if (state.findString && (force || state.replaceRevealed)) findReplaceService.find();
|
|
1098
|
+
}
|
|
1099
|
+
const findScopeOptions = FIND_SCOPE_OPTIONS$1.map((option) => ({
|
|
1100
|
+
...option,
|
|
1101
|
+
label: localeService.t(option.label)
|
|
1102
|
+
}));
|
|
1103
|
+
const findDirectionOptions = FIND_DIRECTION_OPTIONS$1.map((option) => ({
|
|
1104
|
+
...option,
|
|
1105
|
+
label: localeService.t(option.label)
|
|
1106
|
+
}));
|
|
1107
|
+
const findByOptions = FIND_BY_OPTIONS$1.map((option) => ({
|
|
1108
|
+
...option,
|
|
1109
|
+
label: localeService.t(option.label)
|
|
1110
|
+
}));
|
|
1111
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1112
|
+
className: "univer-grid univer-gap-2",
|
|
1113
|
+
"data-u-comp": "mobile-find-replace-settings",
|
|
1114
|
+
children: [
|
|
1115
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingCheckbox, {
|
|
1116
|
+
checked: state.replaceRevealed,
|
|
1117
|
+
label: localeService.t("find-replace.dialog.replace"),
|
|
1118
|
+
onChange: (checked) => {
|
|
1119
|
+
if (checked) findReplaceService.revealReplace();
|
|
1120
|
+
else findReplaceService.hideReplace();
|
|
1121
|
+
refreshSearch(true);
|
|
1122
|
+
}
|
|
1123
|
+
}),
|
|
1124
|
+
(capabilities === null || capabilities === void 0 ? void 0 : capabilities.findDirection) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingSelect, {
|
|
1125
|
+
label: localeService.t("find-replace.dialog.find-direction.title"),
|
|
1126
|
+
value: state.findDirection,
|
|
1127
|
+
options: findDirectionOptions,
|
|
1128
|
+
onChange: (value) => {
|
|
1129
|
+
findReplaceService.changeFindDirection(value);
|
|
1130
|
+
refreshSearch();
|
|
1131
|
+
}
|
|
1132
|
+
}),
|
|
1133
|
+
(capabilities === null || capabilities === void 0 ? void 0 : capabilities.findScope) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingSelect, {
|
|
1134
|
+
label: localeService.t("find-replace.dialog.find-scope.title"),
|
|
1135
|
+
value: state.findScope,
|
|
1136
|
+
options: findScopeOptions,
|
|
1137
|
+
onChange: (value) => {
|
|
1138
|
+
findReplaceService.changeFindScope(value);
|
|
1139
|
+
refreshSearch();
|
|
1140
|
+
}
|
|
1141
|
+
}),
|
|
1142
|
+
(capabilities === null || capabilities === void 0 ? void 0 : capabilities.findBy) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingSelect, {
|
|
1143
|
+
label: localeService.t("find-replace.dialog.find-by.title"),
|
|
1144
|
+
value: state.findBy,
|
|
1145
|
+
options: findByOptions,
|
|
1146
|
+
onChange: (value) => {
|
|
1147
|
+
findReplaceService.changeFindBy(value);
|
|
1148
|
+
refreshSearch();
|
|
1149
|
+
}
|
|
1150
|
+
}),
|
|
1151
|
+
(capabilities === null || capabilities === void 0 ? void 0 : capabilities.caseSensitive) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingCheckbox, {
|
|
1152
|
+
checked: state.caseSensitive,
|
|
1153
|
+
label: localeService.t("find-replace.dialog.case-sensitive"),
|
|
1154
|
+
onChange: (checked) => {
|
|
1155
|
+
findReplaceService.changeCaseSensitive(checked);
|
|
1156
|
+
refreshSearch();
|
|
1157
|
+
}
|
|
1158
|
+
}),
|
|
1159
|
+
(capabilities === null || capabilities === void 0 ? void 0 : capabilities.matchesTheWholeCell) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingCheckbox, {
|
|
1160
|
+
checked: state.matchesTheWholeCell,
|
|
1161
|
+
label: localeService.t("find-replace.dialog.match-the-whole-cell"),
|
|
1162
|
+
onChange: (checked) => {
|
|
1163
|
+
findReplaceService.changeMatchesTheWholeCell(checked);
|
|
1164
|
+
refreshSearch();
|
|
1165
|
+
}
|
|
1166
|
+
}),
|
|
1167
|
+
(capabilities === null || capabilities === void 0 ? void 0 : capabilities.matchesTheWholeWord) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingCheckbox, {
|
|
1168
|
+
checked: state.matchesTheWholeWord,
|
|
1169
|
+
label: localeService.t("find-replace.dialog.match-the-whole-word"),
|
|
1170
|
+
onChange: (checked) => {
|
|
1171
|
+
findReplaceService.changeMatchesTheWholeWord(checked);
|
|
1172
|
+
refreshSearch();
|
|
1173
|
+
}
|
|
1174
|
+
})
|
|
1175
|
+
]
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
function SettingSelect(props) {
|
|
1179
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1180
|
+
className: "univer-grid univer-gap-1 univer-text-sm univer-text-gray-700 dark:!univer-text-gray-300",
|
|
1181
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: props.label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileSelect, {
|
|
1182
|
+
value: props.value,
|
|
1183
|
+
options: props.options,
|
|
1184
|
+
onChange: props.onChange
|
|
1185
|
+
})]
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
function SettingCheckbox(props) {
|
|
1189
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1190
|
+
className: "univer-flex univer-min-h-9 univer-items-center",
|
|
1191
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
1192
|
+
checked: props.checked,
|
|
1193
|
+
onChange: (checked) => props.onChange(Boolean(checked)),
|
|
1194
|
+
children: props.label
|
|
1195
|
+
})
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
//#endregion
|
|
1200
|
+
//#region src/controllers/mobile/components.controller.ts
|
|
1201
|
+
/**
|
|
1202
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1203
|
+
*
|
|
1204
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1205
|
+
* you may not use this file except in compliance with the License.
|
|
1206
|
+
* You may obtain a copy of the License at
|
|
1207
|
+
*
|
|
1208
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1209
|
+
*
|
|
1210
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1211
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1212
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1213
|
+
* See the License for the specific language governing permissions and
|
|
1214
|
+
* limitations under the License.
|
|
1215
|
+
*/
|
|
1216
|
+
let MobileComponentsController = class MobileComponentsController extends _univerjs_core.Disposable {
|
|
1217
|
+
constructor(componentManager, iconManager) {
|
|
1218
|
+
super();
|
|
1219
|
+
this.disposeWithMe(iconManager.register({ SearchIcon: _univerjs_icons.SearchIcon }));
|
|
1220
|
+
this.disposeWithMe(componentManager.register(MOBILE_FIND_REPLACE_SETTINGS_COMPONENT, MobileFindReplaceSettings));
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
MobileComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], MobileComponentsController);
|
|
1224
|
+
|
|
1225
|
+
//#endregion
|
|
1226
|
+
//#region src/menu/mobile-schema.ts
|
|
1227
|
+
const mobileMenuSchema = { [_univerjs_ui.RibbonDataGroup.ORGANIZATION]: { [OpenFindDialogOperation.id]: {
|
|
1228
|
+
order: 2,
|
|
1229
|
+
menuItemFactory: FindReplaceMenuItemFactory
|
|
1230
|
+
} } };
|
|
1231
|
+
|
|
1232
|
+
//#endregion
|
|
1233
|
+
//#region src/views/mobile/MobileFindReplaceBar.tsx
|
|
1234
|
+
const SEARCH_DEBOUNCE_TIME = 500;
|
|
1235
|
+
function MobileFindReplaceBar() {
|
|
1236
|
+
const findReplaceService = (0, _univerjs_ui.useDependency)(IFindReplaceService);
|
|
1237
|
+
(0, _univerjs_ui.useObservable)(findReplaceService.state$, void 0, true);
|
|
1238
|
+
if (!findReplaceService.revealed) return null;
|
|
1239
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileFindReplaceBarContent, {});
|
|
1240
|
+
}
|
|
1241
|
+
function MobileFindReplaceBarContent() {
|
|
1242
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1243
|
+
const dialogService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IDialogService);
|
|
1244
|
+
const findReplaceService = (0, _univerjs_ui.useDependency)(IFindReplaceService);
|
|
1245
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1246
|
+
const state = (0, _univerjs_ui.useObservable)(findReplaceService.state$, void 0, true);
|
|
1247
|
+
const currentMatch = (0, _univerjs_ui.useObservable)(findReplaceService.currentMatch$, null, true);
|
|
1248
|
+
const replaceables = (0, _univerjs_ui.useObservable)(findReplaceService.replaceables$, [], true);
|
|
1249
|
+
const [findValue, setFindValue] = (0, react.useState)(() => state.replaceRevealed ? state.inputtingFindString : state.findString);
|
|
1250
|
+
const barRef = (0, react.useRef)(null);
|
|
1251
|
+
const inputRef = (0, react.useRef)(null);
|
|
1252
|
+
const searchTimerRef = (0, react.useRef)(null);
|
|
1253
|
+
const suppressNextFocusRef = (0, react.useRef)(false);
|
|
1254
|
+
const keyboardLayout = (0, _univerjs_design.useMobileKeyboardViewportLayout)(barRef);
|
|
1255
|
+
(0, react.useEffect)(() => {
|
|
1256
|
+
const frame = requestAnimationFrame(() => {
|
|
1257
|
+
var _inputRef$current;
|
|
1258
|
+
return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
1259
|
+
});
|
|
1260
|
+
return () => cancelAnimationFrame(frame);
|
|
1261
|
+
}, []);
|
|
1262
|
+
(0, react.useEffect)(() => {
|
|
1263
|
+
const subscription = findReplaceService.focusSignal$.subscribe(() => {
|
|
1264
|
+
var _inputRef$current2;
|
|
1265
|
+
if (suppressNextFocusRef.current) {
|
|
1266
|
+
suppressNextFocusRef.current = false;
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.focus();
|
|
1270
|
+
});
|
|
1271
|
+
return () => subscription.unsubscribe();
|
|
1272
|
+
}, [findReplaceService]);
|
|
1273
|
+
(0, react.useEffect)(() => () => {
|
|
1274
|
+
if (searchTimerRef.current) clearTimeout(searchTimerRef.current);
|
|
1275
|
+
}, []);
|
|
1276
|
+
function clearSearchTimer() {
|
|
1277
|
+
if (searchTimerRef.current) {
|
|
1278
|
+
clearTimeout(searchTimerRef.current);
|
|
1279
|
+
searchTimerRef.current = null;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
function commitSearch(value) {
|
|
1283
|
+
clearSearchTimer();
|
|
1284
|
+
if (!value) {
|
|
1285
|
+
findReplaceService.changeInputtingFindString("");
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
if (findReplaceService.replaceRevealed) {
|
|
1289
|
+
findReplaceService.changeInputtingFindString(value);
|
|
1290
|
+
findReplaceService.changeFindString(value);
|
|
1291
|
+
findReplaceService.find();
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
findReplaceService.changeFindString(value);
|
|
1295
|
+
}
|
|
1296
|
+
function scheduleSearch(value) {
|
|
1297
|
+
clearSearchTimer();
|
|
1298
|
+
if (!value) {
|
|
1299
|
+
commitSearch(value);
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
searchTimerRef.current = setTimeout(() => commitSearch(value), SEARCH_DEBOUNCE_TIME);
|
|
1303
|
+
}
|
|
1304
|
+
function blurActiveElement() {
|
|
1305
|
+
if (document.activeElement instanceof HTMLElement) document.activeElement.blur();
|
|
1306
|
+
}
|
|
1307
|
+
function executeAfterBlur(commandId, suppressFocusSignal = false) {
|
|
1308
|
+
blurActiveElement();
|
|
1309
|
+
if (findValue !== state.findString) {
|
|
1310
|
+
commitSearch(findValue);
|
|
1311
|
+
if (commandId === GoToNextMatchOperation.id || commandId === GoToPreviousMatchOperation.id) return;
|
|
1312
|
+
}
|
|
1313
|
+
suppressNextFocusRef.current = suppressFocusSignal;
|
|
1314
|
+
const execution = commandService.executeCommand(commandId);
|
|
1315
|
+
suppressNextFocusRef.current = false;
|
|
1316
|
+
execution.catch(() => void 0);
|
|
1317
|
+
}
|
|
1318
|
+
function openSettings() {
|
|
1319
|
+
commitSearch(findValue);
|
|
1320
|
+
blurActiveElement();
|
|
1321
|
+
dialogService.open({
|
|
1322
|
+
id: MOBILE_FIND_REPLACE_SETTINGS_DIALOG_ID,
|
|
1323
|
+
title: { title: localeService.t("find-replace.mobile.settings-title") },
|
|
1324
|
+
children: { label: MOBILE_FIND_REPLACE_SETTINGS_COMPONENT }
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
const resultText = state.findCompleted && state.matchesCount === 0 ? localeService.t("find-replace.dialog.no-result") : state.matchesCount > 0 ? `${state.matchesPosition}/${state.matchesCount}` : void 0;
|
|
1328
|
+
const navigationDisabled = state.matchesCount === 0;
|
|
1329
|
+
const replaceDisabled = state.matchesCount === 0 || !(currentMatch === null || currentMatch === void 0 ? void 0 : currentMatch.replaceable);
|
|
1330
|
+
const replaceAllDisabled = replaceables.length === 0;
|
|
1331
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1332
|
+
ref: barRef,
|
|
1333
|
+
"data-u-comp": "mobile-find-replace-bar",
|
|
1334
|
+
className: "univer-fixed univer-inset-x-0 univer-z-40 univer-grid univer-gap-2 univer-bg-gray-0 univer-px-2 univer-pt-1.5 univer-shadow-[0_-4px_16px_rgba(0,0,0,0.08)] dark:!univer-bg-gray-800",
|
|
1335
|
+
style: {
|
|
1336
|
+
bottom: (keyboardLayout === null || keyboardLayout === void 0 ? void 0 : keyboardLayout.bottom) ?? 0,
|
|
1337
|
+
paddingBottom: "calc(6px + env(safe-area-inset-bottom, 0px))"
|
|
1338
|
+
},
|
|
1339
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1340
|
+
className: "univer-flex",
|
|
1341
|
+
children: [
|
|
1342
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
|
|
1343
|
+
label: localeService.t("find-replace.mobile.settings"),
|
|
1344
|
+
onClick: openSettings,
|
|
1345
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ConfigureTabIcon, {})
|
|
1346
|
+
}),
|
|
1347
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1348
|
+
className: "univer-relative univer-mr-2 univer-min-w-0 univer-flex-1",
|
|
1349
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SearchIcon, { className: "univer-pointer-events-none univer-absolute univer-left-3 univer-top-1/2 univer-z-10 univer-size-5 -univer-translate-y-1/2 univer-text-gray-500" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
1350
|
+
ref: inputRef,
|
|
1351
|
+
size: "middle",
|
|
1352
|
+
allowClear: true,
|
|
1353
|
+
value: findValue,
|
|
1354
|
+
placeholder: localeService.t("find-replace.dialog.find-placeholder"),
|
|
1355
|
+
inputClass: "!univer-pl-10",
|
|
1356
|
+
slot: resultText ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1357
|
+
className: "univer-text-xs univer-text-gray-400",
|
|
1358
|
+
children: resultText
|
|
1359
|
+
}) : void 0,
|
|
1360
|
+
onChange: (value) => {
|
|
1361
|
+
setFindValue(value);
|
|
1362
|
+
scheduleSearch(value);
|
|
1363
|
+
},
|
|
1364
|
+
onKeyDown: (event) => {
|
|
1365
|
+
if (event.key === "Enter") executeAfterBlur(GoToNextMatchOperation.id);
|
|
1366
|
+
}
|
|
1367
|
+
})]
|
|
1368
|
+
}),
|
|
1369
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
|
|
1370
|
+
disabled: navigationDisabled,
|
|
1371
|
+
label: localeService.t("find-replace.mobile.previous-match"),
|
|
1372
|
+
onClick: () => executeAfterBlur(GoToPreviousMatchOperation.id, true),
|
|
1373
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ArrowUpIcon, {})
|
|
1374
|
+
}),
|
|
1375
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
|
|
1376
|
+
disabled: navigationDisabled,
|
|
1377
|
+
label: localeService.t("find-replace.mobile.next-match"),
|
|
1378
|
+
onClick: () => executeAfterBlur(GoToNextMatchOperation.id, true),
|
|
1379
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ArrowDownIcon, {})
|
|
1380
|
+
}),
|
|
1381
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
|
|
1382
|
+
label: localeService.t("find-replace.mobile.close"),
|
|
1383
|
+
onClick: () => {
|
|
1384
|
+
blurActiveElement();
|
|
1385
|
+
commandService.executeCommand(CloseFindDialogOperation.id).catch(() => void 0);
|
|
1386
|
+
},
|
|
1387
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CloseIcon, {})
|
|
1388
|
+
})
|
|
1389
|
+
]
|
|
1390
|
+
}), state.replaceRevealed && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1391
|
+
className: "univer-flex univer-gap-1 univer-pl-9",
|
|
1392
|
+
children: [
|
|
1393
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
1394
|
+
size: "middle",
|
|
1395
|
+
className: "univer-min-w-0 univer-flex-1",
|
|
1396
|
+
value: state.replaceString,
|
|
1397
|
+
placeholder: localeService.t("find-replace.dialog.replace-placeholder"),
|
|
1398
|
+
onChange: (value) => findReplaceService.changeReplaceString(value)
|
|
1399
|
+
}),
|
|
1400
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton, {
|
|
1401
|
+
disabled: replaceDisabled,
|
|
1402
|
+
onClick: () => executeAfterBlur(ReplaceCurrentMatchCommand.id),
|
|
1403
|
+
children: localeService.t("find-replace.dialog.replace")
|
|
1404
|
+
}),
|
|
1405
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionButton, {
|
|
1406
|
+
disabled: replaceAllDisabled,
|
|
1407
|
+
onClick: () => executeAfterBlur(ReplaceAllMatchesCommand.id),
|
|
1408
|
+
children: localeService.t("find-replace.dialog.replace-all")
|
|
1409
|
+
})
|
|
1410
|
+
]
|
|
1411
|
+
})]
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
function IconButton(props) {
|
|
1415
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1416
|
+
type: "button",
|
|
1417
|
+
"aria-label": props.label,
|
|
1418
|
+
disabled: props.disabled,
|
|
1419
|
+
className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, "univer-flex univer-size-9 univer-flex-none univer-items-center univer-justify-center univer-rounded-full univer-text-lg univer-text-gray-700 active:univer-bg-gray-100 disabled:univer-opacity-35 dark:!univer-text-gray-200 dark:active:!univer-bg-gray-700"),
|
|
1420
|
+
onClick: props.onClick,
|
|
1421
|
+
children: props.children
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
function ActionButton(props) {
|
|
1425
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1426
|
+
type: "button",
|
|
1427
|
+
disabled: props.disabled,
|
|
1428
|
+
className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, "univer-h-10 univer-flex-none univer-whitespace-nowrap univer-rounded-lg univer-bg-primary-600 univer-px-3 univer-text-sm univer-font-medium univer-text-gray-0 active:univer-bg-primary-700 disabled:univer-bg-gray-100 disabled:univer-text-gray-400 dark:disabled:!univer-bg-gray-700 dark:disabled:!univer-text-gray-500"),
|
|
1429
|
+
onClick: props.onClick,
|
|
1430
|
+
children: props.children
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
//#endregion
|
|
1435
|
+
//#region src/controllers/mobile/find-replace.controller.ts
|
|
1436
|
+
/**
|
|
1437
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1438
|
+
*
|
|
1439
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1440
|
+
* you may not use this file except in compliance with the License.
|
|
1441
|
+
* You may obtain a copy of the License at
|
|
1442
|
+
*
|
|
1443
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1444
|
+
*
|
|
1445
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1446
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1447
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1448
|
+
* See the License for the specific language governing permissions and
|
|
1449
|
+
* limitations under the License.
|
|
1450
|
+
*/
|
|
1451
|
+
let FindReplaceMobileController = class FindReplaceMobileController extends _univerjs_core.RxDisposable {
|
|
1452
|
+
constructor(injector, commandService, dialogService, findReplaceService, menuManagerService, univerInstanceService, uiPartsService) {
|
|
1453
|
+
super();
|
|
1454
|
+
[
|
|
1455
|
+
OpenFindDialogOperation,
|
|
1456
|
+
OpenReplaceDialogOperation,
|
|
1457
|
+
CloseFindDialogOperation,
|
|
1458
|
+
GoToNextMatchOperation,
|
|
1459
|
+
GoToPreviousMatchOperation,
|
|
1460
|
+
ReplaceAllMatchesCommand,
|
|
1461
|
+
ReplaceCurrentMatchCommand,
|
|
1462
|
+
FocusSelectionOperation
|
|
1463
|
+
].forEach((command) => this.disposeWithMe(commandService.registerCommand(command)));
|
|
1464
|
+
menuManagerService.mergeMenu(mobileMenuSchema);
|
|
1465
|
+
this.disposeWithMe(uiPartsService.registerComponent(_univerjs_ui.BuiltInUIPart.FOOTER, () => (0, _univerjs_ui.connectInjector)(MobileFindReplaceBar, injector)));
|
|
1466
|
+
findReplaceService.stateUpdates$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((state) => {
|
|
1467
|
+
if (state.revealed === false) dialogService.close(MOBILE_FIND_REPLACE_SETTINGS_DIALOG_ID);
|
|
1468
|
+
});
|
|
1469
|
+
let sessionUnitId = null;
|
|
1470
|
+
findReplaceService.stateUpdates$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((state) => {
|
|
1471
|
+
if (state.revealed === true) {
|
|
1472
|
+
var _univerInstanceServic;
|
|
1473
|
+
sessionUnitId = ((_univerInstanceServic = univerInstanceService.getFocusedUnit()) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId()) ?? null;
|
|
1474
|
+
} else if (state.revealed === false) sessionUnitId = null;
|
|
1475
|
+
});
|
|
1476
|
+
univerInstanceService.focused$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((focused) => {
|
|
1477
|
+
if (sessionUnitId && focused !== sessionUnitId) findReplaceService.terminate();
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
};
|
|
1481
|
+
FindReplaceMobileController = __decorate([
|
|
1482
|
+
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1483
|
+
__decorateParam(1, _univerjs_core.ICommandService),
|
|
1484
|
+
__decorateParam(2, _univerjs_ui.IDialogService),
|
|
1485
|
+
__decorateParam(3, IFindReplaceService),
|
|
1486
|
+
__decorateParam(4, _univerjs_ui.IMenuManagerService),
|
|
1487
|
+
__decorateParam(5, _univerjs_core.IUniverInstanceService),
|
|
1488
|
+
__decorateParam(6, _univerjs_ui.IUIPartsService)
|
|
1489
|
+
], FindReplaceMobileController);
|
|
1490
|
+
|
|
1491
|
+
//#endregion
|
|
1492
|
+
//#region src/mobile-plugin.ts
|
|
1493
|
+
let UniverFindReplaceMobileUIPlugin = class UniverFindReplaceMobileUIPlugin extends _univerjs_core.Plugin {
|
|
1494
|
+
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
1495
|
+
super();
|
|
1496
|
+
this._config = _config;
|
|
1497
|
+
this._injector = _injector;
|
|
1498
|
+
this._configService = _configService;
|
|
1499
|
+
const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
|
|
1500
|
+
this._configService.setConfig(FIND_REPLACE_PLUGIN_CONFIG_KEY, rest);
|
|
1501
|
+
}
|
|
1502
|
+
onStarting() {
|
|
1503
|
+
this._injector.add([MobileComponentsController]);
|
|
1504
|
+
this._injector.get(MobileComponentsController);
|
|
1505
|
+
[[FindReplaceMobileController], [IFindReplaceService, { useClass: FindReplaceService }]].forEach((dependency) => this._injector.add(dependency));
|
|
1506
|
+
}
|
|
1507
|
+
onRendered() {
|
|
1508
|
+
this._injector.get(FindReplaceMobileController);
|
|
1509
|
+
}
|
|
1510
|
+
};
|
|
1511
|
+
_defineProperty(UniverFindReplaceMobileUIPlugin, "pluginName", "UNIVER_FIND_REPLACE_PLUGIN");
|
|
1512
|
+
_defineProperty(UniverFindReplaceMobileUIPlugin, "packageName", name);
|
|
1513
|
+
_defineProperty(UniverFindReplaceMobileUIPlugin, "version", version);
|
|
1514
|
+
UniverFindReplaceMobileUIPlugin = __decorate([
|
|
1515
|
+
(0, _univerjs_core.DependentOn)(_univerjs_ui.UniverMobileUIPlugin),
|
|
1516
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1517
|
+
__decorateParam(2, _univerjs_core.IConfigService)
|
|
1518
|
+
], UniverFindReplaceMobileUIPlugin);
|
|
1519
|
+
|
|
1024
1520
|
//#endregion
|
|
1025
1521
|
//#region src/views/dialog/SearchInput.tsx
|
|
1026
1522
|
function SearchInput(props) {
|
|
@@ -1082,10 +1578,18 @@ const FIND_BY_OPTIONS = [{
|
|
|
1082
1578
|
value: "formula"
|
|
1083
1579
|
}];
|
|
1084
1580
|
function useFindInputFocus(findReplaceService, ref) {
|
|
1581
|
+
const pendingFocusFrameRef = (0, react.useRef)(null);
|
|
1085
1582
|
const focus = (0, react.useCallback)(() => {
|
|
1086
1583
|
var _document$querySelect;
|
|
1087
1584
|
(_document$querySelect = document.querySelector(".univer-find-input input")) === null || _document$querySelect === void 0 || _document$querySelect.focus();
|
|
1088
1585
|
}, []);
|
|
1586
|
+
const focusAfterDialogClose = (0, react.useCallback)(() => {
|
|
1587
|
+
focus();
|
|
1588
|
+
pendingFocusFrameRef.current = requestAnimationFrame(() => {
|
|
1589
|
+
pendingFocusFrameRef.current = null;
|
|
1590
|
+
focus();
|
|
1591
|
+
});
|
|
1592
|
+
}, [focus]);
|
|
1089
1593
|
const selectHasFocus = (0, react.useCallback)(() => {
|
|
1090
1594
|
const allInputs = document.querySelectorAll("[data-u-comp=find-replace-dialog] [data-u-comp=search-input]");
|
|
1091
1595
|
return Array.from(allInputs).some((input) => input === document.activeElement);
|
|
@@ -1096,10 +1600,14 @@ function useFindInputFocus(findReplaceService, ref) {
|
|
|
1096
1600
|
}));
|
|
1097
1601
|
(0, react.useEffect)(() => {
|
|
1098
1602
|
const subscription = findReplaceService.focusSignal$.subscribe(() => focus());
|
|
1099
|
-
return () =>
|
|
1603
|
+
return () => {
|
|
1604
|
+
subscription.unsubscribe();
|
|
1605
|
+
if (pendingFocusFrameRef.current !== null) cancelAnimationFrame(pendingFocusFrameRef.current);
|
|
1606
|
+
};
|
|
1100
1607
|
}, [findReplaceService, focus]);
|
|
1101
1608
|
return {
|
|
1102
1609
|
focus,
|
|
1610
|
+
focusAfterDialogClose,
|
|
1103
1611
|
selectHasFocus
|
|
1104
1612
|
};
|
|
1105
1613
|
}
|
|
@@ -1145,7 +1653,7 @@ const ReplaceDialog = (0, react.forwardRef)(function ReplaceDialogImpl(_props, r
|
|
|
1145
1653
|
const replaceAllDisabled = replaceables.length === 0;
|
|
1146
1654
|
const onFindStringChange = (0, react.useCallback)((newValue) => findReplaceService.changeInputtingFindString(newValue), [findReplaceService]);
|
|
1147
1655
|
const onReplaceStringChange = (0, react.useCallback)((replaceString) => findReplaceService.changeReplaceString(replaceString), [findReplaceService]);
|
|
1148
|
-
const {
|
|
1656
|
+
const { focusAfterDialogClose } = useFindInputFocus(findReplaceService, ref);
|
|
1149
1657
|
const onClickFindButton = (0, react.useCallback)(() => {
|
|
1150
1658
|
if (findString === inputtingFindString) findReplaceService.moveToNextMatch();
|
|
1151
1659
|
else {
|
|
@@ -1160,8 +1668,8 @@ const ReplaceDialog = (0, react.forwardRef)(function ReplaceDialogImpl(_props, r
|
|
|
1160
1668
|
const onClickReplaceButton = (0, react.useCallback)(() => commandService.executeCommand(ReplaceCurrentMatchCommand.id), [commandService]);
|
|
1161
1669
|
const onClickReplaceAllButton = (0, react.useCallback)(async () => {
|
|
1162
1670
|
await commandService.executeCommand(ReplaceAllMatchesCommand.id);
|
|
1163
|
-
|
|
1164
|
-
}, [commandService,
|
|
1671
|
+
focusAfterDialogClose();
|
|
1672
|
+
}, [commandService, focusAfterDialogClose]);
|
|
1165
1673
|
const onChangeFindDirection = (0, react.useCallback)((findDirection) => {
|
|
1166
1674
|
findReplaceService.changeFindDirection(findDirection);
|
|
1167
1675
|
}, [findReplaceService]);
|
|
@@ -1243,20 +1751,20 @@ const ReplaceDialog = (0, react.forwardRef)(function ReplaceDialogImpl(_props, r
|
|
|
1243
1751
|
capabilities.caseSensitive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
1244
1752
|
checked: caseSensitive,
|
|
1245
1753
|
onChange: (checked) => {
|
|
1246
|
-
findReplaceService.changeCaseSensitive(checked);
|
|
1754
|
+
findReplaceService.changeCaseSensitive(Boolean(checked));
|
|
1247
1755
|
if (findCompleted) findReplaceService.find();
|
|
1248
1756
|
},
|
|
1249
1757
|
children: localeService.t("find-replace.dialog.case-sensitive")
|
|
1250
1758
|
}) }),
|
|
1251
1759
|
capabilities.matchesTheWholeCell && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
1252
1760
|
checked: matchesTheWholeCell,
|
|
1253
|
-
onChange: (checked) => findReplaceService.changeMatchesTheWholeCell(checked),
|
|
1761
|
+
onChange: (checked) => findReplaceService.changeMatchesTheWholeCell(Boolean(checked)),
|
|
1254
1762
|
children: localeService.t("find-replace.dialog.match-the-whole-cell")
|
|
1255
1763
|
}) }),
|
|
1256
1764
|
capabilities.matchesTheWholeWord && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.FormLayout, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
1257
1765
|
checked: matchesTheWholeWord,
|
|
1258
1766
|
onChange: (checked) => {
|
|
1259
|
-
findReplaceService.changeMatchesTheWholeWord(checked);
|
|
1767
|
+
findReplaceService.changeMatchesTheWholeWord(Boolean(checked));
|
|
1260
1768
|
if (findCompleted) findReplaceService.find();
|
|
1261
1769
|
},
|
|
1262
1770
|
children: localeService.t("find-replace.dialog.match-the-whole-word")
|
|
@@ -1385,6 +1893,7 @@ _defineProperty(UniverFindReplacePlugin, "version", version);
|
|
|
1385
1893
|
UniverFindReplacePlugin = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(2, _univerjs_core.IConfigService)], UniverFindReplacePlugin);
|
|
1386
1894
|
|
|
1387
1895
|
//#endregion
|
|
1896
|
+
exports.CloseFindDialogOperation = CloseFindDialogOperation;
|
|
1388
1897
|
exports.FindBy = FindBy;
|
|
1389
1898
|
exports.FindDirection = FindDirection;
|
|
1390
1899
|
exports.FindModel = FindModel;
|
|
@@ -1416,6 +1925,12 @@ exports.OpenFindDialogOperation = OpenFindDialogOperation;
|
|
|
1416
1925
|
exports.OpenReplaceDialogOperation = OpenReplaceDialogOperation;
|
|
1417
1926
|
exports.ReplaceAllMatchesCommand = ReplaceAllMatchesCommand;
|
|
1418
1927
|
exports.ReplaceCurrentMatchCommand = ReplaceCurrentMatchCommand;
|
|
1928
|
+
Object.defineProperty(exports, 'UniverFindReplaceMobileUIPlugin', {
|
|
1929
|
+
enumerable: true,
|
|
1930
|
+
get: function () {
|
|
1931
|
+
return UniverFindReplaceMobileUIPlugin;
|
|
1932
|
+
}
|
|
1933
|
+
});
|
|
1419
1934
|
Object.defineProperty(exports, 'UniverFindReplacePlugin', {
|
|
1420
1935
|
enumerable: true,
|
|
1421
1936
|
get: function () {
|