@univerjs/find-replace 0.25.1 → 1.0.0-alpha.1
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/lib/cjs/index.js +237 -199
- package/lib/cjs/locale/ar-SA.js +1 -0
- package/lib/cjs/locale/ca-ES.js +1 -0
- package/lib/cjs/locale/de-DE.js +1 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/es-ES.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/fr-FR.js +1 -0
- package/lib/cjs/locale/id-ID.js +1 -0
- package/lib/cjs/locale/it-IT.js +1 -0
- package/lib/cjs/locale/ja-JP.js +1 -0
- package/lib/cjs/locale/ko-KR.js +1 -0
- package/lib/cjs/locale/pl-PL.js +1 -0
- package/lib/cjs/locale/pt-BR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/sk-SK.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-HK.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/index.js +233 -201
- package/lib/es/locale/ar-SA.js +1 -0
- package/lib/es/locale/ca-ES.js +1 -0
- package/lib/es/locale/de-DE.js +1 -0
- package/lib/es/locale/en-US.js +1 -0
- package/lib/es/locale/es-ES.js +1 -0
- package/lib/es/locale/fa-IR.js +1 -0
- package/lib/es/locale/fr-FR.js +1 -0
- package/lib/es/locale/id-ID.js +1 -0
- package/lib/es/locale/it-IT.js +1 -0
- package/lib/es/locale/ja-JP.js +1 -0
- package/lib/es/locale/ko-KR.js +1 -0
- package/lib/es/locale/pl-PL.js +1 -0
- package/lib/es/locale/pt-BR.js +1 -0
- package/lib/es/locale/ru-RU.js +1 -0
- package/lib/es/locale/sk-SK.js +1 -0
- package/lib/es/locale/vi-VN.js +1 -0
- package/lib/es/locale/zh-CN.js +1 -0
- package/lib/es/locale/zh-HK.js +1 -0
- package/lib/es/locale/zh-TW.js +1 -0
- package/lib/index.js +233 -201
- package/lib/locale/ar-SA.js +1 -0
- package/lib/locale/ca-ES.js +1 -0
- package/lib/locale/de-DE.js +1 -0
- package/lib/locale/en-US.js +1 -0
- package/lib/locale/es-ES.js +1 -0
- package/lib/locale/fa-IR.js +1 -0
- package/lib/locale/fr-FR.js +1 -0
- package/lib/locale/id-ID.js +1 -0
- package/lib/locale/it-IT.js +1 -0
- package/lib/locale/ja-JP.js +1 -0
- package/lib/locale/ko-KR.js +1 -0
- package/lib/locale/pl-PL.js +1 -0
- package/lib/locale/pt-BR.js +1 -0
- package/lib/locale/ru-RU.js +1 -0
- package/lib/locale/sk-SK.js +1 -0
- package/lib/locale/vi-VN.js +1 -0
- package/lib/locale/zh-CN.js +1 -0
- package/lib/locale/zh-HK.js +1 -0
- package/lib/locale/zh-TW.js +1 -0
- package/lib/types/controllers/components.controller.d.ts +24 -0
- package/lib/types/controllers/find-replace.controller.d.ts +2 -3
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/en-US.d.ts +1 -0
- package/lib/types/locale/types.d.ts +18 -0
- package/lib/types/menu/find-replace.menu.d.ts +2 -1
- package/lib/types/views/dialog/FindReplaceDialog.d.ts +1 -1
- package/lib/types/views/dialog/FindReplaceDialog.stories.d.ts +2 -2
- package/lib/types/views/dialog/SearchInput.d.ts +1 -3
- 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 +8 -8
package/lib/cjs/locale/zh-CN.js
CHANGED
package/lib/cjs/locale/zh-HK.js
CHANGED
package/lib/cjs/locale/zh-TW.js
CHANGED
package/lib/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandType, Disposable, DisposableCollection, EDITOR_ACTIVATED, FOCUSING_SHEET, ICommandService, IConfigService, IConfirmService, IContextService, IUniverInstanceService, Inject, Injector, LocaleService, Plugin, RxDisposable, UniverInstanceType, createIdentifier, merge, toDisposable } from "@univerjs/core";
|
|
2
2
|
import { Button, Checkbox, FormDualColumnLayout, FormLayout, Input, MessageType, Pager, Select } from "@univerjs/design";
|
|
3
|
-
import { ComponentManager, IDialogService, ILayoutService, IMenuManagerService, IMessageService, IShortcutService, KeyCode, MenuItemType, MetaKeys, RibbonDataGroup, getMenuHiddenObservable, useDebounceFn, useDependency, useObservable } from "@univerjs/ui";
|
|
3
|
+
import { ComponentManager, IDialogService, ILayoutService, IMenuManagerService, IMessageService, IShortcutService, IconManager, KeyCode, MenuItemType, MetaKeys, RibbonDataGroup, getMenuHiddenObservable, useDebounceFn, useDependency, useObservable } from "@univerjs/ui";
|
|
4
4
|
import { RENDER_RAW_FORMULA_KEY } from "@univerjs/engine-render";
|
|
5
5
|
import { BehaviorSubject, Subject, combineLatest, debounceTime, fromEvent, map, takeUntil, throttleTime } from "rxjs";
|
|
6
6
|
import { SearchIcon } from "@univerjs/icons";
|
|
@@ -34,7 +34,7 @@ const FIND_REPLACE_DIALOG_FOCUS = "FIND_REPLACE_DIALOG_FOCUS";
|
|
|
34
34
|
const FIND_REPLACE_REPLACE_REVEALED = "FIND_REPLACE_REPLACE_REVEALED";
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
38
38
|
function _typeof(o) {
|
|
39
39
|
"@babel/helpers - typeof";
|
|
40
40
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -45,7 +45,7 @@ function _typeof(o) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
//#endregion
|
|
48
|
-
//#region \0@oxc-project+runtime@0.
|
|
48
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
49
49
|
function toPrimitive(t, r) {
|
|
50
50
|
if ("object" != _typeof(t) || !t) return t;
|
|
51
51
|
var e = t[Symbol.toPrimitive];
|
|
@@ -58,14 +58,14 @@ function toPrimitive(t, r) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
//#endregion
|
|
61
|
-
//#region \0@oxc-project+runtime@0.
|
|
61
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
62
62
|
function toPropertyKey(t) {
|
|
63
63
|
var i = toPrimitive(t, "string");
|
|
64
64
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
//#endregion
|
|
68
|
-
//#region \0@oxc-project+runtime@0.
|
|
68
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
69
69
|
function _defineProperty(e, r, t) {
|
|
70
70
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
71
71
|
value: t,
|
|
@@ -76,7 +76,7 @@ function _defineProperty(e, r, t) {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
//#endregion
|
|
79
|
-
//#region \0@oxc-project+runtime@0.
|
|
79
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
80
80
|
function __decorateParam(paramIndex, decorator) {
|
|
81
81
|
return function(target, key) {
|
|
82
82
|
decorator(target, key, paramIndex);
|
|
@@ -84,7 +84,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
//#endregion
|
|
87
|
-
//#region \0@oxc-project+runtime@0.
|
|
87
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
88
88
|
function __decorate(decorators, target, key, desc) {
|
|
89
89
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
90
90
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -779,10 +779,206 @@ const menuSchema = { [RibbonDataGroup.ORGANIZATION]: { [OpenFindDialogOperation.
|
|
|
779
779
|
menuItemFactory: FindReplaceMenuItemFactory
|
|
780
780
|
} } };
|
|
781
781
|
|
|
782
|
+
//#endregion
|
|
783
|
+
//#region src/controllers/find-replace.shortcut.ts
|
|
784
|
+
function whenFindReplaceDialogFocused(contextService) {
|
|
785
|
+
return contextService.getContextValue(FIND_REPLACE_DIALOG_FOCUS);
|
|
786
|
+
}
|
|
787
|
+
function whenReplaceRevealed(contextService) {
|
|
788
|
+
return contextService.getContextValue(FIND_REPLACE_REPLACE_REVEALED);
|
|
789
|
+
}
|
|
790
|
+
function whenFindReplaceInputFocused(contextService) {
|
|
791
|
+
return contextService.getContextValue(FIND_REPLACE_INPUT_FOCUS);
|
|
792
|
+
}
|
|
793
|
+
const FIND_REPLACE_SHORTCUT_GROUP = "7_find-replace-shortcuts";
|
|
794
|
+
function whenSheetFocused(contextService) {
|
|
795
|
+
return contextService.getContextValue(FOCUSING_SHEET);
|
|
796
|
+
}
|
|
797
|
+
function whenEditorNotActivated(contextService) {
|
|
798
|
+
return !contextService.getContextValue(EDITOR_ACTIVATED);
|
|
799
|
+
}
|
|
800
|
+
const OpenFindDialogShortcutItem = {
|
|
801
|
+
id: OpenFindDialogOperation.id,
|
|
802
|
+
description: "find-replace.shortcut.open-find-dialog",
|
|
803
|
+
binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
|
|
804
|
+
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
805
|
+
groupTitle: "find-replace.shortcut.panel",
|
|
806
|
+
preconditions(contextService) {
|
|
807
|
+
return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
const MacOpenFindDialogShortcutItem = {
|
|
811
|
+
id: OpenFindDialogOperation.id,
|
|
812
|
+
description: "find-replace.shortcut.open-find-dialog",
|
|
813
|
+
binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
|
|
814
|
+
mac: KeyCode.F | MetaKeys.MAC_CTRL,
|
|
815
|
+
preconditions(contextService) {
|
|
816
|
+
return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
const OpenReplaceDialogShortcutItem = {
|
|
820
|
+
id: OpenReplaceDialogOperation.id,
|
|
821
|
+
description: "find-replace.shortcut.open-replace-dialog",
|
|
822
|
+
binding: KeyCode.H | MetaKeys.CTRL_COMMAND,
|
|
823
|
+
mac: KeyCode.H | MetaKeys.MAC_CTRL,
|
|
824
|
+
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
825
|
+
groupTitle: "find-replace.shortcut.panel",
|
|
826
|
+
preconditions(contextService) {
|
|
827
|
+
return whenSheetFocused(contextService) && whenEditorNotActivated(contextService) && (!whenFindReplaceDialogFocused(contextService) || !whenReplaceRevealed(contextService));
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
const GoToNextFindMatchShortcutItem = {
|
|
831
|
+
id: GoToNextMatchOperation.id,
|
|
832
|
+
description: "find-replace.shortcut.go-to-next-match",
|
|
833
|
+
binding: KeyCode.ENTER,
|
|
834
|
+
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
835
|
+
groupTitle: "find-replace.shortcut.panel",
|
|
836
|
+
priority: 1e3,
|
|
837
|
+
preconditions(contextService) {
|
|
838
|
+
return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
const GoToPreviousFindMatchShortcutItem = {
|
|
842
|
+
id: GoToPreviousMatchOperation.id,
|
|
843
|
+
description: "find-replace.shortcut.go-to-previous-match",
|
|
844
|
+
binding: KeyCode.ENTER | MetaKeys.SHIFT,
|
|
845
|
+
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
846
|
+
groupTitle: "find-replace.shortcut.panel",
|
|
847
|
+
priority: 1e3,
|
|
848
|
+
preconditions(contextService) {
|
|
849
|
+
return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
const FocusSelectionShortcutItem = {
|
|
853
|
+
id: FocusSelectionOperation.id,
|
|
854
|
+
description: "find-replace.shortcut.focus-selection",
|
|
855
|
+
binding: KeyCode.ESC,
|
|
856
|
+
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
857
|
+
groupTitle: "find-replace.shortcut.panel",
|
|
858
|
+
priority: 1e3,
|
|
859
|
+
preconditions(contextService) {
|
|
860
|
+
return whenFindReplaceDialogFocused(contextService);
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
|
|
864
|
+
//#endregion
|
|
865
|
+
//#region src/controllers/find-replace.controller.ts
|
|
866
|
+
const FIND_REPLACE_DIALOG_ID = "DESKTOP_FIND_REPLACE_DIALOG";
|
|
867
|
+
const FIND_REPLACE_PANEL_WIDTH = 350;
|
|
868
|
+
const FIND_REPLACE_PANEL_RIGHT_PADDING = 20;
|
|
869
|
+
const FIND_REPLACE_PANEL_TOP_PADDING = 64;
|
|
870
|
+
let FindReplaceController = class FindReplaceController extends RxDisposable {
|
|
871
|
+
constructor(_univerInstanceService, _menuManagerService, _shortcutService, _commandService, _findReplaceService, _dialogService, _layoutService, _localeService) {
|
|
872
|
+
super();
|
|
873
|
+
this._univerInstanceService = _univerInstanceService;
|
|
874
|
+
this._menuManagerService = _menuManagerService;
|
|
875
|
+
this._shortcutService = _shortcutService;
|
|
876
|
+
this._commandService = _commandService;
|
|
877
|
+
this._findReplaceService = _findReplaceService;
|
|
878
|
+
this._dialogService = _dialogService;
|
|
879
|
+
this._layoutService = _layoutService;
|
|
880
|
+
this._localeService = _localeService;
|
|
881
|
+
_defineProperty(this, "_closingListenerDisposable", void 0);
|
|
882
|
+
this._initCommands();
|
|
883
|
+
this._initUI();
|
|
884
|
+
this._initShortcuts();
|
|
885
|
+
}
|
|
886
|
+
dispose() {
|
|
887
|
+
var _this$_closingListene;
|
|
888
|
+
super.dispose();
|
|
889
|
+
(_this$_closingListene = this._closingListenerDisposable) === null || _this$_closingListene === void 0 || _this$_closingListene.dispose();
|
|
890
|
+
this._closingListenerDisposable = null;
|
|
891
|
+
}
|
|
892
|
+
_initCommands() {
|
|
893
|
+
[
|
|
894
|
+
OpenFindDialogOperation,
|
|
895
|
+
OpenReplaceDialogOperation,
|
|
896
|
+
GoToNextMatchOperation,
|
|
897
|
+
GoToPreviousMatchOperation,
|
|
898
|
+
ReplaceAllMatchesCommand,
|
|
899
|
+
ReplaceCurrentMatchCommand,
|
|
900
|
+
FocusSelectionOperation
|
|
901
|
+
].forEach((c) => {
|
|
902
|
+
this.disposeWithMe(this._commandService.registerCommand(c));
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
_initShortcuts() {
|
|
906
|
+
[
|
|
907
|
+
OpenReplaceDialogShortcutItem,
|
|
908
|
+
OpenFindDialogShortcutItem,
|
|
909
|
+
MacOpenFindDialogShortcutItem,
|
|
910
|
+
GoToPreviousFindMatchShortcutItem,
|
|
911
|
+
GoToNextFindMatchShortcutItem,
|
|
912
|
+
FocusSelectionShortcutItem
|
|
913
|
+
].forEach((s) => this.disposeWithMe(this._shortcutService.registerShortcut(s)));
|
|
914
|
+
}
|
|
915
|
+
_initUI() {
|
|
916
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
917
|
+
this._findReplaceService.stateUpdates$.pipe(takeUntil(this.dispose$)).subscribe((newState) => {
|
|
918
|
+
if (newState.revealed === true) this._openPanel();
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
_openPanel() {
|
|
922
|
+
this._dialogService.open({
|
|
923
|
+
id: FIND_REPLACE_DIALOG_ID,
|
|
924
|
+
draggable: true,
|
|
925
|
+
width: FIND_REPLACE_PANEL_WIDTH,
|
|
926
|
+
title: { title: this._localeService.t("find-replace.dialog.title") },
|
|
927
|
+
children: { label: "FindReplaceDialog" },
|
|
928
|
+
destroyOnClose: true,
|
|
929
|
+
mask: false,
|
|
930
|
+
maskClosable: false,
|
|
931
|
+
defaultPosition: getFindReplaceDialogDefaultPosition(),
|
|
932
|
+
preservePositionOnDestroy: true,
|
|
933
|
+
onClose: () => this.closePanel()
|
|
934
|
+
});
|
|
935
|
+
this._closingListenerDisposable = toDisposable(this._univerInstanceService.focused$.pipe(takeUntil(this.dispose$)).subscribe((focused) => {
|
|
936
|
+
if (!focused || !this._univerInstanceService.getUniverSheetInstance(focused)) this.closePanel();
|
|
937
|
+
}));
|
|
938
|
+
}
|
|
939
|
+
closePanel() {
|
|
940
|
+
if (!this._closingListenerDisposable) return;
|
|
941
|
+
this._closingListenerDisposable.dispose();
|
|
942
|
+
this._closingListenerDisposable = null;
|
|
943
|
+
this._dialogService.close(FIND_REPLACE_DIALOG_ID);
|
|
944
|
+
this._findReplaceService.terminate();
|
|
945
|
+
queueMicrotask(() => this._layoutService.focus());
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
FindReplaceController = __decorate([
|
|
949
|
+
__decorateParam(0, IUniverInstanceService),
|
|
950
|
+
__decorateParam(1, IMenuManagerService),
|
|
951
|
+
__decorateParam(2, IShortcutService),
|
|
952
|
+
__decorateParam(3, ICommandService),
|
|
953
|
+
__decorateParam(4, IFindReplaceService),
|
|
954
|
+
__decorateParam(5, IDialogService),
|
|
955
|
+
__decorateParam(6, ILayoutService),
|
|
956
|
+
__decorateParam(7, Inject(LocaleService))
|
|
957
|
+
], FindReplaceController);
|
|
958
|
+
function getFindReplaceDialogDefaultPosition() {
|
|
959
|
+
const { innerWidth } = window;
|
|
960
|
+
return {
|
|
961
|
+
x: innerWidth - FIND_REPLACE_PANEL_WIDTH - FIND_REPLACE_PANEL_RIGHT_PADDING,
|
|
962
|
+
y: FIND_REPLACE_PANEL_TOP_PADDING
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
//#endregion
|
|
967
|
+
//#region package.json
|
|
968
|
+
var name = "@univerjs/find-replace";
|
|
969
|
+
var version = "1.0.0-alpha.1";
|
|
970
|
+
|
|
971
|
+
//#endregion
|
|
972
|
+
//#region src/config/config.ts
|
|
973
|
+
const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
|
|
974
|
+
const configSymbol = Symbol(FIND_REPLACE_PLUGIN_CONFIG_KEY);
|
|
975
|
+
const defaultPluginConfig = {};
|
|
976
|
+
|
|
782
977
|
//#endregion
|
|
783
978
|
//#region src/views/dialog/SearchInput.tsx
|
|
784
979
|
function SearchInput(props) {
|
|
785
|
-
const { findCompleted: findComplete,
|
|
980
|
+
const { findCompleted: findComplete, matchesCount, matchesPosition, initialFindString, findReplaceService, onChange, ...rest } = props;
|
|
981
|
+
const localeService = useDependency(LocaleService);
|
|
786
982
|
const [value, setValue] = useState(initialFindString);
|
|
787
983
|
const text = findComplete && matchesCount === 0 ? localeService.t("find-replace.dialog.no-result") : matchesCount === 0 ? " " : void 0;
|
|
788
984
|
function handleChangePosition(newIndex) {
|
|
@@ -856,7 +1052,6 @@ const FindDialog = forwardRef(function FindDialogImpl(_props, ref) {
|
|
|
856
1052
|
matchesCount,
|
|
857
1053
|
matchesPosition,
|
|
858
1054
|
findReplaceService,
|
|
859
|
-
localeService,
|
|
860
1055
|
initialFindString: findString,
|
|
861
1056
|
onChange: onFindStringChange
|
|
862
1057
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -931,7 +1126,6 @@ const ReplaceDialog = forwardRef(function ReplaceDialogImpl(_props, ref) {
|
|
|
931
1126
|
matchesCount,
|
|
932
1127
|
matchesPosition,
|
|
933
1128
|
findReplaceService,
|
|
934
|
-
localeService,
|
|
935
1129
|
initialFindString: inputtingFindString,
|
|
936
1130
|
onChange: onFindStringChange
|
|
937
1131
|
})
|
|
@@ -1074,204 +1268,40 @@ function useFindByOptions(localeService) {
|
|
|
1074
1268
|
}
|
|
1075
1269
|
|
|
1076
1270
|
//#endregion
|
|
1077
|
-
//#region src/controllers/
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
id: OpenFindDialogOperation.id,
|
|
1096
|
-
description: "find-replace.shortcut.open-find-dialog",
|
|
1097
|
-
binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
|
|
1098
|
-
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
1099
|
-
groupTitle: "find-replace.shortcut.panel",
|
|
1100
|
-
preconditions(contextService) {
|
|
1101
|
-
return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
|
|
1102
|
-
}
|
|
1103
|
-
};
|
|
1104
|
-
const MacOpenFindDialogShortcutItem = {
|
|
1105
|
-
id: OpenFindDialogOperation.id,
|
|
1106
|
-
description: "find-replace.shortcut.open-find-dialog",
|
|
1107
|
-
binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
|
|
1108
|
-
mac: KeyCode.F | MetaKeys.MAC_CTRL,
|
|
1109
|
-
preconditions(contextService) {
|
|
1110
|
-
return !whenFindReplaceDialogFocused(contextService) && whenSheetFocused(contextService) && whenEditorNotActivated(contextService);
|
|
1111
|
-
}
|
|
1112
|
-
};
|
|
1113
|
-
const OpenReplaceDialogShortcutItem = {
|
|
1114
|
-
id: OpenReplaceDialogOperation.id,
|
|
1115
|
-
description: "find-replace.shortcut.open-replace-dialog",
|
|
1116
|
-
binding: KeyCode.H | MetaKeys.CTRL_COMMAND,
|
|
1117
|
-
mac: KeyCode.H | MetaKeys.MAC_CTRL,
|
|
1118
|
-
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
1119
|
-
groupTitle: "find-replace.shortcut.panel",
|
|
1120
|
-
preconditions(contextService) {
|
|
1121
|
-
return whenSheetFocused(contextService) && whenEditorNotActivated(contextService) && (!whenFindReplaceDialogFocused(contextService) || !whenReplaceRevealed(contextService));
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
const GoToNextFindMatchShortcutItem = {
|
|
1125
|
-
id: GoToNextMatchOperation.id,
|
|
1126
|
-
description: "find-replace.shortcut.go-to-next-match",
|
|
1127
|
-
binding: KeyCode.ENTER,
|
|
1128
|
-
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
1129
|
-
groupTitle: "find-replace.shortcut.panel",
|
|
1130
|
-
priority: 1e3,
|
|
1131
|
-
preconditions(contextService) {
|
|
1132
|
-
return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
|
|
1133
|
-
}
|
|
1134
|
-
};
|
|
1135
|
-
const GoToPreviousFindMatchShortcutItem = {
|
|
1136
|
-
id: GoToPreviousMatchOperation.id,
|
|
1137
|
-
description: "find-replace.shortcut.go-to-previous-match",
|
|
1138
|
-
binding: KeyCode.ENTER | MetaKeys.SHIFT,
|
|
1139
|
-
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
1140
|
-
groupTitle: "find-replace.shortcut.panel",
|
|
1141
|
-
priority: 1e3,
|
|
1142
|
-
preconditions(contextService) {
|
|
1143
|
-
return whenFindReplaceInputFocused(contextService) && whenFindReplaceDialogFocused(contextService);
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1146
|
-
const FocusSelectionShortcutItem = {
|
|
1147
|
-
id: FocusSelectionOperation.id,
|
|
1148
|
-
description: "find-replace.shortcut.focus-selection",
|
|
1149
|
-
binding: KeyCode.ESC,
|
|
1150
|
-
group: FIND_REPLACE_SHORTCUT_GROUP,
|
|
1151
|
-
groupTitle: "find-replace.shortcut.panel",
|
|
1152
|
-
priority: 1e3,
|
|
1153
|
-
preconditions(contextService) {
|
|
1154
|
-
return whenFindReplaceDialogFocused(contextService);
|
|
1155
|
-
}
|
|
1156
|
-
};
|
|
1157
|
-
|
|
1158
|
-
//#endregion
|
|
1159
|
-
//#region src/controllers/find-replace.controller.ts
|
|
1160
|
-
const FIND_REPLACE_DIALOG_ID = "DESKTOP_FIND_REPLACE_DIALOG";
|
|
1161
|
-
const FIND_REPLACE_PANEL_WIDTH = 350;
|
|
1162
|
-
const FIND_REPLACE_PANEL_RIGHT_PADDING = 20;
|
|
1163
|
-
const FIND_REPLACE_PANEL_TOP_PADDING = 64;
|
|
1164
|
-
let FindReplaceController = class FindReplaceController extends RxDisposable {
|
|
1165
|
-
constructor(_univerInstanceService, _menuManagerService, _shortcutService, _commandService, _findReplaceService, _dialogService, _layoutService, _localeService, _componentManager) {
|
|
1271
|
+
//#region src/controllers/components.controller.ts
|
|
1272
|
+
/**
|
|
1273
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1274
|
+
*
|
|
1275
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1276
|
+
* you may not use this file except in compliance with the License.
|
|
1277
|
+
* You may obtain a copy of the License at
|
|
1278
|
+
*
|
|
1279
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1280
|
+
*
|
|
1281
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1282
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1283
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1284
|
+
* See the License for the specific language governing permissions and
|
|
1285
|
+
* limitations under the License.
|
|
1286
|
+
*/
|
|
1287
|
+
let ComponentsController = class ComponentsController extends Disposable {
|
|
1288
|
+
constructor(_componentManager, _iconManager) {
|
|
1166
1289
|
super();
|
|
1167
|
-
this._univerInstanceService = _univerInstanceService;
|
|
1168
|
-
this._menuManagerService = _menuManagerService;
|
|
1169
|
-
this._shortcutService = _shortcutService;
|
|
1170
|
-
this._commandService = _commandService;
|
|
1171
|
-
this._findReplaceService = _findReplaceService;
|
|
1172
|
-
this._dialogService = _dialogService;
|
|
1173
|
-
this._layoutService = _layoutService;
|
|
1174
|
-
this._localeService = _localeService;
|
|
1175
1290
|
this._componentManager = _componentManager;
|
|
1176
|
-
|
|
1177
|
-
this.
|
|
1178
|
-
this.
|
|
1179
|
-
this._initShortcuts();
|
|
1291
|
+
this._iconManager = _iconManager;
|
|
1292
|
+
this._registerIcons();
|
|
1293
|
+
this._registerComponents();
|
|
1180
1294
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
super.dispose();
|
|
1184
|
-
(_this$_closingListene = this._closingListenerDisposable) === null || _this$_closingListene === void 0 || _this$_closingListene.dispose();
|
|
1185
|
-
this._closingListenerDisposable = null;
|
|
1295
|
+
_registerIcons() {
|
|
1296
|
+
this.disposeWithMe(this._iconManager.register({ SearchIcon }));
|
|
1186
1297
|
}
|
|
1187
|
-
|
|
1188
|
-
[
|
|
1189
|
-
OpenFindDialogOperation,
|
|
1190
|
-
OpenReplaceDialogOperation,
|
|
1191
|
-
GoToNextMatchOperation,
|
|
1192
|
-
GoToPreviousMatchOperation,
|
|
1193
|
-
ReplaceAllMatchesCommand,
|
|
1194
|
-
ReplaceCurrentMatchCommand,
|
|
1195
|
-
FocusSelectionOperation
|
|
1196
|
-
].forEach((c) => {
|
|
1197
|
-
this.disposeWithMe(this._commandService.registerCommand(c));
|
|
1198
|
-
});
|
|
1199
|
-
}
|
|
1200
|
-
_initShortcuts() {
|
|
1201
|
-
[
|
|
1202
|
-
OpenReplaceDialogShortcutItem,
|
|
1203
|
-
OpenFindDialogShortcutItem,
|
|
1204
|
-
MacOpenFindDialogShortcutItem,
|
|
1205
|
-
GoToPreviousFindMatchShortcutItem,
|
|
1206
|
-
GoToNextFindMatchShortcutItem,
|
|
1207
|
-
FocusSelectionShortcutItem
|
|
1208
|
-
].forEach((s) => this.disposeWithMe(this._shortcutService.registerShortcut(s)));
|
|
1209
|
-
}
|
|
1210
|
-
_initUI() {
|
|
1211
|
-
[["FindReplaceDialog", FindReplaceDialog], ["SearchIcon", SearchIcon]].forEach(([key, comp]) => {
|
|
1298
|
+
_registerComponents() {
|
|
1299
|
+
[["FindReplaceDialog", FindReplaceDialog]].forEach(([key, comp]) => {
|
|
1212
1300
|
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
1213
1301
|
});
|
|
1214
|
-
this._menuManagerService.mergeMenu(menuSchema);
|
|
1215
|
-
this._findReplaceService.stateUpdates$.pipe(takeUntil(this.dispose$)).subscribe((newState) => {
|
|
1216
|
-
if (newState.revealed === true) this._openPanel();
|
|
1217
|
-
});
|
|
1218
|
-
}
|
|
1219
|
-
_openPanel() {
|
|
1220
|
-
this._dialogService.open({
|
|
1221
|
-
id: FIND_REPLACE_DIALOG_ID,
|
|
1222
|
-
draggable: true,
|
|
1223
|
-
width: FIND_REPLACE_PANEL_WIDTH,
|
|
1224
|
-
title: { title: this._localeService.t("find-replace.dialog.title") },
|
|
1225
|
-
children: { label: "FindReplaceDialog" },
|
|
1226
|
-
destroyOnClose: true,
|
|
1227
|
-
mask: false,
|
|
1228
|
-
maskClosable: false,
|
|
1229
|
-
defaultPosition: getFindReplaceDialogDefaultPosition(),
|
|
1230
|
-
preservePositionOnDestroy: true,
|
|
1231
|
-
onClose: () => this.closePanel()
|
|
1232
|
-
});
|
|
1233
|
-
this._closingListenerDisposable = toDisposable(this._univerInstanceService.focused$.pipe(takeUntil(this.dispose$)).subscribe((focused) => {
|
|
1234
|
-
if (!focused || !this._univerInstanceService.getUniverSheetInstance(focused)) this.closePanel();
|
|
1235
|
-
}));
|
|
1236
|
-
}
|
|
1237
|
-
closePanel() {
|
|
1238
|
-
if (!this._closingListenerDisposable) return;
|
|
1239
|
-
this._closingListenerDisposable.dispose();
|
|
1240
|
-
this._closingListenerDisposable = null;
|
|
1241
|
-
this._dialogService.close(FIND_REPLACE_DIALOG_ID);
|
|
1242
|
-
this._findReplaceService.terminate();
|
|
1243
|
-
queueMicrotask(() => this._layoutService.focus());
|
|
1244
1302
|
}
|
|
1245
1303
|
};
|
|
1246
|
-
|
|
1247
|
-
__decorateParam(0, IUniverInstanceService),
|
|
1248
|
-
__decorateParam(1, IMenuManagerService),
|
|
1249
|
-
__decorateParam(2, IShortcutService),
|
|
1250
|
-
__decorateParam(3, ICommandService),
|
|
1251
|
-
__decorateParam(4, IFindReplaceService),
|
|
1252
|
-
__decorateParam(5, IDialogService),
|
|
1253
|
-
__decorateParam(6, ILayoutService),
|
|
1254
|
-
__decorateParam(7, Inject(LocaleService)),
|
|
1255
|
-
__decorateParam(8, Inject(ComponentManager))
|
|
1256
|
-
], FindReplaceController);
|
|
1257
|
-
function getFindReplaceDialogDefaultPosition() {
|
|
1258
|
-
const { innerWidth } = window;
|
|
1259
|
-
return {
|
|
1260
|
-
x: innerWidth - FIND_REPLACE_PANEL_WIDTH - FIND_REPLACE_PANEL_RIGHT_PADDING,
|
|
1261
|
-
y: FIND_REPLACE_PANEL_TOP_PADDING
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
//#endregion
|
|
1266
|
-
//#region package.json
|
|
1267
|
-
var name = "@univerjs/find-replace";
|
|
1268
|
-
var version = "0.25.1";
|
|
1269
|
-
|
|
1270
|
-
//#endregion
|
|
1271
|
-
//#region src/config/config.ts
|
|
1272
|
-
const FIND_REPLACE_PLUGIN_CONFIG_KEY = "find-replace.config";
|
|
1273
|
-
const configSymbol = Symbol(FIND_REPLACE_PLUGIN_CONFIG_KEY);
|
|
1274
|
-
const defaultPluginConfig = {};
|
|
1304
|
+
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
1275
1305
|
|
|
1276
1306
|
//#endregion
|
|
1277
1307
|
//#region src/plugin.ts
|
|
@@ -1285,6 +1315,8 @@ let UniverFindReplacePlugin = class UniverFindReplacePlugin extends Plugin {
|
|
|
1285
1315
|
this._configService.setConfig(FIND_REPLACE_PLUGIN_CONFIG_KEY, rest);
|
|
1286
1316
|
}
|
|
1287
1317
|
onStarting() {
|
|
1318
|
+
this._injector.add([ComponentsController]);
|
|
1319
|
+
this._injector.get(ComponentsController);
|
|
1288
1320
|
[[FindReplaceController], [IFindReplaceService, { useClass: FindReplaceService }]].forEach((d) => this._injector.add(d));
|
|
1289
1321
|
}
|
|
1290
1322
|
onRendered() {
|
|
@@ -1297,4 +1329,4 @@ _defineProperty(UniverFindReplacePlugin, "version", version);
|
|
|
1297
1329
|
UniverFindReplacePlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverFindReplacePlugin);
|
|
1298
1330
|
|
|
1299
1331
|
//#endregion
|
|
1300
|
-
export { FindBy, FindDirection, FindModel, FindReplaceController, FindReplaceModel, FindReplaceState, FindScope, GoToNextMatchOperation, GoToPreviousMatchOperation, IFindReplaceService, OpenFindDialogOperation, OpenReplaceDialogOperation, ReplaceAllMatchesCommand, ReplaceCurrentMatchCommand, UniverFindReplacePlugin, createInitFindReplaceState };
|
|
1332
|
+
export { FindBy, FindDirection, FindModel, FindReplaceController, FindReplaceModel, FindReplaceService, FindReplaceState, FindScope, GoToNextMatchOperation, GoToPreviousMatchOperation, IFindReplaceService, OpenFindDialogOperation, OpenReplaceDialogOperation, ReplaceAllMatchesCommand, ReplaceCurrentMatchCommand, UniverFindReplacePlugin, createInitFindReplaceState };
|
package/lib/es/locale/ar-SA.js
CHANGED
|
@@ -40,6 +40,7 @@ const locale = { "find-replace": {
|
|
|
40
40
|
},
|
|
41
41
|
replace: {
|
|
42
42
|
"all-success": "تم استبدال {0} تطابقات",
|
|
43
|
+
"partial-success": "تم استبدال {0} تطابقات، وتعذر استبدال {1}",
|
|
43
44
|
"all-failure": "فشل الاستبدال",
|
|
44
45
|
confirm: { title: "هل أنت متأكد من استبدال جميع التطابقات؟" }
|
|
45
46
|
},
|
package/lib/es/locale/ca-ES.js
CHANGED
|
@@ -40,6 +40,7 @@ const locale = { "find-replace": {
|
|
|
40
40
|
},
|
|
41
41
|
replace: {
|
|
42
42
|
"all-success": "S'han reemplaçat totes les {0} coincidències",
|
|
43
|
+
"partial-success": "S'han reemplaçat {0} coincidències, no s'han pogut reemplaçar {1}",
|
|
43
44
|
"all-failure": "Error en el reemplaçament",
|
|
44
45
|
confirm: { title: "Esteu segur que voleu reemplaçar totes les coincidències?" }
|
|
45
46
|
},
|
package/lib/es/locale/de-DE.js
CHANGED
|
@@ -40,6 +40,7 @@ const locale = { "find-replace": {
|
|
|
40
40
|
},
|
|
41
41
|
replace: {
|
|
42
42
|
"all-success": "Alle {0} Treffer ersetzt",
|
|
43
|
+
"partial-success": "{0} Treffer ersetzt, {1} konnten nicht ersetzt werden",
|
|
43
44
|
"all-failure": "Ersetzen fehlgeschlagen",
|
|
44
45
|
confirm: { title: "Sollen alle Treffer ersetzt werden?" }
|
|
45
46
|
},
|
package/lib/es/locale/en-US.js
CHANGED
|
@@ -55,6 +55,7 @@ const locale = { "find-replace": {
|
|
|
55
55
|
},
|
|
56
56
|
replace: {
|
|
57
57
|
"all-success": "Replaced all {0} matches",
|
|
58
|
+
"partial-success": "Replaced {0} matches, failed to replace {1}",
|
|
58
59
|
"all-failure": "Replace failed",
|
|
59
60
|
confirm: { title: "Are you sure to replace all matches?" }
|
|
60
61
|
},
|
package/lib/es/locale/es-ES.js
CHANGED
|
@@ -40,6 +40,7 @@ const locale = { "find-replace": {
|
|
|
40
40
|
},
|
|
41
41
|
replace: {
|
|
42
42
|
"all-success": "Se reemplazaron todas las {0} coincidencias",
|
|
43
|
+
"partial-success": "Se reemplazaron {0} coincidencias; no se pudieron reemplazar {1}",
|
|
43
44
|
"all-failure": "Error al reemplazar",
|
|
44
45
|
confirm: { title: "¿Está seguro de que desea reemplazar todas las coincidencias?" }
|
|
45
46
|
},
|
package/lib/es/locale/fa-IR.js
CHANGED
|
@@ -40,6 +40,7 @@ const locale = { "find-replace": {
|
|
|
40
40
|
},
|
|
41
41
|
replace: {
|
|
42
42
|
"all-success": "همه {0} مورد تطابق جایگزین شدند",
|
|
43
|
+
"partial-success": "{0} مورد تطابق جایگزین شد، جایگزینی {1} مورد ناموفق بود",
|
|
43
44
|
"all-failure": "جایگزینی ناموفق بود",
|
|
44
45
|
confirm: { title: "آیا مطمئن هستید که میخواهید همه موارد تطابق را جایگزین کنید؟" }
|
|
45
46
|
},
|
package/lib/es/locale/fr-FR.js
CHANGED
|
@@ -40,6 +40,7 @@ const locale = { "find-replace": {
|
|
|
40
40
|
},
|
|
41
41
|
replace: {
|
|
42
42
|
"all-success": "Toutes les {0} correspondances ont été remplacées",
|
|
43
|
+
"partial-success": "{0} correspondances ont été remplacées, {1} ont échoué",
|
|
43
44
|
"all-failure": "Échec du remplacement",
|
|
44
45
|
confirm: { title: "Êtes-vous sûr de vouloir remplacer toutes les correspondances ?" }
|
|
45
46
|
},
|
package/lib/es/locale/id-ID.js
CHANGED
|
@@ -40,6 +40,7 @@ const locale = { "find-replace": {
|
|
|
40
40
|
},
|
|
41
41
|
replace: {
|
|
42
42
|
"all-success": "Berhasil mengganti {0} kecocokan",
|
|
43
|
+
"partial-success": "Berhasil mengganti {0} kecocokan, gagal mengganti {1}",
|
|
43
44
|
"all-failure": "Penggantian gagal",
|
|
44
45
|
confirm: { title: "Apakah Anda yakin ingin mengganti semua kecocokan?" }
|
|
45
46
|
},
|
package/lib/es/locale/it-IT.js
CHANGED
|
@@ -40,6 +40,7 @@ const locale = { "find-replace": {
|
|
|
40
40
|
},
|
|
41
41
|
replace: {
|
|
42
42
|
"all-success": "Sostituite tutte le {0} corrispondenze",
|
|
43
|
+
"partial-success": "Sostituite {0} corrispondenze, {1} non sostituite",
|
|
43
44
|
"all-failure": "Sostituzione non riuscita",
|
|
44
45
|
confirm: { title: "Sei sicuro di voler sostituire tutte le corrispondenze?" }
|
|
45
46
|
},
|
package/lib/es/locale/ja-JP.js
CHANGED
package/lib/es/locale/ko-KR.js
CHANGED
package/lib/es/locale/pl-PL.js
CHANGED
|
@@ -40,6 +40,7 @@ const locale = { "find-replace": {
|
|
|
40
40
|
},
|
|
41
41
|
replace: {
|
|
42
42
|
"all-success": "Zastąpiono wszystkie dopasowania: {0}",
|
|
43
|
+
"partial-success": "Zastąpiono dopasowania: {0}, nie udało się zastąpić: {1}",
|
|
43
44
|
"all-failure": "Zastępowanie nie powiodło się",
|
|
44
45
|
confirm: { title: "Czy na pewno chcesz zastąpić wszystkie dopasowania?" }
|
|
45
46
|
},
|