@difizen/libro-search 0.2.0 → 0.2.2
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/es/libro-search-provider.d.ts +2 -2
- package/es/libro-search-provider.js +4 -4
- package/es/libro-search-view.d.ts +2 -2
- package/es/libro-search-view.d.ts.map +1 -1
- package/es/libro-search-view.js +114 -108
- package/package.json +5 -5
- package/src/libro-search-provider.ts +3 -3
- package/src/libro-search-view.tsx +114 -104
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SearchMatch } from '@difizen/libro-code-editor';
|
|
2
2
|
import type { CellView, VirtualizedManager } from '@difizen/libro-core';
|
|
3
|
-
import { LibroView, VirtualizedManagerHelper,
|
|
3
|
+
import { LibroView, VirtualizedManagerHelper, LibroContextKey } from '@difizen/libro-core';
|
|
4
4
|
import { Deferred, DisposableCollection } from '@difizen/mana-app';
|
|
5
5
|
import { AbstractSearchProvider } from './abstract-search-provider.js';
|
|
6
6
|
import { LibroCellSearchProvider } from './libro-cell-search-provider.js';
|
|
@@ -13,7 +13,7 @@ export declare const LibroSearchProviderFactory: unique symbol;
|
|
|
13
13
|
* Libro view search provider
|
|
14
14
|
*/
|
|
15
15
|
export declare class LibroSearchProvider extends AbstractSearchProvider {
|
|
16
|
-
contextKey:
|
|
16
|
+
contextKey: LibroContextKey;
|
|
17
17
|
libroCellSearchProvider: LibroCellSearchProvider;
|
|
18
18
|
protected cellsChangeDeferred: Deferred<void> | undefined;
|
|
19
19
|
protected toDispose: DisposableCollection;
|
|
@@ -20,7 +20,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
20
20
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
21
21
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
22
22
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
23
|
-
import { EditorCellView, LibroView, VirtualizedManagerHelper,
|
|
23
|
+
import { EditorCellView, LibroView, VirtualizedManagerHelper, LibroContextKey } from '@difizen/libro-core';
|
|
24
24
|
import { inject, prop, transient, equals } from '@difizen/mana-app';
|
|
25
25
|
import { Deferred, DisposableCollection } from '@difizen/mana-app';
|
|
26
26
|
import { l10n } from '@difizen/mana-l10n';
|
|
@@ -35,7 +35,7 @@ export var LibroSearchProviderFactory = Symbol('LibroSearchProviderFactory');
|
|
|
35
35
|
/**
|
|
36
36
|
* Libro view search provider
|
|
37
37
|
*/
|
|
38
|
-
export var LibroSearchProvider = (_dec = transient(), _dec2 = inject(
|
|
38
|
+
export var LibroSearchProvider = (_dec = transient(), _dec2 = inject(LibroContextKey), _dec3 = inject(LibroCellSearchProvider), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec9 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function (_AbstractSearchProvid) {
|
|
39
39
|
_inherits(LibroSearchProvider, _AbstractSearchProvid);
|
|
40
40
|
var _super = _createSuper(LibroSearchProvider);
|
|
41
41
|
/**
|
|
@@ -682,8 +682,8 @@ export var LibroSearchProvider = (_dec = transient(), _dec2 = inject(LirboContex
|
|
|
682
682
|
}, {
|
|
683
683
|
key: "isReadOnly",
|
|
684
684
|
get: function get() {
|
|
685
|
-
var _this$view$model$
|
|
686
|
-
return (_this$view$model$
|
|
685
|
+
var _this$view$model$inpu, _this$view;
|
|
686
|
+
return (_this$view$model$inpu = (_this$view = this.view) === null || _this$view === void 0 || (_this$view = _this$view.model) === null || _this$view === void 0 ? void 0 : _this$view.inputEditable) !== null && _this$view$model$inpu !== void 0 ? _this$view$model$inpu : false;
|
|
687
687
|
}
|
|
688
688
|
|
|
689
689
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import type { LibroView } from '@difizen/libro-core';
|
|
3
|
-
import {
|
|
3
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
4
4
|
import { BaseView } from '@difizen/mana-app';
|
|
5
5
|
import type { CheckboxChangeEvent } from 'antd/es/checkbox';
|
|
6
6
|
import type { InputRef } from 'antd/es/input';
|
|
@@ -14,7 +14,7 @@ export declare const SearchContent: () => import("react/jsx-runtime").JSX.Elemen
|
|
|
14
14
|
export declare const SearchComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
15
15
|
export declare class LibroSearchView extends BaseView {
|
|
16
16
|
findInputRef?: React.RefObject<InputRef> | null;
|
|
17
|
-
contextKey:
|
|
17
|
+
contextKey: LibroContextKey;
|
|
18
18
|
utils: LibroSearchUtils;
|
|
19
19
|
searchProviderFactory: LibroSearchProviderFactory;
|
|
20
20
|
libro?: LibroView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-search-view.d.ts","sourceRoot":"","sources":["../src/libro-search-view.tsx"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAsB,MAAM,mBAAmB,CAAC;AAIjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAA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Of ? Object.g
|
|
|
19
19
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
20
20
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
21
21
|
import { ArrowDownOutlined, ArrowUpOutlined, CloseOutlined, createFromIconfontCN, EllipsisOutlined, RightOutlined } from '@ant-design/icons';
|
|
22
|
-
import {
|
|
23
|
-
import { prop, useInject, useObserve, watch } from '@difizen/mana-app';
|
|
22
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
23
|
+
import { prop, ThemeService, useInject, useObserve, watch } from '@difizen/mana-app';
|
|
24
24
|
import { BaseView, view, ViewInstance } from '@difizen/mana-app';
|
|
25
25
|
import { inject, transient } from '@difizen/mana-app';
|
|
26
26
|
import { l10n } from '@difizen/mana-l10n';
|
|
27
|
-
import { Button, Checkbox, Input, Tag } from 'antd';
|
|
27
|
+
import { Button, Checkbox, ConfigProvider, Input, Tag, theme } from 'antd';
|
|
28
28
|
import classnames from 'classnames';
|
|
29
29
|
import { forwardRef, memo, useEffect, useRef } from 'react';
|
|
30
30
|
import { LibroSearchProviderFactory } from "./libro-search-provider.js";
|
|
@@ -67,6 +67,7 @@ export var SearchContent = function SearchContent() {
|
|
|
67
67
|
var _instance$searchProvi;
|
|
68
68
|
var instance = useInject(ViewInstance);
|
|
69
69
|
var findInputRef = useRef(null);
|
|
70
|
+
var themeService = useInject(ThemeService);
|
|
70
71
|
useEffect(function () {
|
|
71
72
|
var _instance$container;
|
|
72
73
|
if (findInputRef.current) {
|
|
@@ -82,117 +83,122 @@ export var SearchContent = function SearchContent() {
|
|
|
82
83
|
}
|
|
83
84
|
return;
|
|
84
85
|
}, [instance]);
|
|
85
|
-
return /*#__PURE__*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
height: "".concat(instance.contentHeight, "px")
|
|
86
|
+
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
87
|
+
theme: {
|
|
88
|
+
algorithm: themeService.getCurrentTheme().type === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm
|
|
89
89
|
},
|
|
90
|
-
children:
|
|
91
|
-
className: "libro-search-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
instance.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
90
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
91
|
+
className: "libro-search-content",
|
|
92
|
+
style: {
|
|
93
|
+
height: "".concat(instance.contentHeight, "px")
|
|
94
|
+
},
|
|
95
|
+
children: [/*#__PURE__*/_jsx(ReplaceToggle, {}), /*#__PURE__*/_jsxs("table", {
|
|
96
|
+
className: "libro-search-input-area",
|
|
97
|
+
children: [/*#__PURE__*/_jsxs("tr", {
|
|
98
|
+
className: "libro-search-row",
|
|
99
|
+
children: [/*#__PURE__*/_jsx("td", {
|
|
100
|
+
className: "libro-search-input",
|
|
101
|
+
children: /*#__PURE__*/_jsx(Input, {
|
|
102
|
+
ref: findInputRef,
|
|
103
|
+
value: instance.findStr,
|
|
104
|
+
onChange: instance.handleFindChange,
|
|
105
|
+
size: "small",
|
|
106
|
+
placeholder: "\u641C\u7D22",
|
|
107
|
+
onFocus: function onFocus() {
|
|
108
|
+
instance.hasFocus = true;
|
|
109
|
+
},
|
|
110
|
+
onBlur: function onBlur() {
|
|
111
|
+
instance.hasFocus = false;
|
|
112
|
+
},
|
|
113
|
+
suffix: /*#__PURE__*/_jsxs("span", {
|
|
114
|
+
className: "libro-search-input-suffix",
|
|
115
|
+
children: [/*#__PURE__*/_jsx(IconFont, {
|
|
116
|
+
className: classnames({
|
|
117
|
+
'libro-search-input-suffix-active': instance.caseSensitive
|
|
118
|
+
}),
|
|
119
|
+
onClick: instance.toggleCaseSensitive,
|
|
120
|
+
type: "icon-Aa",
|
|
121
|
+
title: "Match Case"
|
|
122
|
+
}), /*#__PURE__*/_jsx(IconFont, {
|
|
123
|
+
className: classnames({
|
|
124
|
+
'libro-search-input-suffix-active': instance.useRegex
|
|
125
|
+
}),
|
|
126
|
+
onClick: instance.toggleUseRegex,
|
|
127
|
+
type: "icon-zhengzeshi",
|
|
128
|
+
title: "Use Regular Expression"
|
|
129
|
+
})]
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
}), /*#__PURE__*/_jsxs("td", {
|
|
133
|
+
className: "libro-search-action",
|
|
134
|
+
children: [/*#__PURE__*/_jsx(SearchIndexMemo, {}), /*#__PURE__*/_jsxs("div", {
|
|
135
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
136
|
+
title: "Previous Match",
|
|
137
|
+
onClick: instance.previous,
|
|
138
|
+
icon: /*#__PURE__*/_jsx(ArrowUpOutlined, {}),
|
|
139
|
+
size: "small"
|
|
140
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
141
|
+
title: "Next Match",
|
|
142
|
+
onClick: instance.next,
|
|
143
|
+
icon: /*#__PURE__*/_jsx(ArrowDownOutlined, {}),
|
|
144
|
+
size: "small"
|
|
145
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
146
|
+
onClick: instance.toggleSetting,
|
|
147
|
+
icon: /*#__PURE__*/_jsx(EllipsisOutlined, {}),
|
|
148
|
+
size: "small"
|
|
149
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
150
|
+
onClick: function onClick() {
|
|
151
|
+
return instance.hide();
|
|
152
|
+
},
|
|
153
|
+
icon: /*#__PURE__*/_jsx(CloseOutlined, {}),
|
|
154
|
+
size: "small"
|
|
155
|
+
})]
|
|
156
|
+
})]
|
|
157
|
+
})]
|
|
158
|
+
}), instance.replaceVisible && /*#__PURE__*/_jsxs("tr", {
|
|
159
|
+
className: "libro-search-row",
|
|
160
|
+
children: [/*#__PURE__*/_jsx("td", {
|
|
161
|
+
className: "libro-search-input",
|
|
162
|
+
children: /*#__PURE__*/_jsx(Input, {
|
|
163
|
+
value: instance.replaceStr,
|
|
164
|
+
onChange: instance.handleReplaceChange,
|
|
165
|
+
size: "small",
|
|
166
|
+
placeholder: "\u66FF\u6362"
|
|
167
|
+
})
|
|
168
|
+
}), /*#__PURE__*/_jsx("td", {
|
|
169
|
+
className: "libro-search-action",
|
|
170
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
171
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
172
|
+
onClick: instance.replace,
|
|
173
|
+
icon: /*#__PURE__*/_jsx(IconFont, {
|
|
174
|
+
type: "icon-zifuchuantihuan_2"
|
|
113
175
|
}),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
176
|
+
size: "small",
|
|
177
|
+
title: "Replace"
|
|
178
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
179
|
+
onClick: instance.replaceAll,
|
|
180
|
+
icon: /*#__PURE__*/_jsx(IconFont, {
|
|
181
|
+
type: "icon-tihuantupian"
|
|
120
182
|
}),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
title: "Use Regular Expression"
|
|
183
|
+
size: "small",
|
|
184
|
+
title: "Replace All"
|
|
124
185
|
})]
|
|
125
186
|
})
|
|
126
|
-
})
|
|
127
|
-
}), /*#__PURE__*/_jsxs("td", {
|
|
128
|
-
className: "libro-search-action",
|
|
129
|
-
children: [/*#__PURE__*/_jsx(SearchIndexMemo, {}), /*#__PURE__*/_jsxs("div", {
|
|
130
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
|
131
|
-
title: "Previous Match",
|
|
132
|
-
onClick: instance.previous,
|
|
133
|
-
icon: /*#__PURE__*/_jsx(ArrowUpOutlined, {}),
|
|
134
|
-
size: "small"
|
|
135
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
136
|
-
title: "Next Match",
|
|
137
|
-
onClick: instance.next,
|
|
138
|
-
icon: /*#__PURE__*/_jsx(ArrowDownOutlined, {}),
|
|
139
|
-
size: "small"
|
|
140
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
141
|
-
onClick: instance.toggleSetting,
|
|
142
|
-
icon: /*#__PURE__*/_jsx(EllipsisOutlined, {}),
|
|
143
|
-
size: "small"
|
|
144
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
145
|
-
onClick: function onClick() {
|
|
146
|
-
return instance.hide();
|
|
147
|
-
},
|
|
148
|
-
icon: /*#__PURE__*/_jsx(CloseOutlined, {}),
|
|
149
|
-
size: "small"
|
|
150
|
-
})]
|
|
151
187
|
})]
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})
|
|
163
|
-
}), /*#__PURE__*/_jsx("td", {
|
|
164
|
-
className: "libro-search-action",
|
|
165
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
166
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
|
167
|
-
onClick: instance.replace,
|
|
168
|
-
icon: /*#__PURE__*/_jsx(IconFont, {
|
|
169
|
-
type: "icon-zifuchuantihuan_2"
|
|
170
|
-
}),
|
|
171
|
-
size: "small",
|
|
172
|
-
title: "Replace"
|
|
173
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
174
|
-
onClick: instance.replaceAll,
|
|
175
|
-
icon: /*#__PURE__*/_jsx(IconFont, {
|
|
176
|
-
type: "icon-tihuantupian"
|
|
177
|
-
}),
|
|
178
|
-
size: "small",
|
|
179
|
-
title: "Replace All"
|
|
180
|
-
})]
|
|
181
|
-
})
|
|
182
|
-
})]
|
|
183
|
-
}), instance.settingVisible && /*#__PURE__*/_jsxs("div", {
|
|
184
|
-
className: "libro-search-row",
|
|
185
|
-
children: [/*#__PURE__*/_jsx(Checkbox, {
|
|
186
|
-
checked: (_instance$searchProvi = instance.searchProvider) === null || _instance$searchProvi === void 0 ? void 0 : _instance$searchProvi.searchCellOutput,
|
|
187
|
-
onChange: instance.searchCellOutputChange,
|
|
188
|
-
disabled: instance.replaceVisible,
|
|
189
|
-
children: l10n.t('在 output 中查找')
|
|
190
|
-
}), instance.replaceVisible && /*#__PURE__*/_jsx(Tag, {
|
|
191
|
-
color: "warning",
|
|
192
|
-
children: l10n.t('替换功能不能在 output 生效')
|
|
188
|
+
}), instance.settingVisible && /*#__PURE__*/_jsxs("div", {
|
|
189
|
+
className: "libro-search-row",
|
|
190
|
+
children: [/*#__PURE__*/_jsx(Checkbox, {
|
|
191
|
+
checked: (_instance$searchProvi = instance.searchProvider) === null || _instance$searchProvi === void 0 ? void 0 : _instance$searchProvi.searchCellOutput,
|
|
192
|
+
onChange: instance.searchCellOutputChange,
|
|
193
|
+
disabled: instance.replaceVisible,
|
|
194
|
+
children: l10n.t('在 output 中查找')
|
|
195
|
+
}), instance.replaceVisible && /*#__PURE__*/_jsx(Tag, {
|
|
196
|
+
color: "warning",
|
|
197
|
+
children: l10n.t('替换功能不能在 output 生效')
|
|
198
|
+
})]
|
|
193
199
|
})]
|
|
194
200
|
})]
|
|
195
|
-
})
|
|
201
|
+
})
|
|
196
202
|
});
|
|
197
203
|
};
|
|
198
204
|
// TODO: 更改图标
|
|
@@ -212,7 +218,7 @@ export var SearchComponent = /*#__PURE__*/forwardRef(function SearchComponent(pr
|
|
|
212
218
|
children: instance.searchVisible && /*#__PURE__*/_jsx(SearchContent, {})
|
|
213
219
|
});
|
|
214
220
|
});
|
|
215
|
-
export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-view'), _dec3 = inject(
|
|
221
|
+
export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-view'), _dec3 = inject(LibroContextKey), _dec4 = inject(LibroSearchUtils), _dec5 = inject(LibroSearchProviderFactory), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec9 = prop(), _dec10 = prop(), _dec11 = prop(), _dec12 = prop(), _dec13 = prop(), _dec14 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
|
|
216
222
|
_inherits(LibroSearchView, _BaseView);
|
|
217
223
|
var _super = _createSuper(LibroSearchView);
|
|
218
224
|
function LibroSearchView() {
|
|
@@ -252,7 +258,7 @@ export var LibroSearchView = (_dec = transient(), _dec2 = view('libro-search-vie
|
|
|
252
258
|
_this.toDispose.push(_this.libro.model.onCommandModeChanged(function (mode) {
|
|
253
259
|
if (mode) {
|
|
254
260
|
setTimeout(function () {
|
|
255
|
-
if (_this.hasFocus === false) {
|
|
261
|
+
if (_this.hasFocus === false && _this.searchVisible) {
|
|
256
262
|
_this.hide(false);
|
|
257
263
|
}
|
|
258
264
|
}, 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-search",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"@difizen/mana-app": "latest",
|
|
37
37
|
"@difizen/mana-l10n": "latest",
|
|
38
38
|
"@ant-design/icons": "^5.1.0",
|
|
39
|
-
"@difizen/libro-common": "^0.2.
|
|
40
|
-
"@difizen/libro-core": "^0.2.
|
|
41
|
-
"@difizen/libro-code-editor": "^0.2.
|
|
39
|
+
"@difizen/libro-common": "^0.2.2",
|
|
40
|
+
"@difizen/libro-core": "^0.2.2",
|
|
41
|
+
"@difizen/libro-code-editor": "^0.2.2",
|
|
42
42
|
"@types/lodash.debounce": "^4.0.7",
|
|
43
43
|
"classnames": "^2.3.2",
|
|
44
44
|
"lodash.debounce": "^4.0.8",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"antd": "^5.8.6",
|
|
49
|
-
"react": "
|
|
49
|
+
"react": ">=16"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/react": "^18.2.25"
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
EditorCellView,
|
|
5
5
|
LibroView,
|
|
6
6
|
VirtualizedManagerHelper,
|
|
7
|
-
|
|
7
|
+
LibroContextKey,
|
|
8
8
|
} from '@difizen/libro-core';
|
|
9
9
|
import { inject, prop, transient, equals } from '@difizen/mana-app';
|
|
10
10
|
import { Deferred, DisposableCollection } from '@difizen/mana-app';
|
|
@@ -40,7 +40,7 @@ export const LibroSearchProviderFactory = Symbol('LibroSearchProviderFactory');
|
|
|
40
40
|
*/
|
|
41
41
|
@transient()
|
|
42
42
|
export class LibroSearchProvider extends AbstractSearchProvider {
|
|
43
|
-
@inject(
|
|
43
|
+
@inject(LibroContextKey) contextKey: LibroContextKey;
|
|
44
44
|
@inject(LibroCellSearchProvider) libroCellSearchProvider: LibroCellSearchProvider;
|
|
45
45
|
protected cellsChangeDeferred: Deferred<void> | undefined;
|
|
46
46
|
|
|
@@ -138,7 +138,7 @@ export class LibroSearchProvider extends AbstractSearchProvider {
|
|
|
138
138
|
* the replace option.
|
|
139
139
|
*/
|
|
140
140
|
get isReadOnly(): boolean {
|
|
141
|
-
return this.view?.model?.
|
|
141
|
+
return this.view?.model?.inputEditable ?? false;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
RightOutlined,
|
|
8
8
|
} from '@ant-design/icons';
|
|
9
9
|
import type { LibroView } from '@difizen/libro-core';
|
|
10
|
-
import {
|
|
11
|
-
import { prop, useInject, useObserve, watch } from '@difizen/mana-app';
|
|
10
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
11
|
+
import { prop, ThemeService, useInject, useObserve, watch } from '@difizen/mana-app';
|
|
12
12
|
import { BaseView, view, ViewInstance } from '@difizen/mana-app';
|
|
13
13
|
import { inject, transient } from '@difizen/mana-app';
|
|
14
14
|
import { l10n } from '@difizen/mana-l10n';
|
|
15
|
-
import { Button, Checkbox, Input, Tag } from 'antd';
|
|
15
|
+
import { Button, Checkbox, ConfigProvider, Input, Tag, theme } from 'antd';
|
|
16
16
|
import type { CheckboxChangeEvent } from 'antd/es/checkbox';
|
|
17
17
|
import type { InputRef } from 'antd/es/input';
|
|
18
18
|
import classnames from 'classnames';
|
|
@@ -63,6 +63,7 @@ export const SearchIndexMemo = memo(SearchIndex);
|
|
|
63
63
|
export const SearchContent = () => {
|
|
64
64
|
const instance = useInject<LibroSearchView>(ViewInstance);
|
|
65
65
|
const findInputRef = useRef<InputRef>(null);
|
|
66
|
+
const themeService = useInject(ThemeService);
|
|
66
67
|
useEffect(() => {
|
|
67
68
|
if (findInputRef.current) {
|
|
68
69
|
findInputRef.current.focus();
|
|
@@ -79,123 +80,132 @@ export const SearchContent = () => {
|
|
|
79
80
|
}, [instance]);
|
|
80
81
|
|
|
81
82
|
return (
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
<ConfigProvider
|
|
84
|
+
theme={{
|
|
85
|
+
algorithm:
|
|
86
|
+
themeService.getCurrentTheme().type === 'dark'
|
|
87
|
+
? theme.darkAlgorithm
|
|
88
|
+
: theme.defaultAlgorithm,
|
|
89
|
+
}}
|
|
85
90
|
>
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
value={instance.findStr}
|
|
93
|
-
onChange={instance.handleFindChange}
|
|
94
|
-
size="small"
|
|
95
|
-
placeholder="搜索"
|
|
96
|
-
onFocus={() => {
|
|
97
|
-
instance.hasFocus = true;
|
|
98
|
-
}}
|
|
99
|
-
onBlur={() => {
|
|
100
|
-
instance.hasFocus = false;
|
|
101
|
-
}}
|
|
102
|
-
suffix={
|
|
103
|
-
<span className="libro-search-input-suffix">
|
|
104
|
-
<IconFont
|
|
105
|
-
className={classnames({
|
|
106
|
-
'libro-search-input-suffix-active': instance.caseSensitive,
|
|
107
|
-
})}
|
|
108
|
-
onClick={instance.toggleCaseSensitive}
|
|
109
|
-
type="icon-Aa"
|
|
110
|
-
title="Match Case"
|
|
111
|
-
/>
|
|
112
|
-
|
|
113
|
-
<IconFont
|
|
114
|
-
className={classnames({
|
|
115
|
-
'libro-search-input-suffix-active': instance.useRegex,
|
|
116
|
-
})}
|
|
117
|
-
onClick={instance.toggleUseRegex}
|
|
118
|
-
type="icon-zhengzeshi"
|
|
119
|
-
title="Use Regular Expression"
|
|
120
|
-
/>
|
|
121
|
-
</span>
|
|
122
|
-
}
|
|
123
|
-
/>
|
|
124
|
-
</td>
|
|
125
|
-
<td className="libro-search-action">
|
|
126
|
-
<SearchIndexMemo />
|
|
127
|
-
<div>
|
|
128
|
-
<Button
|
|
129
|
-
title="Previous Match"
|
|
130
|
-
onClick={instance.previous}
|
|
131
|
-
icon={<ArrowUpOutlined />}
|
|
132
|
-
size="small"
|
|
133
|
-
/>
|
|
134
|
-
<Button
|
|
135
|
-
title="Next Match"
|
|
136
|
-
onClick={instance.next}
|
|
137
|
-
icon={<ArrowDownOutlined />}
|
|
138
|
-
size="small"
|
|
139
|
-
/>
|
|
140
|
-
<Button
|
|
141
|
-
onClick={instance.toggleSetting}
|
|
142
|
-
icon={<EllipsisOutlined />}
|
|
143
|
-
size="small"
|
|
144
|
-
/>
|
|
145
|
-
<Button
|
|
146
|
-
onClick={() => instance.hide()}
|
|
147
|
-
icon={<CloseOutlined />}
|
|
148
|
-
size="small"
|
|
149
|
-
/>
|
|
150
|
-
</div>
|
|
151
|
-
</td>
|
|
152
|
-
</tr>
|
|
153
|
-
{instance.replaceVisible && (
|
|
91
|
+
<div
|
|
92
|
+
className="libro-search-content"
|
|
93
|
+
style={{ height: `${instance.contentHeight}px` }}
|
|
94
|
+
>
|
|
95
|
+
<ReplaceToggle />
|
|
96
|
+
<table className="libro-search-input-area">
|
|
154
97
|
<tr className="libro-search-row">
|
|
155
98
|
<td className="libro-search-input">
|
|
156
99
|
<Input
|
|
157
|
-
|
|
158
|
-
|
|
100
|
+
ref={findInputRef}
|
|
101
|
+
value={instance.findStr}
|
|
102
|
+
onChange={instance.handleFindChange}
|
|
159
103
|
size="small"
|
|
160
|
-
placeholder="
|
|
104
|
+
placeholder="搜索"
|
|
105
|
+
onFocus={() => {
|
|
106
|
+
instance.hasFocus = true;
|
|
107
|
+
}}
|
|
108
|
+
onBlur={() => {
|
|
109
|
+
instance.hasFocus = false;
|
|
110
|
+
}}
|
|
111
|
+
suffix={
|
|
112
|
+
<span className="libro-search-input-suffix">
|
|
113
|
+
<IconFont
|
|
114
|
+
className={classnames({
|
|
115
|
+
'libro-search-input-suffix-active': instance.caseSensitive,
|
|
116
|
+
})}
|
|
117
|
+
onClick={instance.toggleCaseSensitive}
|
|
118
|
+
type="icon-Aa"
|
|
119
|
+
title="Match Case"
|
|
120
|
+
/>
|
|
121
|
+
|
|
122
|
+
<IconFont
|
|
123
|
+
className={classnames({
|
|
124
|
+
'libro-search-input-suffix-active': instance.useRegex,
|
|
125
|
+
})}
|
|
126
|
+
onClick={instance.toggleUseRegex}
|
|
127
|
+
type="icon-zhengzeshi"
|
|
128
|
+
title="Use Regular Expression"
|
|
129
|
+
/>
|
|
130
|
+
</span>
|
|
131
|
+
}
|
|
161
132
|
/>
|
|
162
133
|
</td>
|
|
163
134
|
<td className="libro-search-action">
|
|
135
|
+
<SearchIndexMemo />
|
|
164
136
|
<div>
|
|
165
137
|
<Button
|
|
166
|
-
|
|
167
|
-
|
|
138
|
+
title="Previous Match"
|
|
139
|
+
onClick={instance.previous}
|
|
140
|
+
icon={<ArrowUpOutlined />}
|
|
141
|
+
size="small"
|
|
142
|
+
/>
|
|
143
|
+
<Button
|
|
144
|
+
title="Next Match"
|
|
145
|
+
onClick={instance.next}
|
|
146
|
+
icon={<ArrowDownOutlined />}
|
|
147
|
+
size="small"
|
|
148
|
+
/>
|
|
149
|
+
<Button
|
|
150
|
+
onClick={instance.toggleSetting}
|
|
151
|
+
icon={<EllipsisOutlined />}
|
|
168
152
|
size="small"
|
|
169
|
-
title="Replace"
|
|
170
153
|
/>
|
|
171
|
-
|
|
172
154
|
<Button
|
|
173
|
-
onClick={instance.
|
|
174
|
-
icon={<
|
|
155
|
+
onClick={() => instance.hide()}
|
|
156
|
+
icon={<CloseOutlined />}
|
|
175
157
|
size="small"
|
|
176
|
-
title="Replace All"
|
|
177
158
|
/>
|
|
178
159
|
</div>
|
|
179
160
|
</td>
|
|
180
161
|
</tr>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
162
|
+
{instance.replaceVisible && (
|
|
163
|
+
<tr className="libro-search-row">
|
|
164
|
+
<td className="libro-search-input">
|
|
165
|
+
<Input
|
|
166
|
+
value={instance.replaceStr}
|
|
167
|
+
onChange={instance.handleReplaceChange}
|
|
168
|
+
size="small"
|
|
169
|
+
placeholder="替换"
|
|
170
|
+
/>
|
|
171
|
+
</td>
|
|
172
|
+
<td className="libro-search-action">
|
|
173
|
+
<div>
|
|
174
|
+
<Button
|
|
175
|
+
onClick={instance.replace}
|
|
176
|
+
icon={<IconFont type="icon-zifuchuantihuan_2" />}
|
|
177
|
+
size="small"
|
|
178
|
+
title="Replace"
|
|
179
|
+
/>
|
|
180
|
+
|
|
181
|
+
<Button
|
|
182
|
+
onClick={instance.replaceAll}
|
|
183
|
+
icon={<IconFont type="icon-tihuantupian" />}
|
|
184
|
+
size="small"
|
|
185
|
+
title="Replace All"
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
188
|
+
</td>
|
|
189
|
+
</tr>
|
|
190
|
+
)}
|
|
191
|
+
|
|
192
|
+
{instance.settingVisible && (
|
|
193
|
+
<div className="libro-search-row">
|
|
194
|
+
<Checkbox
|
|
195
|
+
checked={instance.searchProvider?.searchCellOutput}
|
|
196
|
+
onChange={instance.searchCellOutputChange}
|
|
197
|
+
disabled={instance.replaceVisible}
|
|
198
|
+
>
|
|
199
|
+
{l10n.t('在 output 中查找')}
|
|
200
|
+
</Checkbox>
|
|
201
|
+
{instance.replaceVisible && (
|
|
202
|
+
<Tag color="warning">{l10n.t('替换功能不能在 output 生效')}</Tag>
|
|
203
|
+
)}
|
|
204
|
+
</div>
|
|
205
|
+
)}
|
|
206
|
+
</table>
|
|
207
|
+
</div>
|
|
208
|
+
</ConfigProvider>
|
|
199
209
|
);
|
|
200
210
|
};
|
|
201
211
|
// TODO: 更改图标
|
|
@@ -222,7 +232,7 @@ export const SearchComponent = forwardRef<HTMLDivElement>(function SearchCompone
|
|
|
222
232
|
@view('libro-search-view')
|
|
223
233
|
export class LibroSearchView extends BaseView {
|
|
224
234
|
findInputRef?: React.RefObject<InputRef> | null;
|
|
225
|
-
@inject(
|
|
235
|
+
@inject(LibroContextKey) contextKey: LibroContextKey;
|
|
226
236
|
@inject(LibroSearchUtils) utils: LibroSearchUtils;
|
|
227
237
|
@inject(LibroSearchProviderFactory) searchProviderFactory: LibroSearchProviderFactory;
|
|
228
238
|
libro?: LibroView;
|
|
@@ -278,7 +288,7 @@ export class LibroSearchView extends BaseView {
|
|
|
278
288
|
this.libro.model.onCommandModeChanged((mode) => {
|
|
279
289
|
if (mode) {
|
|
280
290
|
setTimeout(() => {
|
|
281
|
-
if (this.hasFocus === false) {
|
|
291
|
+
if (this.hasFocus === false && this.searchVisible) {
|
|
282
292
|
this.hide(false);
|
|
283
293
|
}
|
|
284
294
|
}, 0);
|