Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(sr): add base for search & replace feature (#1065)

Wenzhao Hud6149e5ee6fb
diff --git a/.storybook/main.ts b/.storybook/main.ts
index 0221a39611..d2343409b1 100644
--- a/.storybook/main.ts
+++ b/.storybook/main.ts
@@ -26,6 +26,11 @@ const config: StorybookConfig = {
files: '*.stories.@(js|jsx|mjs|ts|tsx)',
titlePrefix: 'Numfmt'
},
+ {
+ directory: '../packages/find-replace/src/**',
+ files: '*.stories.@(js|jsx|mjs|ts|tsx)',
+ titlePrefix: 'Find & Replace'
+ },
],
addons: [
getAbsolutePath('@storybook/addon-links'),
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8e36d63c01..5559845dad 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -85,6 +85,16 @@ During the refactoring process, it is recommended to remove legacy folders such
Avoid creating barrel imports (index.ts) unless it is the main root index.ts file of a plugin.
+### Contextual Connections
+
+To effectively contribute as a member of a software engineering team (and community as well!), it is crucial to establish strong contextual connections. Providing links to relevant resources can greatly assist others in understanding the context. Consider the following practices:
+
+- Include the link to the corresponding issue in your commit message.
+- Leave comments with links to the relevant context within the code.
+- Whenever possible, document important information directly within the codebase itself.
+
+By adopting these practices, you can enhance collaboration and facilitate a better understanding of the codebase within our community.
+
### Naming conventions
To ensure code quality and consistency, please adhere to the following guidelines:
diff --git a/examples/package.json b/examples/package.json
index f31e98e603..24feec055c 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -19,6 +19,7 @@
"@univerjs/icons": "^0.1.25",
"@univerjs/rpc": "workspace:*",
"@univerjs/sheets": "workspace:*",
+ "@univerjs/sheets-find-replace": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
"@univerjs/sheets-numfmt": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
diff --git a/examples/src/sheets-multi/main.tsx b/examples/src/sheets-multi/main.tsx
index 7775a107f8..468567ec88 100644
--- a/examples/src/sheets-multi/main.tsx
+++ b/examples/src/sheets-multi/main.tsx
@@ -100,6 +100,7 @@ export const App = (
);
ReactDOM.render(App, document.getElementById('container'));
+
factory('app-a')();
factory('app-b')();
factory('app-c')();
diff --git a/examples/src/sheets/lazy.ts b/examples/src/sheets/lazy.ts
index 4fbb76de66..5f69d2cda4 100644
--- a/examples/src/sheets/lazy.ts
+++ b/examples/src/sheets/lazy.ts
@@ -14,21 +14,22 @@
* limitations under the License.
*/
-import type { PluginCtor } from '@univerjs/core';
-import type { IUniscriptConfig } from '@univerjs/uniscript';
+import type { Plugin, PluginCtor } from '@univerjs/core';
import { UniverUniscriptPlugin } from '@univerjs/uniscript';
-export default function getLazyPlugins(): [PluginCtor<UniverUniscriptPlugin>, IUniscriptConfig] {
+export default function getLazyPlugins(): Array<[PluginCtor<Plugin>] | [PluginCtor<Plugin>, unknown]> {
return [
- UniverUniscriptPlugin,
- {
- getWorkerUrl(moduleID, label) {
- if (label === 'typescript' || label === 'javascript') {
- return './vs/language/typescript/ts.worker.js';
- }
+ [
+ UniverUniscriptPlugin,
+ {
+ getWorkerUrl(moduleID: string, label: string) {
+ if (label === 'typescript' || label === 'javascript') {
+ return './vs/language/typescript/ts.worker.js';
+ }
- return './vs/editor/editor.worker.js';
+ return './vs/editor/editor.worker.js';
+ },
},
- },
+ ],
];
}
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts
index 8cc5226a0b..589aa7f15d 100644
--- a/examples/src/sheets/main.ts
+++ b/examples/src/sheets/main.ts
@@ -20,7 +20,6 @@ import { UniverDocsPlugin } from '@univerjs/docs';
import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
-import { UniverFindReplacePlugin } from '@univerjs/find-replace';
import type { IUniverRPCMainThreadConfig } from '@univerjs/rpc';
import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsPlugin } from '@univerjs/sheets';
@@ -33,6 +32,8 @@ import { UniverUIPlugin } from '@univerjs/ui';
import { DEFAULT_WORKBOOK_DATA_DEMO } from '../data';
import { DebuggerPlugin } from '../plugins/debugger';
import { locales } from './locales';
+import { UniverFindReplacePlugin } from '@univerjs/find-replace';
+import { UniverSheetsFindPlugin } from '@univerjs/sheets-find-replace';
const LOAD_LAZY_PLUGINS_TIMEOUT = 5_000;
// univer
@@ -54,7 +55,6 @@ univer.registerPlugin(UniverUIPlugin, {
toolbar: true,
footer: true,
});
-univer.registerPlugin(UniverFindReplacePlugin);
univer.registerPlugin(UniverDocsUIPlugin);
@@ -76,6 +76,10 @@ univer.registerPlugin(UniverRPCMainThreadPlugin, {
workerURL: './worker.js',
} as IUniverRPCMainThreadConfig);
+// find replace
+univer.registerPlugin(UniverFindReplacePlugin);
+univer.registerPlugin(UniverSheetsFindPlugin);
+
// create univer sheet instance
univer.createUniverSheet(DEFAULT_WORKBOOK_DATA_DEMO);
@@ -88,8 +92,8 @@ declare global {
setTimeout(() => {
import('./lazy').then((lazy) => {
- const plugin = lazy.default();
- univer.registerPlugin(plugin[0], plugin[1]);
+ const plugins = lazy.default();
+ plugins.forEach((p) => univer.registerPlugin(p[0], p[1]));
});
}, LOAD_LAZY_PLUGINS_TIMEOUT);
diff --git a/packages/core/src/basics/plugin-holder.ts b/packages/core/src/basics/plugin-holder.ts
index 42413afeb5..65ff36daa9 100644
--- a/packages/core/src/basics/plugin-holder.ts
+++ b/packages/core/src/basics/plugin-holder.ts
@@ -38,7 +38,8 @@ export abstract class PluginHolder extends Disposable {
} else {
const lazyPlugins = plugins.map(([plugin, options]) => this._initPlugin(plugin, options));
this._pluginsRunLifecycle(lazyPlugins, LifecycleStages.Starting);
- setTimeout(() => this._takePluginsThroughLifecycle(lazyPlugins));
+
+ setTimeout(() => this._takePluginsThroughLifecycle(lazyPlugins, true));
}
}
diff --git a/packages/core/src/common/function.ts b/packages/core/src/common/function.ts
new file mode 100644
index 0000000000..d1aab2fdfd
--- /dev/null
+++ b/packages/core/src/common/function.ts
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* eslint-disable @typescript-eslint/no-explicit-any */
+
+// eslint-disable-next-line no-magic-numbers
+export function throttle<T extends (...args: any[]) => any>(fn: T, wait: number = 16): T {
+ let lastTime = 0;
+ let timer: number | null = null;
+
+ return function throttled(this: any, ...args: any[]) {
+ const now = Date.now();
+ if (now - lastTime < wait) {
+ if (timer) {
+ clearTimeout(timer);
+ }
+
+ timer = setTimeout(() => {
+ lastTime = now;
+ fn.apply(this, args);
+ }, wait) as unknown as number;
+ } else {
+ lastTime = now;
+ fn.apply(this, args);
+ }
+ } as unknown as T;
+}
diff --git a/packages/core/src/common/interceptor.ts b/packages/core/src/common/interceptor.ts
index b2d66823ea..7b7c4c523a 100644
--- a/packages/core/src/common/interceptor.ts
+++ b/packages/core/src/common/interceptor.ts
@@ -90,7 +90,7 @@ export class InterceptorManager<P extends Record<string, IInterceptor<any, any>>
this._interceptorsByName.set(
key,
- interceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
+ interceptors.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0))
);
return () => remove(this._interceptorsByName.get(key)!, interceptor);
}
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index d5680208c5..f206b8efdb 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -23,6 +23,7 @@ export {
DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
} from './common/const';
+export { throttle } from './common/function';
export { MemoryCursor } from './common/memory-cursor';
export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
export { type ISequenceExecuteResult, sequence, sequenceAsync } from './common/sequence';
diff --git a/packages/core/src/services/context/context.ts b/packages/core/src/services/context/context.ts
index 65e907f41c..fdaa6809fc 100644
--- a/packages/core/src/services/context/context.ts
+++ b/packages/core/src/services/context/context.ts
@@ -17,7 +17,12 @@
export const FOCUSING_SHEET = 'FOCUSING_SHEET';
export const FOCUSING_DOC = 'FOCUSING_DOC';
export const FOCUSING_SLIDE = 'FOCUSING_SLIDE';
+
+/** @deprecated */
export const FOCUSING_EDITOR_BUT_HIDDEN = 'FOCUSING_EDITOR_BUT_HIDDEN';
-export const FOCUSING_EDITOR = 'FOCUSING_EDITOR';
+
+export const EDITOR_ACTIVATED = 'EDITOR_ACTIVATED';
export const FOCUSING_EDITOR_INPUT_FORMULA = 'FOCUSING_EDITOR_INPUT_FORMULA';
export const FOCUSING_FORMULA_EDITOR = 'FOCUSING_FORMULA_EDITOR';
+
+export const FOCUSING_UNIVER_EDITOR = 'FOCUSING_UNIVER_EDITOR';
diff --git a/packages/core/src/services/locale/locale.service.ts b/packages/core/src/services/locale/locale.service.ts
index 124fbb832d..a3a841a9cc 100644
--- a/packages/core/src/services/locale/locale.service.ts
+++ b/packages/core/src/services/locale/locale.service.ts
@@ -48,9 +48,9 @@ function getValue(locale: ILocales[LocaleType], key: string): Nullable<string> {
* This service provides i18n and timezone / location features to other modules.
*/
export class LocaleService extends Disposable {
- private currentLocale: LocaleType = LocaleType.ZH_CN;
+ private _currentLocale: LocaleType = LocaleType.ZH_CN;
- private locales: ILocales | null = null;
+ private _locales: ILocales | null = null;
localeChanged$ = new Subject<void>();
@@ -68,25 +68,25 @@ export class LocaleService extends Disposable {
*
*/
load(locales: ILocales) {
- this.locales = Tools.deepMerge(this.locales ?? {}, locales);
+ this._locales = Tools.deepMerge(this._locales ?? {}, locales);
}
t = (key: string): string => {
- if (!this.locales) throw new Error('Locale not initialized');
+ if (!this._locales) throw new Error('Locale not initialized');
- return getValue(this.locales[this.currentLocale], key) ?? key;
+ return getValue(this._locales[this._currentLocale], key) ?? key;
};
setLocale(locale: LocaleType): void {
- this.currentLocale = locale;
+ this._currentLocale = locale;
this.localeChanged$.next();
}
getLocales() {
- return this.locales?.[this.currentLocale];
+ return this._locales?.[this._currentLocale];
}
getCurrentLocale() {
- return this.currentLocale;
+ return this._currentLocale;
}
}
diff --git a/packages/core/src/services/log/log.service.ts b/packages/core/src/services/log/log.service.ts
index b91c5e6c68..b610aac72e 100644
--- a/packages/core/src/services/log/log.service.ts
+++ b/packages/core/src/services/log/log.service.ts
@@ -80,7 +80,7 @@ export class DesktopLogService extends Disposable implements ILogService {
const firstArg = args[0];
const withTag = /^\[(.*?)\]/g.test(firstArg);
if (withTag) {
- method(`\x1B[97;104m${firstArg}\x1B[0m:`, ...args.slice(1));
+ method(`\x1B[97;104m${firstArg}\x1B[0m`, ...args.slice(1));
} else {
method(...args);
}
diff --git a/packages/core/src/services/undoredo/undoredo.service.ts b/packages/core/src/services/undoredo/undoredo.service.ts
index 95a2fff83c..62ad7abbcd 100644
--- a/packages/core/src/services/undoredo/undoredo.service.ts
+++ b/packages/core/src/services/undoredo/undoredo.service.ts
@@ -23,7 +23,7 @@ import { DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY } f
import { Disposable, toDisposable } from '../../shared/lifecycle';
import type { ICommand, IMutationInfo } from '../command/command.service';
import { CommandType, ICommandService, sequenceExecute } from '../command/command.service';
-import { FOCUSING_EDITOR, FOCUSING_FORMULA_EDITOR, FOCUSING_SHEET } from '../context/context';
+import { EDITOR_ACTIVATED, FOCUSING_FORMULA_EDITOR, FOCUSING_SHEET } from '../context/context';
import { IContextService } from '../context/context.service';
import { IUniverInstanceService } from '../instance/instance.service';
@@ -225,7 +225,7 @@ export class LocalUndoRedoService extends Disposable implements IUndoRedoService
const isFocusSheet = this._contextService.getContextValue(FOCUSING_SHEET);
const isFocusFormulaEditor = this._contextService.getContextValue(FOCUSING_FORMULA_EDITOR);
- const isFocusEditor = this._contextService.getContextValue(FOCUSING_EDITOR);
+ const isFocusEditor = this._contextService.getContextValue(EDITOR_ACTIVATED);
if (isFocusSheet) {
if (isFocusFormulaEditor) {
diff --git a/packages/core/src/sheets/worksheet.ts b/packages/core/src/sheets/worksheet.ts
index 7e9c0445ae..53f53097ad 100644
--- a/packages/core/src/sheets/worksheet.ts
+++ b/packages/core/src/sheets/worksheet.ts
@@ -491,4 +491,8 @@ export class Worksheet {
cellHasValue(value: ICellData) {
return value && (value.v !== undefined || value.f !== undefined || value.p !== undefined);
}
+
+ // #region iterators
+
+ // #endregion
}
diff --git a/packages/core/src/types/interfaces/i-cell-data.ts b/packages/core/src/types/interfaces/i-cell-data.ts
index 404cd848f5..7872c2a433 100644
--- a/packages/core/src/types/interfaces/i-cell-data.ts
+++ b/packages/core/src/types/interfaces/i-cell-data.ts
@@ -22,7 +22,7 @@ import type { IStyleData } from './i-style-data';
/**
* Cell value type
*/
-export type ICellV = string | number | boolean;
+export type CellValue = string | number | boolean;
/**
* Cell data
@@ -38,7 +38,7 @@ export interface ICellData {
/**
* Origin value
*/
- v?: Nullable<ICellV>;
+ v?: Nullable<CellValue>;
// Usually the type is automatically determined based on the data, or the user directly specifies
t?: Nullable<CellValueType>; // 1 string, 2 number, 3 boolean, 4 force string, green icon, set null for cell clear all
f?: Nullable<string>; // formula '=SUM(1)'
@@ -100,6 +100,6 @@ export function isNullCell(cell: Nullable<ICellData>) {
return true;
}
-export function isCellV(cell: Nullable<ICellData | ICellV>) {
+export function isCellV(cell: Nullable<ICellData | CellValue>) {
return cell != null && (typeof cell === 'string' || typeof cell === 'number' || typeof cell === 'boolean');
}
diff --git a/packages/design/package.json b/packages/design/package.json
index c180b70ceb..5ed3783a7c 100644
--- a/packages/design/package.json
+++ b/packages/design/package.json
@@ -62,7 +62,8 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-draggable": "^4.4.6",
- "react-transition-group": "^4.4.5"
+ "react-transition-group": "^4.4.5",
+ "rxjs": "^7.8.1"
},
"devDependencies": {
"@testing-library/react": "^14.1.2",
@@ -81,6 +82,7 @@
},
"peerDependencies": {
"react": ">=16.9.0",
- "react-dom": ">=16.9.0"
+ "react-dom": ">=16.9.0",
+ "rxjs": "^7.8.1"
}
}
diff --git a/packages/design/src/components/dialog/index.module.less b/packages/design/src/components/dialog/index.module.less
index 85f6c11bad..8cc59b8b20 100644
--- a/packages/design/src/components/dialog/index.module.less
+++ b/packages/design/src/components/dialog/index.module.less
@@ -17,6 +17,7 @@
&-title {
margin: 0;
+ padding: 24px 28px 20px;
font-size: var(--font-size-lg);
font-weight: 500;
}
@@ -62,7 +63,6 @@
&-header {
box-sizing: border-box;
- padding: 24px 28px 20px;
color: rgb(var(--text-color));
border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}
diff --git a/packages/design/src/components/icon/Icon.stories.tsx b/packages/design/src/components/icon/Icon.stories.tsx
index 8d661f4126..cc541c1b0d 100644
--- a/packages/design/src/components/icon/Icon.stories.tsx
+++ b/packages/design/src/components/icon/Icon.stories.tsx
@@ -29,7 +29,7 @@ const meta: Meta = {
export default meta;
-export const PlayGround = {
+export const Playground = {
render() {
function handleRedirect() {
window.open('https://univer-icons.vercel.app/', '_blank');
diff --git a/packages/design/src/components/input/Input.tsx b/packages/design/src/components/input/Input.tsx
index b05f10c206..ddd5cfb356 100644
--- a/packages/design/src/components/input/Input.tsx
+++ b/packages/design/src/components/input/Input.tsx
@@ -22,6 +22,8 @@ import React from 'react';
import styles from './index.module.less';
export interface IInputProps {
+ autoFocus?: boolean;
+
/**
* The input affix wrapper style
*/
@@ -92,6 +94,7 @@ export function Input(props: IInputProps) {
onClick,
onKeyDown,
onChange,
+ autoFocus,
} = props;
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
@@ -115,6 +118,7 @@ export function Input(props: IInputProps) {
styles={{
affixWrapper: affixWrapperStyle,
}}
+ autoFocus={autoFocus}
type={type}
placeholder={placeholder}
value={value}
diff --git a/packages/design/src/components/input/index.module.less b/packages/design/src/components/input/index.module.less
index 840b8a8444..731ef8a83f 100644
--- a/packages/design/src/components/input/index.module.less
+++ b/packages/design/src/components/input/index.module.less
@@ -1,5 +1,6 @@
.input {
box-sizing: border-box;
+ width: 100%;
color: rgb(var(--text-color));
&::selection {
@@ -100,7 +101,11 @@
&-slot-container {
position: relative;
- display: inline-block;
+ display: flex;
+
+ > span {
+ width: 100%;
+ }
}
&-slot {
diff --git a/packages/design/src/hooks/observable.ts b/packages/design/src/hooks/observable.ts
new file mode 100644
index 0000000000..bcb891f2cd
--- /dev/null
+++ b/packages/design/src/hooks/observable.ts
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type React from 'react';
+import { useRef, useState } from 'react';
+import type { Observable, Subscription } from 'rxjs';
+
+export function useObservable<T>(observable: Observable<T>, defaultValue?: T): T | undefined;
+export function useObservable<T>(observable: Observable<T>, defaultValue?: T, shouldHaveSyncValue?: true): T;
+export function useObservable<T>(
+ observable: Observable<T>,
+ defaultValue?: T,
+ shouldHaveSyncValue?: true
+): T | undefined {
+ const observableRef = useRef<Observable<T> | null>(null);
+ const subscriptionRef = useRef<Subscription | null>(null);
+
+ let setValue: React.Dispatch<React.SetStateAction<T | undefined>>;
+ let initialized = false;
+ let innerDefaultValue: T | undefined;
+ if (!observableRef.current || observableRef.current !== observable) {
+ subscriptionRef.current?.unsubscribe();
+ subscriptionRef.current = observable.subscribe((v) => {
+ if (setValue) {
+ setValue(v);
+ } else {
+ innerDefaultValue = v;
+ initialized = true;
+ }
+ });
+ }
+
+ if (shouldHaveSyncValue && !initialized) {
+ throw new Error('[useObservable]: expect shouldHaveSyncValue but not getting a sync value!');
+ }
+
+ const s = useState<T | undefined>(innerDefaultValue || defaultValue);
+ const value = s[0];
+ setValue = s[1];
+
+ return value;
+}
diff --git a/packages/design/src/index.ts b/packages/design/src/index.ts
index 971916017a..7e1f2703d4 100644
--- a/packages/design/src/index.ts
+++ b/packages/design/src/index.ts
@@ -26,7 +26,7 @@ export { Container, type IContainerProps } from './components/container';
export { Dialog, type IDialogProps } from './components/dialog';
export { Dropdown, type IDropdownProps } from './components/dropdown';
export { FormLayout, type IFormLayoutProps } from './components/form-layout';
-export { type IInputProps, Input } from './components/input';
+export { type IInputProps, type IInputWithSlotProps, Input, InputWithSlot } from './components/input';
export { type IInputNumberProps, InputNumber } from './components/input-number';
export { Menu, MenuItem, MenuItemGroup, SubMenu } from './components/menu';
export { type IMessageMethodOptions, type IMessageProps, Message, MessageType } from './components/message';
@@ -40,6 +40,7 @@ export { type ISelectListProps, SelectList } from './components/select-list';
export { type ISliderProps, Slider } from './components/slider';
export { type ITooltipProps, Tooltip } from './components/tooltip';
export { type ITreeNodeProps, type ITreeProps, Tree, TreeSelectionMode } from './components/tree';
+export { useObservable } from './hooks/observable';
export { enUS, zhCN } from './locale';
export { type ILocale } from './locale/interface';
export { defaultTheme, greenTheme, themeInstance } from './themes';
diff --git a/packages/docs/src/commands/commands/clipboard.command.ts b/packages/docs/src/commands/commands/clipboard.command.ts
index 79a9877d3d..1db519d281 100644
--- a/packages/docs/src/commands/commands/clipboard.command.ts
+++ b/packages/docs/src/commands/commands/clipboard.command.ts
@@ -15,7 +15,7 @@
*/
import type { IMultiCommand } from '@univerjs/core';
-import { CommandType, FOCUSING_DOC, FOCUSING_EDITOR } from '@univerjs/core';
+import { CommandType, EDITOR_ACTIVATED, FOCUSING_DOC } from '@univerjs/core';
import { CopyCommand, CutCommand, PasteCommand } from '@univerjs/ui';
export const DocCopyCommand: IMultiCommand = {
@@ -25,7 +25,7 @@ export const DocCopyCommand: IMultiCommand = {
multi: true,
priority: 999,
preconditions: (contextService) =>
- contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(FOCUSING_EDITOR),
+ contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED),
handler: async () => true,
};
@@ -36,7 +36,7 @@ export const DocCutCommand: IMultiCommand = {
multi: true,
priority: 999,
preconditions: (contextService) =>
- contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(FOCUSING_EDITOR),
+ contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED),
handler: async () => true,
};
@@ -47,6 +47,6 @@ export const DocPasteCommand: IMultiCommand = {
multi: true,
priority: 999,
preconditions: (contextService) =>
- contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(FOCUSING_EDITOR),
+ contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED),
handler: async () => true,
};
diff --git a/packages/docs/src/controllers/clipboard.controller.ts b/packages/docs/src/controllers/clipboard.controller.ts
index 0fa2d2f905..b2966439dc 100644
--- a/packages/docs/src/controllers/clipboard.controller.ts
+++ b/packages/docs/src/controllers/clipboard.controller.ts
@@ -17,8 +17,8 @@
import type { ICommandInfo, IDocumentBody } from '@univerjs/core';
import {
Disposable,
+ EDITOR_ACTIVATED,
FOCUSING_DOC,
- FOCUSING_EDITOR,
ICommandService,
IContextService,
ILogService,
@@ -68,7 +68,7 @@ export class DocClipboardController extends Disposable {
if (
!this._contextService.getContextValue(FOCUSING_DOC) &&
- !this._contextService.getContextValue(FOCUSING_EDITOR)
+ !this._contextService.getContextValue(EDITOR_ACTIVATED)
) {
return;
}
diff --git a/packages/docs/src/controllers/text-selection.controller.ts b/packages/docs/src/controllers/text-selection.controller.ts
index 1054a4435c..39e837a858 100644
--- a/packages/docs/src/controllers/text-selection.controller.ts
+++ b/packages/docs/src/controllers/text-selection.controller.ts
@@ -77,6 +77,7 @@ export class TextSelectionController extends Disposable {
if (this._layoutService) {
this.disposeWithMe(
+ // the content editable div should be regarded as part of the applications container
this._layoutService.registerContainer(this._textSelectionRenderManager.__getEditorContainer())
);
}
diff --git a/packages/docs/src/shortcuts/cursor.shortcut.ts b/packages/docs/src/shortcuts/cursor.shortcut.ts
index 03067fbfb1..0c066e2706 100644
--- a/packages/docs/src/shortcuts/cursor.shortcut.ts
+++ b/packages/docs/src/shortcuts/cursor.shortcut.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { Direction, FOCUSING_DOC, FOCUSING_EDITOR } from '@univerjs/core';
+import { Direction, EDITOR_ACTIVATED, FOCUSING_DOC } from '@univerjs/core';
import type { IShortcutItem } from '@univerjs/ui';
import { KeyCode, MetaKeys } from '@univerjs/ui';
@@ -97,5 +97,5 @@ export const SelectAllShortcut: IShortcutItem = {
id: SelectAllOperation.id,
binding: KeyCode.A | MetaKeys.CTRL_COMMAND,
preconditions: (contextService) =>
- contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(FOCUSING_EDITOR),
+ contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED),
};
diff --git a/packages/engine-render/src/components/docs/text-selection-render-manager.ts b/packages/engine-render/src/components/docs/text-selection-render-manager.ts
index 9285fd23c3..216ad0e310 100644
--- a/packages/engine-render/src/components/docs/text-selection-render-manager.ts
+++ b/packages/engine-render/src/components/docs/text-selection-render-manager.ts
@@ -636,6 +636,7 @@ export class TextSelectionRenderManager extends RxDisposable implements ITextSel
this._input.contentEditable = 'true';
+ this._input.classList.add('univer-editor');
this._input.style.cssText = `
position: absolute;
overflow: hidden;
diff --git a/packages/find-replace/docs/README.md b/packages/find-replace/docs/README.md
index eb03becd14..6d0d902e15 100644
--- a/packages/find-replace/docs/README.md
+++ b/packages/find-replace/docs/README.md
@@ -1,25 +1,38 @@
-# Design Spec of Search & Replace
+# Design Spec of Find & Replace
-Author: [@wzhudev](https://github/wzhudev)
+## Introduction
----
+Find & Replace (F&D) is a common feature in text editors. It is used to search for a string in the text and replace it with another string.
-## Introduction
+F&D is usually used in conjunction with the editor's regular expression feature.
## Architecture
+Overall, F&D is divided into many packages and works as plugins. This package (@univerjs/find-replace) provides the find and replace scheduling service, interface and UI, and the business packages (e.g. @univerjs/sheets-find-replace) provide specific search and replace logics.
+
+What does this package do?
+
+- UI
+ - TODO: Some UI should be determined by business plugins?
+
+What do business packages (e.g @univerjs/sheets-find-replace) do?
+
由 find-replace 包提供查找替换的调度服务、接口以及 UI,业务包提供具体的查找替换方法
-* 输入查找内容
-* 确定搜索范围,当前 focused 的业务,或者全部的业务
-* 切换查找模式
-* 接收各个业务提供的查找结果(可能需要支持动态查找)
-* 定位查找项的位置
-* 结束查找
-* 执行替换或者全部替换
+- 输入查找内容
+- 确定搜索范围,当前 focused 的业务,或者全部的业务
+- 切换查找模式
+- 接收各个业务提供的查找结果(可能需要支持动态查找)
+- 定位查找项的位置
+- 结束查找
+- 执行替换或者全部替换
各个包要做的事情
-* 根据查找字符串的变化来搜索并把结果塞给 find-replace
-* 查找高亮,定位到查找位置
-* 执行替换
\ No newline at end of file
+- 根据查找字符串的变化来搜索并把结果塞给 find-replace
+- 查找高亮,定位到查找位置
+- 执行替换 & re-update 查找结果
+
+## Supported features in Jan 2024
+
+## Features to be supported in the future
diff --git a/packages/find-replace/docs/arch.excalidraw b/packages/find-replace/docs/arch.excalidraw
deleted file mode 100644
index 6ede9d5a7c..0000000000
--- a/packages/find-replace/docs/arch.excalidraw
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "type": "excalidraw",
- "version": 2,
- "source": "https://marketplace.visualstudio.com/items?itemName=pomdtr.excalidraw-editor",
- "elements": [
- {
- "id": "3k5lrIK0dFvyvu1cHvnQ4",
- "type": "rectangle",
- "x": 346,
- "y": 347.5,
- "width": 264,
- "height": 73.5,
- "angle": 0,
- "strokeColor": "#1e1e1e",
- "backgroundColor": "transparent",
- "fillStyle": "solid",
- "strokeWidth": 2,
- "strokeStyle": "solid",
- "roughness": 1,
- "opacity": 100,
- "groupIds": [],
- "frameId": null,
- "roundness": {
- "type": 3
- },
- "seed": 1817001344,
- "version": 49,
- "versionNonce": 730611072,
- "isDeleted": false,
- "boundElements": null,
- "updated": 1704457441440,
- "link": null,
- "locked": false
- }
- ],
- "appState": {
- "gridSize": null,
- "viewBackgroundColor": "#ffffff"
- },
- "files": {}
-}
\ No newline at end of file
diff --git a/packages/find-replace/docs/find-replace.excalidraw b/packages/find-replace/docs/find-replace.excalidraw
new file mode 100644
index 0000000000..6ca155e3ef
--- /dev/null
+++ b/packages/find-replace/docs/find-replace.excalidraw
@@ -0,0 +1,2086 @@
+{
+ "type": "excalidraw",
+ "version": 2,
+ "source": "https://marketplace.visualstudio.com/items?itemName=pomdtr.excalidraw-editor",
+ "elements": [
+ {
+ "type": "rectangle",
+ "version": 203,
+ "versionNonce": 197671588,
+ "isDeleted": false,
+ "id": "APFIIosPcGxBYCW2XdWZm",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "dotted",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -441.4296861823343,
+ "y": -220.63488587909387,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 799.9991910032631,
+ "height": 591.2501348953097,
+ "seed": 391785116,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "9zycBuZmfY3pTNrfrMF9L"
+ }
+ ],
+ "updated": 1705452554727,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 174,
+ "versionNonce": 330384932,
+ "isDeleted": false,
+ "id": "9zycBuZmfY3pTNrfrMF9L",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "dotted",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -146.73998905716758,
+ "y": -215.63488587909387,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 210.6197967529297,
+ "height": 25,
+ "seed": 1618425884,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452554727,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "@univerjs/find-replace",
+ "textAlign": "center",
+ "verticalAlign": "top",
+ "containerId": "APFIIosPcGxBYCW2XdWZm",
+ "originalText": "@univerjs/find-replace",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 506,
+ "versionNonce": 365551268,
+ "isDeleted": false,
+ "id": "3k5lrIK0dFvyvu1cHvnQ4",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -54.49819954538475,
+ "y": 119.71633018036295,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 264,
+ "height": 59.6408390230043,
+ "seed": 1817001344,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "DI_AhHIJInfY7Tc-6kBTE"
+ },
+ {
+ "id": "D3eHBFDmFItjlJSBDvzvF",
+ "type": "arrow"
+ },
+ {
+ "id": "w2oCgiWsbqhbi4hLmEqyM",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452566182,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 331,
+ "versionNonce": 903768612,
+ "isDeleted": false,
+ "id": "DI_AhHIJInfY7Tc-6kBTE",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "dotted",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -11.518119894505844,
+ "y": 137.0367496918651,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 178.0398406982422,
+ "height": 25,
+ "seed": 862979876,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452566182,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "FindReplaceService",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "3k5lrIK0dFvyvu1cHvnQ4",
+ "originalText": "FindReplaceService",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 49,
+ "versionNonce": 1290084132,
+ "isDeleted": false,
+ "id": "wtp2rhc4MhGuz_ZBt7tUx",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -472.8664353118853,
+ "y": 1015.7844548758511,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 205.51478684086737,
+ "height": 44.43562958721452,
+ "seed": 660829988,
+ "groupIds": [],
+ "frameId": "RAZCQwkS_owmDzZgOc-Wb",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [],
+ "updated": 1705452498295,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "frame",
+ "version": 208,
+ "versionNonce": 947131292,
+ "isDeleted": false,
+ "id": "RAZCQwkS_owmDzZgOc-Wb",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 0,
+ "opacity": 100,
+ "angle": 0,
+ "x": -554.748792862958,
+ "y": 965.0800319507457,
+ "strokeColor": "#bbb",
+ "backgroundColor": "transparent",
+ "width": 1768.666414439623,
+ "height": 1134.7689759761881,
+ "seed": 834465849,
+ "groupIds": [],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452210821,
+ "link": null,
+ "locked": false,
+ "name": "Time sequence of Finding"
+ },
+ {
+ "type": "frame",
+ "version": 234,
+ "versionNonce": 1195213860,
+ "isDeleted": false,
+ "id": "jknAyiXTw-WH2OGSHJRct",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 0,
+ "opacity": 100,
+ "angle": 0,
+ "x": -260.30041638283683,
+ "y": 2320.1365052334527,
+ "strokeColor": "#bbb",
+ "backgroundColor": "transparent",
+ "width": 1745.5314014719484,
+ "height": 1449.4043157000042,
+ "seed": 1711278327,
+ "groupIds": [],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452210821,
+ "link": null,
+ "locked": false,
+ "name": "Time sequence of Replacing"
+ },
+ {
+ "type": "rectangle",
+ "version": 334,
+ "versionNonce": 1628846116,
+ "isDeleted": false,
+ "id": "gR6_2S7O3dhI3Q6u5Ne4Z",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -101.49813551956379,
+ "y": 178.45807323837124,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 179.0141626195284,
+ "height": 53.704248785858546,
+ "seed": 1660519716,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "n-4s0sivEdIMbKR1jaNLp"
+ }
+ ],
+ "updated": 1705452566183,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 312,
+ "versionNonce": 1499698084,
+ "isDeleted": false,
+ "id": "n-4s0sivEdIMbKR1jaNLp",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -59.80101362142068,
+ "y": 192.81019763130053,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 95.61991882324219,
+ "height": 25,
+ "seed": 1934940068,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452566183,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "FindState",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "gR6_2S7O3dhI3Q6u5Ne4Z",
+ "originalText": "FindState",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 221,
+ "versionNonce": 439572772,
+ "isDeleted": false,
+ "id": "OCbKzB58DDQX6VE_52dh0",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "dotted",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 426.460654867834,
+ "y": -308.87984691080834,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 625.7459649976499,
+ "height": 337.88394490069186,
+ "seed": 1226183076,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "xSb62jB4SynItJZkWMa7k"
+ }
+ ],
+ "updated": 1705452549296,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 216,
+ "versionNonce": 338990244,
+ "isDeleted": false,
+ "id": "xSb62jB4SynItJZkWMa7k",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "dotted",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 597.5237923959559,
+ "y": -303.87984691080834,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 283.61968994140625,
+ "height": 25,
+ "seed": 1027317156,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452549296,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "@univerjs/sheets-find-replace",
+ "textAlign": "center",
+ "verticalAlign": "top",
+ "containerId": "OCbKzB58DDQX6VE_52dh0",
+ "originalText": "@univerjs/sheets-find-replace",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 387,
+ "versionNonce": 1099063332,
+ "isDeleted": false,
+ "id": "1KToDHekSBwFuWd0YcO5d",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 470.9079669566388,
+ "y": -233.18491204810965,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 314.2886973517607,
+ "height": 63.011155388580576,
+ "seed": 45174052,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "XNVInxKVJoE8R0591ZHlV"
+ }
+ ],
+ "updated": 1705452549296,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 463,
+ "versionNonce": 705346468,
+ "isDeleted": false,
+ "id": "XNVInxKVJoE8R0591ZHlV",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 492.5824364821285,
+ "y": -214.17933435381934,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 270.93975830078125,
+ "height": 25,
+ "seed": 1968980132,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452549296,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "SheetsFindReplaceController",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "1KToDHekSBwFuWd0YcO5d",
+ "originalText": "SheetsFindReplaceController",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 283,
+ "versionNonce": 1653438884,
+ "isDeleted": false,
+ "id": "Gyb1QOM-Km9-1_h8ik-cG",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -374.9873206459264,
+ "y": -120.23764317970051,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 335.46797749955795,
+ "height": 58.516213921348935,
+ "seed": 365242908,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "y7dVvKFWTQs1YnBetWjzM"
+ },
+ {
+ "id": "gozwKbAr6uVgeiCNdb2gq",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452560181,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 212,
+ "versionNonce": 2104927524,
+ "isDeleted": false,
+ "id": "y7dVvKFWTQs1YnBetWjzM",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -312.36325621255367,
+ "y": -103.47953621902604,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 210.2198486328125,
+ "height": 25,
+ "seed": 1748919452,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452560181,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "UI: FindReplaceDialog",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "Gyb1QOM-Km9-1_h8ik-cG",
+ "originalText": "UI: FindReplaceDialog",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 258,
+ "versionNonce": 1812039588,
+ "isDeleted": false,
+ "id": "qJhLvMmsyhsnge5jE3Dyn",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 69.54714317593346,
+ "y": -123.06907288557227,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 245.39057450888242,
+ "height": 65.84258509445237,
+ "seed": 1650363684,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "PFCtrQ5vblU5RudeQQMWj"
+ },
+ {
+ "id": "9UX3QcLJW8ouxM1sXuSyL",
+ "type": "arrow"
+ },
+ {
+ "id": "gozwKbAr6uVgeiCNdb2gq",
+ "type": "arrow"
+ },
+ {
+ "id": "w2oCgiWsbqhbi4hLmEqyM",
+ "type": "arrow"
+ },
+ {
+ "id": "Gy_qSZg5yO8QPwqz6Dwi7",
+ "type": "arrow"
+ },
+ {
+ "id": "KAn6K1RKci0BCi1FqN4Bh",
+ "type": "arrow"
+ },
+ {
+ "id": "mkNaes2ecUt44hhr3j1sT",
+ "type": "arrow"
+ },
+ {
+ "id": "_jbszeo4JYiiP1a_tR-gk",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452560181,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 182,
+ "versionNonce": 423162660,
+ "isDeleted": false,
+ "id": "PFCtrQ5vblU5RudeQQMWj",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 89.81252167793326,
+ "y": -102.64778033834608,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 204.8598175048828,
+ "height": 25,
+ "seed": 1951940900,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452560181,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "FindReplaceController",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "qJhLvMmsyhsnge5jE3Dyn",
+ "originalText": "FindReplaceController",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 197,
+ "versionNonce": 670803748,
+ "isDeleted": false,
+ "id": "HB3g6jVi-4i1eSYF9ahxa",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 522.7292648674724,
+ "y": -131.44358534284726,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 322.7829864693758,
+ "height": 56.48598708784477,
+ "seed": 1676496412,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "MSGaUXax2iRQWMJKeyAvj"
+ },
+ {
+ "id": "D3eHBFDmFItjlJSBDvzvF",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452549296,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 164,
+ "versionNonce": 532882084,
+ "isDeleted": false,
+ "id": "MSGaUXax2iRQWMJKeyAvj",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 556.4908829190548,
+ "y": -115.70059179892488,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 255.25975036621094,
+ "height": 25,
+ "seed": 879260444,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452549296,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "SheetsFindReplaceProvider",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "HB3g6jVi-4i1eSYF9ahxa",
+ "originalText": "SheetsFindReplaceProvider",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "arrow",
+ "version": 669,
+ "versionNonce": 2053871772,
+ "isDeleted": false,
+ "id": "D3eHBFDmFItjlJSBDvzvF",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 699.7642663936174,
+ "y": -67.4071190393446,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 481.2402110920539,
+ "height": 213.30341740172838,
+ "seed": 324966180,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "IWE8KuDJDjR5lCr463Ehd"
+ }
+ ],
+ "updated": 1705452574413,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "HB3g6jVi-4i1eSYF9ahxa",
+ "focus": -0.2914771857889858,
+ "gap": 7.5504792156579015
+ },
+ "endBinding": {
+ "elementId": "3k5lrIK0dFvyvu1cHvnQ4",
+ "focus": 0.2877695212427763,
+ "gap": 9.022254846948215
+ },
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ -205.77640351902954,
+ 180.6288404639834
+ ],
+ [
+ -481.2402110920539,
+ 213.30341740172838
+ ]
+ ]
+ },
+ {
+ "type": "text",
+ "version": 28,
+ "versionNonce": 1639462820,
+ "isDeleted": false,
+ "id": "IWE8KuDJDjR5lCr463Ehd",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 241.58685553259465,
+ "y": 136.80640718055872,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 218.47979736328125,
+ "height": 25,
+ "seed": 1694546724,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "register as a provider",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "D3eHBFDmFItjlJSBDvzvF",
+ "originalText": "register as a provider",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 292,
+ "versionNonce": 720756004,
+ "isDeleted": false,
+ "id": "HQnkaiH2gl1xNlCEDlTTf",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -329.3381463462889,
+ "y": -18.69087928274189,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 130.82927059346093,
+ "height": 53.62964274928936,
+ "seed": 455203620,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "xSH9QwJ2ENJCQt_g96R23"
+ },
+ {
+ "id": "9UX3QcLJW8ouxM1sXuSyL",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452560182,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 243,
+ "versionNonce": 1913034916,
+ "isDeleted": false,
+ "id": "xSH9QwJ2ENJCQt_g96R23",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -309.60347320776157,
+ "y": -4.376057908097209,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 91.35992431640625,
+ "height": 25,
+ "seed": 1261464868,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452560182,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "commands",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "HQnkaiH2gl1xNlCEDlTTf",
+ "originalText": "commands",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 114,
+ "versionNonce": 1705021724,
+ "isDeleted": false,
+ "id": "b0XkBxwP48Un6WKuSl-SR",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "dotted",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -91.47098365822717,
+ "y": 423.6487113859321,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 939.854392425083,
+ "height": 267.4304207719275,
+ "seed": 951185828,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "GHe-LBJQyIS4WGkU_H6uY"
+ }
+ ],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 140,
+ "versionNonce": 792829604,
+ "isDeleted": false,
+ "id": "GHe-LBJQyIS4WGkU_H6uY",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "dotted",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 321.28626779113074,
+ "y": 428.6487113859321,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 114.33988952636719,
+ "height": 25,
+ "seed": 5098532,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "@univerjs/ui",
+ "textAlign": "center",
+ "verticalAlign": "top",
+ "containerId": "b0XkBxwP48Un6WKuSl-SR",
+ "originalText": "@univerjs/ui",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 207,
+ "versionNonce": 566054436,
+ "isDeleted": false,
+ "id": "b0flu2Bus-LpFSdgrW5yI",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 802.5967762665806,
+ "y": -47.71502480662008,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 220.75745288434013,
+ "height": 57.60769095803483,
+ "seed": 1261941660,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "vlaTEo7cfPr_bSfTTSigb"
+ },
+ {
+ "id": "UkVHf29YWzjgJme0WUFZj",
+ "type": "arrow"
+ },
+ {
+ "id": "xYVQW4hADxbm_3G6Cdk2T",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452588649,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 152,
+ "versionNonce": 2946340,
+ "isDeleted": false,
+ "id": "vlaTEo7cfPr_bSfTTSigb",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "dotted",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 830.0055854113874,
+ "y": -31.411179327602667,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 165.93983459472656,
+ "height": 25,
+ "seed": 1936702372,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452549297,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "SheetsFindResult",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "b0flu2Bus-LpFSdgrW5yI",
+ "originalText": "SheetsFindResult",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "arrow",
+ "version": 472,
+ "versionNonce": 1660356132,
+ "isDeleted": false,
+ "id": "UkVHf29YWzjgJme0WUFZj",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 946.5093482010336,
+ "y": 18.77818389348272,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 680.9418472032785,
+ "height": 231.9754821515578,
+ "seed": 1797826716,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "b6OB2SMhGVBS29Ri7O4H-"
+ }
+ ],
+ "updated": 1705452566183,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "b0flu2Bus-LpFSdgrW5yI",
+ "focus": -0.5195027241716065,
+ "gap": 8.885517742067975
+ },
+ "endBinding": {
+ "elementId": "V6pHAi8qvDql57ew2In65",
+ "focus": 0.36900260665999424,
+ "gap": 7.304916156137665
+ },
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ -243.0254143235975,
+ 231.9754821515578
+ ],
+ [
+ -680.9418472032785,
+ 204.78971383763738
+ ]
+ ]
+ },
+ {
+ "type": "text",
+ "version": 65,
+ "versionNonce": 2027767204,
+ "isDeleted": false,
+ "id": "b6OB2SMhGVBS29Ri7O4H-",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 543.2408837220335,
+ "y": 166.4307606709658,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 215.39981079101562,
+ "height": 50,
+ "seed": 1810199844,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "returned to FindModel\nas a result",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "UkVHf29YWzjgJme0WUFZj",
+ "originalText": "returned to FindModel\nas a result",
+ "lineHeight": 1.25,
+ "baseline": 45
+ },
+ {
+ "type": "arrow",
+ "version": 567,
+ "versionNonce": 1982578596,
+ "isDeleted": false,
+ "id": "9UX3QcLJW8ouxM1sXuSyL",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 56.47667898182783,
+ "y": -81.80184256042028,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 242.78348175819673,
+ "height": 78.8070588559317,
+ "seed": 1472916900,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [],
+ "updated": 1705452560182,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "qJhLvMmsyhsnge5jE3Dyn",
+ "focus": 0.49391846603209955,
+ "gap": 13.070464194105625
+ },
+ "endBinding": {
+ "elementId": "HQnkaiH2gl1xNlCEDlTTf",
+ "focus": 0.2929451055011817,
+ "gap": 12.202072976459078
+ },
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ -242.78348175819673,
+ 78.8070588559317
+ ]
+ ]
+ },
+ {
+ "type": "arrow",
+ "version": 504,
+ "versionNonce": 845431076,
+ "isDeleted": false,
+ "id": "gozwKbAr6uVgeiCNdb2gq",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 59.237917269016776,
+ "y": -88.99892056312584,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 93.56346199021456,
+ "height": 0.14281455234861085,
+ "seed": 262408484,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [],
+ "updated": 1705452560181,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "qJhLvMmsyhsnge5jE3Dyn",
+ "gap": 10.309225906916708,
+ "focus": -0.02212661753222586
+ },
+ "endBinding": {
+ "elementId": "Gyb1QOM-Km9-1_h8ik-cG",
+ "gap": 5.193798425170598,
+ "focus": 0.05332514272492042
+ },
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ -93.56346199021456,
+ -0.14281455234861085
+ ]
+ ]
+ },
+ {
+ "type": "arrow",
+ "version": 486,
+ "versionNonce": 1331915940,
+ "isDeleted": false,
+ "id": "w2oCgiWsbqhbi4hLmEqyM",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 215.79429760701765,
+ "y": -45.72473179862544,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 116.93566043458976,
+ "height": 155.2715257228105,
+ "seed": 1121053084,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [],
+ "updated": 1705452566183,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "qJhLvMmsyhsnge5jE3Dyn",
+ "focus": -0.3858008888629465,
+ "gap": 11.501755992494452
+ },
+ "endBinding": {
+ "elementId": "3k5lrIK0dFvyvu1cHvnQ4",
+ "focus": -0.05671301614342749,
+ "gap": 10.169536256177892
+ },
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ -116.93566043458976,
+ 155.2715257228105
+ ]
+ ]
+ },
+ {
+ "type": "rectangle",
+ "version": 193,
+ "versionNonce": 1393975196,
+ "isDeleted": false,
+ "id": "VOyJ04vCtdVgURpz-WNE8",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -43.945235501744605,
+ "y": 574.5535336760629,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 257.50079127588606,
+ "height": 48.28139836422872,
+ "seed": 1965045156,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "gS8bEAzBh4BaHFRn__7D4"
+ },
+ {
+ "id": "Gy_qSZg5yO8QPwqz6Dwi7",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 154,
+ "versionNonce": 1471543332,
+ "isDeleted": false,
+ "id": "gS8bEAzBh4BaHFRn__7D4",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 15.755225748991393,
+ "y": 586.1942328581772,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 138.09986877441406,
+ "height": 25,
+ "seed": 1407415076,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "IDialogService",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "VOyJ04vCtdVgURpz-WNE8",
+ "originalText": "IDialogService",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "arrow",
+ "version": 411,
+ "versionNonce": 369402788,
+ "isDeleted": false,
+ "id": "Gy_qSZg5yO8QPwqz6Dwi7",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 230.34287314613096,
+ "y": -49.87784476304,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 247.5810285130508,
+ "height": 614.1898696951756,
+ "seed": 54362140,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [],
+ "updated": 1705452560182,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "qJhLvMmsyhsnge5jE3Dyn",
+ "focus": -0.2727320466051228,
+ "gap": 7.348643028079891
+ },
+ "endBinding": {
+ "elementId": "VOyJ04vCtdVgURpz-WNE8",
+ "focus": -0.7033946601184256,
+ "gap": 10.241508743927284
+ },
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ 46.12480776927828,
+ 489.82869209034425
+ ],
+ [
+ -201.45622074377252,
+ 614.1898696951756
+ ]
+ ]
+ },
+ {
+ "type": "arrow",
+ "version": 352,
+ "versionNonce": 1282969380,
+ "isDeleted": false,
+ "id": "KAn6K1RKci0BCi1FqN4Bh",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 80.56551712924671,
+ "y": -46.67360846792323,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 309.58944636053394,
+ "height": 341.04872436368953,
+ "seed": 422253852,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [],
+ "updated": 1705452560182,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "qJhLvMmsyhsnge5jE3Dyn",
+ "focus": 0.47327959375451495,
+ "gap": 10.552879323196663
+ },
+ "endBinding": null,
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ -309.58944636053394,
+ 341.04872436368953
+ ]
+ ]
+ },
+ {
+ "type": "arrow",
+ "version": 516,
+ "versionNonce": 1081218596,
+ "isDeleted": false,
+ "id": "mkNaes2ecUt44hhr3j1sT",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 227.24838668468487,
+ "y": -49.87784476304,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 137.42554748346265,
+ "height": 576.149980074874,
+ "seed": 692302884,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [],
+ "updated": 1705452560182,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "qJhLvMmsyhsnge5jE3Dyn",
+ "focus": -0.19457568629216482,
+ "gap": 7.348643028079891
+ },
+ "endBinding": {
+ "elementId": "eUyp6XR1GFsJlmw5vH2tj",
+ "focus": -0.02006676870788884,
+ "gap": 8.778436066223378
+ },
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ 137.42554748346265,
+ 576.149980074874
+ ]
+ ]
+ },
+ {
+ "type": "arrow",
+ "version": 314,
+ "versionNonce": 1569960356,
+ "isDeleted": false,
+ "id": "_jbszeo4JYiiP1a_tR-gk",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 231.10956229639086,
+ "y": -49.87784476304,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 426.4885511608844,
+ "height": 621.505233083695,
+ "seed": 1855187108,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [],
+ "updated": 1705452560182,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "qJhLvMmsyhsnge5jE3Dyn",
+ "focus": -0.19842174662194723,
+ "gap": 7.348643028079891
+ },
+ "endBinding": {
+ "elementId": "X0zRBNS7RwsmIvn_S-ADu",
+ "focus": 0.14833702882483712,
+ "gap": 2.1946090165558303
+ },
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ 139.7263063309205,
+ 450.325729792339
+ ],
+ [
+ 426.4885511608844,
+ 621.505233083695
+ ]
+ ]
+ },
+ {
+ "type": "text",
+ "version": 172,
+ "versionNonce": 1696206718,
+ "isDeleted": false,
+ "id": "IOryEX0m_onvRtjG0sbhf",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 1017.2709569066435,
+ "y": 290.9406953179358,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 283.59979248046875,
+ "height": 75,
+ "seed": 702583844,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705464145822,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "Explanations:\n\n1. FindState is for managing ",
+ "textAlign": "left",
+ "verticalAlign": "top",
+ "containerId": null,
+ "originalText": "Explanations:\n\n1. FindState is for managing ",
+ "lineHeight": 1.25,
+ "baseline": 68
+ },
+ {
+ "type": "rectangle",
+ "version": 163,
+ "versionNonce": 1684567588,
+ "isDeleted": false,
+ "id": "yZePrElbt_qXzyZbndm65",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 78.73141232285514,
+ "y": 232.65573727128594,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 178.71482810681175,
+ "height": 45.197017865038106,
+ "seed": 1301236388,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "i9hIPd_drNzZe4cv335-R"
+ },
+ {
+ "id": "xYVQW4hADxbm_3G6Cdk2T",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452614351,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 97,
+ "versionNonce": 1619532956,
+ "isDeleted": false,
+ "id": "i9hIPd_drNzZe4cv335-R",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 118.15887184745242,
+ "y": 242.754246203805,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 99.85990905761719,
+ "height": 25,
+ "seed": 278657956,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452621663,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "FindResult",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "yZePrElbt_qXzyZbndm65",
+ "originalText": "FindResult",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "arrow",
+ "version": 175,
+ "versionNonce": 1941836196,
+ "isDeleted": false,
+ "id": "xYVQW4hADxbm_3G6Cdk2T",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "dashed",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 799.6532765173388,
+ "y": 14.319401258099333,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 530.6722862605602,
+ "height": 243.04905196754578,
+ "seed": 126823452,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 2
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "-hLtASnqkAi1r-mNQEgwW"
+ }
+ ],
+ "updated": 1705452614352,
+ "link": null,
+ "locked": false,
+ "startBinding": {
+ "elementId": "b0flu2Bus-LpFSdgrW5yI",
+ "focus": 0.4497004186674279,
+ "gap": 4.4267351066845855
+ },
+ "endBinding": {
+ "elementId": "yZePrElbt_qXzyZbndm65",
+ "gap": 11.534749827111682,
+ "focus": 0.632798469012219
+ },
+ "lastCommittedPoint": null,
+ "startArrowhead": null,
+ "endArrowhead": "arrow",
+ "points": [
+ [
+ 0,
+ 0
+ ],
+ [
+ -215.86460390737693,
+ 156.5430333679451
+ ],
+ [
+ -530.6722862605602,
+ 243.04905196754578
+ ]
+ ]
+ },
+ {
+ "type": "text",
+ "version": 8,
+ "versionNonce": 1293219364,
+ "isDeleted": false,
+ "id": "-hLtASnqkAi1r-mNQEgwW",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 545.7887107569345,
+ "y": 158.36243462604443,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 75.99992370605469,
+ "height": 25,
+ "seed": 1143922076,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452592613,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "extends",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "xYVQW4hADxbm_3G6Cdk2T",
+ "originalText": "extends",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "frame",
+ "version": 208,
+ "versionNonce": 1551690788,
+ "isDeleted": false,
+ "id": "Gsl-80wIfbrecjwDMEbmW",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 0,
+ "opacity": 100,
+ "angle": 0,
+ "x": -512.9337050558637,
+ "y": -362.55863013399227,
+ "strokeColor": "#bbb",
+ "backgroundColor": "transparent",
+ "width": 2559.3975605219225,
+ "height": 1109.938703946097,
+ "seed": 36793143,
+ "groupIds": [],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452510045,
+ "link": null,
+ "locked": false,
+ "name": "Architecture of Modules"
+ },
+ {
+ "type": "rectangle",
+ "version": 379,
+ "versionNonce": 645496612,
+ "isDeleted": false,
+ "id": "V6pHAi8qvDql57ew2In65",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 79.24842222208906,
+ "y": 178.74680575872537,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 179.0141626195284,
+ "height": 53.704248785858546,
+ "seed": 11247396,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "D3P-GZI40pbj7ulNO7P4o"
+ },
+ {
+ "id": "UkVHf29YWzjgJme0WUFZj",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452566183,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 366,
+ "versionNonce": 1086716580,
+ "isDeleted": false,
+ "id": "D3P-GZI40pbj7ulNO7P4o",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 123.47554289952905,
+ "y": 193.09893015165466,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 90.55992126464844,
+ "height": 25,
+ "seed": 1337203364,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452566183,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "FindModel",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "V6pHAi8qvDql57ew2In65",
+ "originalText": "FindModel",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 320,
+ "versionNonce": 1699459484,
+ "isDeleted": false,
+ "id": "X0zRBNS7RwsmIvn_S-ADu",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 547.8676626294824,
+ "y": 573.8219973372109,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 257.50079127588606,
+ "height": 48.28139836422872,
+ "seed": 2026817820,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "HxUwrVZeoqfs1A3n6VQni"
+ },
+ {
+ "id": "_jbszeo4JYiiP1a_tR-gk",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 292,
+ "versionNonce": 733398564,
+ "isDeleted": false,
+ "id": "HxUwrVZeoqfs1A3n6VQni",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 613.9281168611755,
+ "y": 585.4626965193252,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 125.3798828125,
+ "height": 25,
+ "seed": 382682524,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "IMenuService",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "X0zRBNS7RwsmIvn_S-ADu",
+ "originalText": "IMenuService",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 412,
+ "versionNonce": 614145564,
+ "isDeleted": false,
+ "id": "eUyp6XR1GFsJlmw5vH2tj",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 246.47469102247976,
+ "y": 535.0505713780574,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 257.50079127588606,
+ "height": 48.28139836422872,
+ "seed": 414935332,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "pnX7eNslUWxall93nkXJZ"
+ },
+ {
+ "id": "mkNaes2ecUt44hhr3j1sT",
+ "type": "arrow"
+ }
+ ],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 402,
+ "versionNonce": 1556242852,
+ "isDeleted": false,
+ "id": "pnX7eNslUWxall93nkXJZ",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 287.72517821315716,
+ "y": 546.6912705601717,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 174.99981689453125,
+ "height": 25,
+ "seed": 658154660,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452510154,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "IShortcutsService",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "eUyp6XR1GFsJlmw5vH2tj",
+ "originalText": "IShortcutsService",
+ "lineHeight": 1.25,
+ "baseline": 20
+ },
+ {
+ "type": "rectangle",
+ "version": 337,
+ "versionNonce": 1364994852,
+ "isDeleted": false,
+ "id": "DYgQNjmcv9t30k--WOBEm",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -398.52384906863824,
+ "y": 59.373092888777876,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 130.82927059346093,
+ "height": 53.62964274928936,
+ "seed": 291814428,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": {
+ "type": 3
+ },
+ "boundElements": [
+ {
+ "type": "text",
+ "id": "UNvua7DwfLGPp0vO6ohJz"
+ }
+ ],
+ "updated": 1705452560182,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 297,
+ "versionNonce": 1383278244,
+ "isDeleted": false,
+ "id": "UNvua7DwfLGPp0vO6ohJz",
+ "fillStyle": "solid",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": -380.7491597557945,
+ "y": 73.68791426342256,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "transparent",
+ "width": 95.27989196777344,
+ "height": 25,
+ "seed": 774822044,
+ "groupIds": [],
+ "frameId": "Gsl-80wIfbrecjwDMEbmW",
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1705452560182,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 1,
+ "text": "shortcuts",
+ "textAlign": "center",
+ "verticalAlign": "middle",
+ "containerId": "DYgQNjmcv9t30k--WOBEm",
+ "originalText": "shortcuts",
+ "lineHeight": 1.25,
+ "baseline": 20
+ }
+ ],
+ "appState": {
+ "gridSize": null,
+ "viewBackgroundColor": "#fffce8"
+ },
+ "files": {}
+}
\ No newline at end of file
diff --git a/packages/find-replace/package.json b/packages/find-replace/package.json
index a6465d36b4..72498f7709 100644
--- a/packages/find-replace/package.json
+++ b/packages/find-replace/package.json
@@ -44,8 +44,12 @@
},
"dependencies": {
"@univerjs/core": "workspace:*",
+ "@univerjs/design": "workspace:*",
+ "@univerjs/icons": "^0.1.25",
"@univerjs/ui": "workspace:*",
"@wendellhu/redi": "^0.12.13",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
"rxjs": "^7.8.1"
},
"devDependencies": {
@@ -58,8 +62,12 @@
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
+ "@univerjs/design": "workspace:*",
+ "@univerjs/icons": "^0.1.25",
"@univerjs/ui": "workspace:*",
"@wendellhu/redi": ">=0.12.13",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
"rxjs": ">=7.0.0"
}
}
diff --git a/packages/find-replace/src/commands/operations/find-replace.operation.ts b/packages/find-replace/src/commands/operations/find-replace.operation.ts
index f36aa7dfb5..7e6d602dca 100644
--- a/packages/find-replace/src/commands/operations/find-replace.operation.ts
+++ b/packages/find-replace/src/commands/operations/find-replace.operation.ts
@@ -17,12 +17,62 @@
import type { IOperation } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
-export const ToggleFindReplaceDialogOperation: IOperation = {
+import { IFindReplaceService } from '../../services/find-replace.service';
+
+export const OpenFindDialogOperation: IOperation = {
+ id: 'ui.operation.open-find-dialog',
+ type: CommandType.OPERATION,
+ handler: (accessor) => {
+ const findReplaceService = accessor.get(IFindReplaceService);
+ findReplaceService.start();
+ return true;
+ },
+};
+
+export const OpenReplaceDialogOperation: IOperation = {
+ id: 'ui.operation.open-replace-dialog',
+ type: CommandType.OPERATION,
+ handler: (accessor) => {
+ const findReplaceService = accessor.get(IFindReplaceService);
+ findReplaceService.start();
+ return true;
+ },
+};
+
+export const ToggleReplaceDialogOperation: IOperation = {
+ id: 'ui.operation.toggle-replace-dialog',
+ type: CommandType.OPERATION,
+ handler: (accessor) => {
+ const findReplaceService = accessor.get(IFindReplaceService);
+ // findReplaceService.
+ return true;
+ },
+};
+
+export const CloseFindReplaceDialogOperation: IOperation = {
+ id: 'ui.operation.close-find-replace-dialog',
+ type: CommandType.OPERATION,
+ handler: (accessor) => {
+ return true;
+ },
+};
+
+export const GoToNextMatchOperation: IOperation = {
+ type: CommandType.OPERATION,
+ id: 'ui.operation.go-to-next-match',
+ handler: (accessor) => {
+ const findReplaceService = accessor.get(IFindReplaceService);
+ findReplaceService.moveToNextMatch();
+ return true;
+ },
+};
+
+export const GoToPreviousMatchOperation: IOperation = {
type: CommandType.OPERATION,
- id: 'ui.operation.toggle-find-replace-dialog',
+ id: 'ui.operation.go-to-previous-match',
handler: (accessor) => {
- const a = 1;
- // Toggle dialog
+ const findReplaceService = accessor.get(IFindReplaceService);
+ findReplaceService.moveToPreviousMatch();
return true;
},
};
diff --git a/packages/find-replace/src/controllers/find-replace.controller.ts b/packages/find-replace/src/controllers/find-replace.controller.ts
index aca3319c83..662cab9f83 100644
--- a/packages/find-replace/src/controllers/find-replace.controller.ts
+++ b/packages/find-replace/src/controllers/find-replace.controller.ts
@@ -14,22 +14,123 @@
* limitations under the License.
*/
-import { Disposable, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { IMenuService } from '@univerjs/ui';
+import {
+ ICommandService,
+ IContextService,
+ LifecycleStages,
+ LocaleService,
+ OnLifecycle,
+ RxDisposable,
+} from '@univerjs/core';
+import { SearchSingle16 } from '@univerjs/icons';
+import { ComponentManager, IDialogService, IFocusService, IMenuService, IShortcutService } from '@univerjs/ui';
import { Inject, Injector } from '@wendellhu/redi';
+import { takeUntil } from 'rxjs';
+import {
+ CloseFindReplaceDialogOperation,
+ GoToNextMatchOperation,
+ GoToPreviousMatchOperation,
+ OpenFindDialogOperation,
+ OpenReplaceDialogOperation,
+ ToggleReplaceDialogOperation,
+} from '../commands/operations/find-replace.operation';
+import { FIND_REPLACE_ACTIVATED } from '../services/context-keys';
+import { IFindReplaceService } from '../services/find-replace.service';
+import { FindReplaceDialog } from '../views/dialog/Dialog';
import { FindReplaceMenuItemFactory } from './find-replace.menu';
+import {
+ CloseFRDialogShortcutItem,
+ GoToNextFindMatchShortcutItem,
+ GoToPreviousFindMatchShortcutItem,
+ OpenFindDialogShortcutItem,
+ OpenReplaceDialogShortcutItem,
+} from './find-replace.shortcut';
-@OnLifecycle(LifecycleStages.Steady, FindReplaceController)
-export class FindReplaceController extends Disposable {
+const FIND_REPLACE_DIALOG_ID = 'DESKTOP_FIND_REPLACE_DIALOG';
+
+@OnLifecycle(LifecycleStages.Rendered, FindReplaceController)
+export class FindReplaceController extends RxDisposable {
constructor(
@IMenuService private readonly _menuService: IMenuService,
+ @IShortcutService private readonly _shortcutService: IShortcutService,
+ @ICommandService private readonly _commandService: ICommandService,
+ @IFindReplaceService private readonly _findReplaceService: IFindReplaceService,
+ @IDialogService private readonly _dialogService: IDialogService,
+ @IContextService private readonly _contextService: IContextService,
+ @IFocusService private readonly _focusService: IFocusService,
+ @Inject(LocaleService) private readonly _localeService: LocaleService,
+ @Inject(ComponentManager) private readonly _componentManager: ComponentManager,
@Inject(Injector) private readonly _injector: Injector
) {
super();
+ this._initOperations();
+ this._initUI();
+ this._initShortcuts();
+ }
+
+ private _initOperations(): void {
+ [
+ CloseFindReplaceDialogOperation,
+ OpenFindDialogOperation,
+ OpenReplaceDialogOperation,
+ ToggleReplaceDialogOperation,
+ GoToNextMatchOperation,
+ GoToPreviousMatchOperation,
+ ].forEach((c) => {
+ this.disposeWithMe(this._commandService.registerCommand(c));
+ });
+ }
+
+ private _initUI(): void {
[FindReplaceMenuItemFactory].forEach((f) => {
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(f)));
});
+
+ this.disposeWithMe(this._componentManager.register('FindReplaceDialog', FindReplaceDialog));
+ this.disposeWithMe(this._componentManager.register('SearchIcon', SearchSingle16));
+
+ // this controller is also responsible for toggling the FindReplaceDialog
+ this._findReplaceService.stateUpdates$.pipe(takeUntil(this.dispose$)).subscribe((newState) => {
+ if (newState.revealed === true) {
+ this._openPanel();
+ } else if (newState.revealed === false) {
+ this._closePanel();
+ }
+ });
+ }
+
+ private _initShortcuts(): void {
+ [
+ OpenReplaceDialogShortcutItem,
+ OpenFindDialogShortcutItem,
+ CloseFRDialogShortcutItem,
+ GoToPreviousFindMatchShortcutItem,
+ GoToNextFindMatchShortcutItem,
+ ].forEach((s) => {
+ this.disposeWithMe(this._shortcutService.registerShortcut(s));
+ });
+ }
+
+ private _openPanel(): void {
+ this._dialogService.open({
+ id: FIND_REPLACE_DIALOG_ID,
+ draggable: true,
+ width: 350,
+ title: { title: this._localeService.t('univer.find-replace.dialog.title') },
+ children: { label: 'FindReplaceDialog' },
+ onClose: () => this._closePanel(),
+ });
+
+ this._contextService.setContextValue(FIND_REPLACE_ACTIVATED, true);
+ }
+
+ private _closePanel(): void {
+ this._dialogService.close(FIND_REPLACE_DIALOG_ID);
+ this._contextService.setContextValue(FIND_REPLACE_ACTIVATED, false);
+ this._focusService.forceFocus();
+
+ this._findReplaceService.end();
}
}
diff --git a/packages/find-replace/src/controllers/find-replace.menu.ts b/packages/find-replace/src/controllers/find-replace.menu.ts
index 1808f76853..fb2c2bcad2 100644
--- a/packages/find-replace/src/controllers/find-replace.menu.ts
+++ b/packages/find-replace/src/controllers/find-replace.menu.ts
@@ -16,13 +16,13 @@
import type { IMenuButtonItem } from '@univerjs/ui';
import { MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
-import type { IAccessor } from '@wendellhu/redi';
-import { ToggleFindReplaceDialogOperation } from '../commands/operations/find-replace.operation';
+import { OpenFindDialogOperation } from '../commands/operations/find-replace.operation';
-export function FindReplaceMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
+export function FindReplaceMenuItemFactory(): IMenuButtonItem {
return {
- id: ToggleFindReplaceDialogOperation.id,
+ id: OpenFindDialogOperation.id,
+ icon: 'SearchIcon',
tooltip: 'toolbar.find-replace',
group: MenuGroup.TOOLBAR_OTHERS,
type: MenuItemType.BUTTON,
diff --git a/packages/find-replace/src/controllers/find-replace.shortcut.ts b/packages/find-replace/src/controllers/find-replace.shortcut.ts
new file mode 100644
index 0000000000..1a03730e50
--- /dev/null
+++ b/packages/find-replace/src/controllers/find-replace.shortcut.ts
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { type IShortcutItem, KeyCode, MetaKeys } from '@univerjs/ui';
+
+import {
+ CloseFindReplaceDialogOperation,
+ GoToNextMatchOperation,
+ GoToPreviousMatchOperation,
+ OpenFindDialogOperation,
+ OpenReplaceDialogOperation,
+} from '../commands/operations/find-replace.operation';
+import { FIND_REPLACE_ACTIVATED } from '../services/context-keys';
+
+export const OpenFindDialogShortcutItem: IShortcutItem = {
+ id: OpenFindDialogOperation.id,
+ description: 'shortcut.find-replace.open-find-dialog',
+ binding: KeyCode.F | MetaKeys.CTRL_COMMAND,
+ group: '4_find-replace',
+ preconditions(contextService) {
+ return !contextService.getContextValue(FIND_REPLACE_ACTIVATED);
+ },
+};
+
+export const OpenReplaceDialogShortcutItem: IShortcutItem = {
+ id: OpenReplaceDialogOperation.id,
+ description: 'shortcut.find-replace.open-replace-dialog',
+ binding: KeyCode.H | MetaKeys.CTRL_COMMAND,
+ group: '4_find-replace',
+ preconditions(contextService) {
+ return !contextService.getContextValue(FIND_REPLACE_ACTIVATED);
+ },
+};
+
+export const CloseFRDialogShortcutItem: IShortcutItem = {
+ id: CloseFindReplaceDialogOperation.id,
+ description: 'shortcut.find-replace.close-dialog',
+ binding: KeyCode.ESC,
+ group: '4_find-replace',
+ priority: 1000,
+ preconditions(contextService) {
+ return !!contextService.getContextValue(FIND_REPLACE_ACTIVATED);
+ },
+};
+
+export const GoToNextFindMatchShortcutItem: IShortcutItem = {
+ id: GoToNextMatchOperation.id,
+ description: 'shortcut.find-replace.go-to-next-find-match',
+ binding: KeyCode.ENTER,
+ group: '4_find-replace',
+ priority: 1000,
+ preconditions(contextService) {
+ return !!contextService.getContextValue(FIND_REPLACE_ACTIVATED);
+ },
+};
+
+export const GoToPreviousFindMatchShortcutItem: IShortcutItem = {
+ id: GoToPreviousMatchOperation.id,
+ description: 'shortcut.find-replace.go-to-previous-find-match',
+ binding: KeyCode.ENTER | MetaKeys.SHIFT,
+ group: '4_find-replace',
+ priority: 1000,
+ preconditions(contextService) {
+ return !!contextService.getContextValue(FIND_REPLACE_ACTIVATED);
+ },
+};
diff --git a/packages/find-replace/src/index.ts b/packages/find-replace/src/index.ts
index e16857f05b..4bc7cdb542 100644
--- a/packages/find-replace/src/index.ts
+++ b/packages/find-replace/src/index.ts
@@ -15,3 +15,5 @@
*/
export { UniverFindReplacePlugin } from './plugin';
+export type { IFindComplete, IFindMatch, IFindQuery, IFindReplaceProvider } from './services/find-replace.service';
+export { FindModel, IFindReplaceService } from './services/find-replace.service';
diff --git a/packages/sheets-find/src/i-data/i-find.ts b/packages/find-replace/src/locale/en-US.ts
similarity index 54%
rename from packages/sheets-find/src/i-data/i-find.ts
rename to packages/find-replace/src/locale/en-US.ts
index e97515f65c..3ba3342d10 100644
--- a/packages/sheets-find/src/i-data/i-find.ts
+++ b/packages/find-replace/src/locale/en-US.ts
@@ -14,6 +14,21 @@
* limitations under the License.
*/
-import type { FormatType } from '@univerjs/core';
+const locale = {
+ univer: {
+ 'find-replace': {
+ dialog: {
+ title: 'Find',
+ find: 'Find',
+ replace: 'Replace',
+ 'replace-all': 'Replace All',
+ 'find-range': 'Find Range',
+ 'find-placeholder': 'Find in this Sheet',
+ 'advanced-finding': 'Advanced Searching & Replace',
+ 'replace-placeholder': 'Input Replace String',
+ },
+ },
+ },
+};
-export type FindType = FormatType | 'null' | 'text' | 'condition' | 'intervalRow' | 'intervalColumn';
+export default locale;
diff --git a/packages/sheets-find/src/locale/index.ts b/packages/find-replace/src/locale/index.ts
similarity index 100%
rename from packages/sheets-find/src/locale/index.ts
rename to packages/find-replace/src/locale/index.ts
diff --git a/packages/sheets-find/src/main.tsx b/packages/find-replace/src/locale/zh-CN.ts
similarity index 51%
rename from packages/sheets-find/src/main.tsx
rename to packages/find-replace/src/locale/zh-CN.ts
index 773ce3eaa1..88e0e3df56 100644
--- a/packages/sheets-find/src/main.tsx
+++ b/packages/find-replace/src/locale/zh-CN.ts
@@ -14,24 +14,23 @@
* limitations under the License.
*/
-// outerRight: true,
+import { type default as enUS } from './en-US';
-// innerLeft: false,
+const locale: typeof enUS = {
+ univer: {
+ 'find-replace': {
+ dialog: {
+ title: '查找',
+ find: '查找',
+ replace: '替换',
+ 'replace-all': '替换全部',
+ 'find-range': '查找范围',
+ 'find-placeholder': '输入查找内容',
+ 'advanced-finding': '替换 / 高级查找',
+ 'replace-placeholder': '输入替换内容',
+ },
+ },
+ },
+};
-// innerRight: false,
-
-// toolbar: true,
-
-// toolbarConfig: {
-// undoRedo: true,
-// font: true,
-// },
-// contentSplit: true,
-// },
-// };
-// const uiDefaultConfigLeft = {
-// container: 'universheet-demo-left',
-// };
-// const uiDefaultConfigRight = {
-// container: 'universheet-demo-right',
-// };
+export default locale;
diff --git a/packages/find-replace/src/plugin.ts b/packages/find-replace/src/plugin.ts
index 5fbcfcd5b6..5a7329a86c 100644
--- a/packages/find-replace/src/plugin.ts
+++ b/packages/find-replace/src/plugin.ts
@@ -14,21 +14,32 @@
* limitations under the License.
*/
-import { Plugin } from '@univerjs/core';
-import type { Dependency, Injector } from '@wendellhu/redi';
+import { LocaleService, Plugin } from '@univerjs/core';
+import { type Dependency, Inject, type Injector } from '@wendellhu/redi';
import { FindReplaceController } from './controllers/find-replace.controller';
+import { zhCN } from './locale';
+import { FindReplaceService, IFindReplaceService } from './services/find-replace.service';
const PLUGIN_NAME = 'FIND_REPLACE';
export class UniverFindReplacePlugin extends Plugin {
- constructor(protected readonly _injector: Injector) {
+ constructor(
+ protected readonly _injector: Injector,
+ @Inject(LocaleService) private readonly _localeService: LocaleService
+ ) {
super(PLUGIN_NAME);
+
+ this._localeService.load({
+ zhCN,
+ });
}
override onStarting(injector: Injector): void {
- ([[FindReplaceController]] as Dependency[]).forEach((d) => {
- injector.add(d);
- });
+ ([[FindReplaceController], [IFindReplaceService, { useClass: FindReplaceService }]] as Dependency[]).forEach(
+ (d) => {
+ injector.add(d);
+ }
+ );
}
}
diff --git a/packages/sheets-find/src/const/plugin-name.ts b/packages/find-replace/src/services/context-keys.ts
similarity index 84%
rename from packages/sheets-find/src/const/plugin-name.ts
rename to packages/find-replace/src/services/context-keys.ts
index eb3b272e83..e85fdc318a 100644
--- a/packages/sheets-find/src/const/plugin-name.ts
+++ b/packages/find-replace/src/services/context-keys.ts
@@ -14,4 +14,7 @@
* limitations under the License.
*/
-export const FIND_PLUGIN_NAME = 'find';
+/**
+ * If find replace feature is activated.
+ */
+export const FIND_REPLACE_ACTIVATED = 'FIND_REPLACE_ACTIVATED';
diff --git a/packages/find-replace/src/services/find-replace.service.ts b/packages/find-replace/src/services/find-replace.service.ts
index 3c99b2a076..f01357a830 100644
--- a/packages/find-replace/src/services/find-replace.service.ts
+++ b/packages/find-replace/src/services/find-replace.service.ts
@@ -14,13 +14,416 @@
* limitations under the License.
*/
-import { createIdentifier } from '@wendellhu/redi';
+import type { Nullable } from '@univerjs/core';
+import { Disposable, ILogService, IUniverInstanceService, toDisposable } from '@univerjs/core';
+import type { IDisposable } from '@wendellhu/redi';
+import { createIdentifier, Inject, Injector } from '@wendellhu/redi';
+import type { Observable } from 'rxjs';
+import { BehaviorSubject, Subject } from 'rxjs';
-export const IFindReplaceService = createIdentifier<IFindReplaceService>('univer.find-replace-service');
+export type FindProgressFn = () => void;
+
+export interface IFindComplete<T extends IFindMatch = IFindMatch> {
+ results: T[];
+}
+
+export interface IFindMatch<T = unknown> {
+ provider: string;
+ unitId: string;
+ range: T;
+}
+
+export abstract class FindModel extends Disposable {
+ abstract readonly unitId: string;
+
+ abstract getMatches(): IFindMatch[];
+
+ abstract moveToNextMatch(loop?: boolean): IFindMatch | null;
+ abstract moveToPreviousMatch(loop?: boolean): IFindMatch | null;
+}
/**
- *
+ * A provider should be implemented by a business to provide the find results.
+ */
+export interface IFindReplaceProvider {
+ find(query: IFindQuery): Promise<FindModel[]>;
+ cancel(): void;
+}
+
+/**
+ * This service works as a core of the find & replace feature.
+ */
+export interface IFindReplaceService {
+ readonly stateUpdates$: Observable<Partial<IFindReplaceState>>;
+ readonly state$: Observable<IFindReplaceState>;
+
+ /**
+ * Register a find replace provider to the service. The provider is the actual bearer to
+ * perform the find in different kinds of documents or different environments.
+ *
+ * @param provider the find replace provider
+ */
+ registerFindReplaceProvider(provider: IFindReplaceProvider): IDisposable;
+
+ /**
+ * Start a find & replace session.
+ *
+ * @returns if the find & replace session is created and user could start find replace
+ */
+ start(): boolean;
+
+ end(): boolean;
+
+ revealReplace(): void;
+ changeFindString(value: string): void;
+ moveToNextMatch(): void;
+ moveToPreviousMatch(): void;
+ replace(): boolean;
+ replaceAll(): boolean;
+
+ // /**
+ // * Call this method to start find.
+ // *
+ // * @param query The query object.
+ // * @param onProgress The callback function to report the progress.
+ // */
+ // find(query: IFindQuery, onProgress?: FindProgressFn): void;
+}
+export const IFindReplaceService = createIdentifier<IFindReplaceService>('univer.find-replace.service');
+
+/**
+ * The find query object with finding options.
+ */
+export interface IFindQuery {
+ text: string;
+
+ isRegex?: boolean;
+ ignoreCase?: boolean;
+
+ /** Other possible options set by business. */
+ [key: string]: boolean | string | number | undefined;
+}
+
+/**
+ * This class stores find replace results and provides methods to perform replace or something.
*/
-export interface IFindReplaceService {}
+export class FindReplaceModel extends Disposable {
+ private _matchPositionFindModel?: Nullable<FindModel> = null;
+ private _findModels: FindModel[] = [];
+ private _matches: IFindMatch[] = [];
+ private _positionModel: FindModel | null = null;
+
+ constructor(
+ private readonly _state: FindReplaceState,
+ private readonly _providers: Set<IFindReplaceProvider>,
+ @ILogService private readonly _logService: ILogService,
+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService
+ ) {
+ super();
+
+ // Should restart finding when the following conditions changed
+ this._state.stateUpdates$.subscribe((newState) => {
+ if (typeof newState.findString !== 'undefined') {
+ if (newState.findString) {
+ this.find();
+ } else {
+ this._cancelFinding();
+ }
+ }
+ });
+ }
+
+ async find(): Promise<IFindComplete> {
+ this._cancelFinding();
+
+ const providers = Array.from(this._providers);
+ const findModels = (this._findModels = (
+ await Promise.all(providers.map((provider) => provider.find({ text: this._state.findString })))
+ ).flat());
+
+ const matches = findModels.map((c) => c.getMatches()).flat();
+ this._matches = matches;
+
+ if (!matches.length) {
+ return {
+ results: [],
+ };
+ }
+
+ const index = this._moveToInitialMatch(findModels, matches);
+ this._state.changeState({
+ matchesCount: matches.length,
+ matchesPosition: index + 1, // the matches position start from 1
+ });
+
+ return {
+ results: matches,
+ };
+ }
+
+ moveToNextMatch(): void {
+ if (!this._positionModel) {
+ return;
+ }
+
+ const loopInCurrentUnit = this._findModels.length === 1;
+ const nextMatch = this._positionModel.moveToNextMatch(loopInCurrentUnit);
+ if (nextMatch) {
+ const index = this._matches.findIndex((value) => value === nextMatch);
+ this._state.changeState({
+ matchesPosition: index + 1,
+ });
+ } else {
+ // search in the next find model
+ const indexOfPositionModel = this._findModels.findIndex((m) => m === this._positionModel);
+ const nextPositionModel = this._findModels[(indexOfPositionModel + 1) % this._findModels.length]; // TODO: always loop or not
+ const nextMatch = nextPositionModel.moveToNextMatch();
+ const index = this._matches.findIndex((value) => value === nextMatch);
+ this._positionModel = nextPositionModel;
+ this._state.changeState({
+ matchesPosition: index + 1,
+ });
+ }
+ }
+
+ moveToPreviousMatch(): void {
+ if (!this._positionModel) {
+ return;
+ }
+
+ const loopInCurrentUnit = this._findModels.length === 1;
+ const nextMatch = this._positionModel.moveToPreviousMatch(loopInCurrentUnit);
+ if (nextMatch) {
+ const index = this._matches.findIndex((value) => value === nextMatch);
+ this._state.changeState({
+ matchesPosition: index + 1,
+ });
+ } else {
+ const indexOfPositionModel = this._findModels.findIndex((m) => m === this._positionModel);
+ const nextPositionModel =
+ this._findModels[(indexOfPositionModel - 1 + this._findModels.length) % this._findModels.length];
+ const nextMatch = nextPositionModel.moveToPreviousMatch();
+ const index = this._matches.findIndex((value) => value === nextMatch);
+ this._positionModel = nextPositionModel;
+ this._state.changeState({
+ matchesPosition: index + 1,
+ });
+ }
+ }
+
+ // TODO@wzhudev: some cold could definitely be reused. Reuse them.
+
+ private _moveToInitialMatch(findModels: FindModel[], results: IFindMatch[]): number {
+ const focusedUnitId = this._univerInstanceService.getFocusedUniverInstance()?.getUnitId();
+ if (!focusedUnitId) {
+ return -1;
+ }
+
+ const findModelOnFocusUnit = findModels.find((model) => model.unitId === focusedUnitId);
+ if (findModelOnFocusUnit) {
+ this._positionModel = findModelOnFocusUnit;
+ const result = findModelOnFocusUnit.moveToNextMatch();
+ const index = results.findIndex((value) => value === result);
+ return index;
+ }
+
+ // otherwise we just simply match the first result
+ this._positionModel = findModels[0];
+ const nextMatch = this._positionModel.moveToNextMatch();
+ const matchPosition = this._matches.findIndex((m) => m === nextMatch);
+ return matchPosition;
+ }
+
+ private _cancelFinding(): void {
+ this._providers.forEach((provider) => provider.cancel());
+ this._state.changeState({
+ matchesCount: 0,
+ matchesPosition: 0,
+ });
+ }
+}
+
+export interface IFindReplaceState {
+ revealed: boolean;
+
+ /** The string user inputs in the input box. */
+ findString: string;
+ replaceString?: string;
+
+ /** Indicates if is in replacing mode. */
+ replaceRevealed: boolean;
+
+ /** The currently focused match's index (1-based). */
+ matchesPosition: number;
+ matchesCount: number;
+}
+
+function createInitFindReplaceState(): IFindReplaceState {
+ return {
+ revealed: true,
+ findString: '',
+ replaceRevealed: false,
+ matchesPosition: 0,
+ matchesCount: 0,
+ };
+}
+
+/**
+ * This class stores find replace options state. These state are stored
+ * here instead of the React component so we can change state from
+ * operations.
+ */
+export class FindReplaceState {
+ private readonly _stateUpdates$ = new Subject<Partial<IFindReplaceState>>();
+ readonly stateUpdates$: Observable<Partial<IFindReplaceState>> = this._stateUpdates$.asObservable();
+
+ private readonly _state$ = new BehaviorSubject<IFindReplaceState>(createInitFindReplaceState());
+ readonly state$ = this._state$.asObservable();
+ get state(): IFindReplaceState {
+ return this._state$.getValue();
+ }
+
+ // TODO@wzhudev: put all state properties here
+ private _findString: string = '';
+ private _revealed = false;
+ private _replaceRevealed = false;
+ private _matchesPosition = 0;
+ private _matchesCount = 0;
+
+ get findString(): string {
+ return this._findString;
+ }
+
+ changeState(changes: Partial<IFindReplaceState>): void {
+ let changed = false;
+ const changedState: Partial<IFindReplaceState> = {};
+
+ if (typeof changes.findString !== 'undefined' && changes.findString !== this._findString) {
+ this._findString = changes.findString;
+ changedState.findString = this._findString;
+ changed = true;
+ }
+
+ if (typeof changes.revealed !== 'undefined' && changes.revealed !== this._revealed) {
+ this._revealed = changes.revealed;
+ changedState.revealed = changes.revealed;
+ changed = true;
+ }
+
+ if (typeof changes.replaceRevealed !== 'undefined' && changes.replaceRevealed !== this._replaceRevealed) {
+ this._replaceRevealed = changes.replaceRevealed;
+ changedState.replaceRevealed = changes.replaceRevealed;
+ changed = true;
+ }
+
+ if (typeof changes.matchesCount !== 'undefined' && changes.matchesCount !== this._matchesCount) {
+ this._matchesCount = changes.matchesCount;
+ changedState.matchesCount = changes.matchesCount;
+ changed = true;
+ }
+
+ if (typeof changes.matchesPosition !== 'undefined' && changes.matchesPosition !== this._matchesPosition) {
+ this._matchesPosition = changes.matchesPosition;
+ changedState.matchesPosition = changes.matchesPosition;
+ changed = true;
+ // TODO@wzhudev: maybe we should recalc matches position according to the current selections position
+ }
+
+ if (changed) {
+ this._stateUpdates$.next(changedState);
+ this._state$.next({
+ findString: this._findString,
+ revealed: this._revealed,
+ replaceRevealed: this._replaceRevealed,
+ matchesCount: this._matchesCount,
+ matchesPosition: this._matchesPosition,
+ });
+ }
+ }
+}
+
+// Since Univer' Find&Replace features works in a plugin manner,
+// each `IFind&Replace` provider should have their own implementations
+// of 'state' and 'model'.
+
+export class FindReplaceService extends Disposable implements IFindReplaceService {
+ private readonly _providers = new Set<IFindReplaceProvider>();
+ private readonly _state = new FindReplaceState();
+ private _model: Nullable<FindReplaceModel>;
+
+ get stateUpdates$() {
+ return this._state.stateUpdates$;
+ }
+
+ get state$() {
+ return this._state.state$;
+ }
+
+ constructor(
+ @Inject(Injector) private readonly _injector: Injector,
+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
+ @ILogService private readonly _logService: ILogService
+ ) {
+ super();
+ }
+
+ changeFindString(value: string): void {
+ this._state.changeState({
+ findString: value,
+ });
+ }
+
+ moveToNextMatch(): void {
+ if (this._model) {
+ this._model?.moveToNextMatch();
+ }
+ }
+
+ moveToPreviousMatch(): void {
+ if (this._model) {
+ this._model?.moveToPreviousMatch();
+ }
+ }
+
+ replace(): boolean {
+ return true;
+ }
+
+ replaceAll(): boolean {
+ return true;
+ }
+
+ revealReplace(): void {
+ this._state.changeState({ replaceRevealed: true });
+ }
+
+ disposeModel(): void {
+ this._model?.dispose();
+ this._model = null;
+ }
+
+ start(): boolean {
+ if (this._providers.size === 0) {
+ return false;
+ }
+
+ this._model = this._injector.createInstance(FindReplaceModel, this._state, this._providers);
+
+ const newState = createInitFindReplaceState();
+ newState.revealed = true;
+
+ this._state.changeState(newState);
+
+ return true;
+ }
+
+ end(): boolean {
+ this._state.changeState({ revealed: false, replaceRevealed: false });
+ return true;
+ }
-export interface IFindReplaceHookd {}
+ registerFindReplaceProvider(provider: IFindReplaceProvider): IDisposable {
+ this._providers.add(provider);
+ return toDisposable(() => this._providers.delete(provider));
+ }
+}
diff --git a/packages/sheets-find/src/conflict/conflict-find.ts b/packages/find-replace/src/services/mocks/mock-find-replace.service.ts
similarity index 80%
rename from packages/sheets-find/src/conflict/conflict-find.ts
rename to packages/find-replace/src/services/mocks/mock-find-replace.service.ts
index ccd66d0e3f..e32faa7f16 100644
--- a/packages/sheets-find/src/conflict/conflict-find.ts
+++ b/packages/find-replace/src/services/mocks/mock-find-replace.service.ts
@@ -14,4 +14,6 @@
* limitations under the License.
*/
-export class ConflictFind {}
+import type { FindReplaceService } from '../common/find-replace.service';
+
+export class MockFindReplaceService implements FindReplaceService {}
diff --git a/packages/find-replace/src/views/dialog/Dialog.module.less b/packages/find-replace/src/views/dialog/Dialog.module.less
new file mode 100644
index 0000000000..687b75a697
--- /dev/null
+++ b/packages/find-replace/src/views/dialog/Dialog.module.less
@@ -0,0 +1,9 @@
+.find-replace {
+ // &-dialog-container {
+ // }
+
+ &-expand-container {
+ margin-top: 16px;
+ text-align: center;
+ }
+}
\ No newline at end of file
diff --git a/packages/find-replace/src/views/dialog/Dialog.stories.tsx b/packages/find-replace/src/views/dialog/Dialog.stories.tsx
new file mode 100644
index 0000000000..baad0bc2d9
--- /dev/null
+++ b/packages/find-replace/src/views/dialog/Dialog.stories.tsx
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Meta } from '@storybook/react';
+import { LocaleService } from '@univerjs/core';
+import { Injector } from '@wendellhu/redi';
+import { RediContext } from '@wendellhu/redi/react-bindings';
+import React, { useState } from 'react';
+
+import { IFindReplaceDialogService } from '../../services/find-replace-dialog.service';
+import { FindReplaceDialog } from './Dialog';
+import { StorybookFindReplaceDialogService } from './mock/mocks';
+
+const meta: Meta = {
+ title: 'Find Replace Dialog',
+ parameters: {
+ layout: 'centered',
+ },
+ tags: ['autodocs'],
+};
+
+export default meta;
+
+function FindDialogDemo() {
+ const [inject] = useState(() => {
+ const injector = new Injector();
+ // injector.add([IFindReplaceService]);
+ injector.add([LocaleService]);
+ injector.add([IFindReplaceDialogService, { useClass: StorybookFindReplaceDialogService }]);
+
+ injector.get(LocaleService).load({});
+
+ return injector;
+ });
+
+ return (
+ <RediContext.Provider value={{ injector: inject }}>
+ <FindReplaceDialog />
+ </RediContext.Provider>
+ );
+}
+
+export const FindDialog = {
+ render() {
+ return <FindDialogDemo />;
+ },
+};
+
+function ReplaceDialogDemo() {
+ const [inject] = useState(() => {
+ const injector = new Injector();
+ // injector.add([IFindReplaceService]);
+ injector.add([LocaleService]);
+ injector.add([IFindReplaceDialogService, { useClass: StorybookFindReplaceDialogService }]);
+
+ injector.get(LocaleService).load({});
+ (injector.get(IFindReplaceDialogService) as StorybookFindReplaceDialogService).toggleReplace();
+
+ return injector;
+ });
+
+ return (
+ <RediContext.Provider value={{ injector: inject }}>
+ <FindReplaceDialog />
+ </RediContext.Provider>
+ );
+}
+
+export const ReplaceDialog = {
+ render() {
+ return <ReplaceDialogDemo />;
+ },
+};
diff --git a/packages/find-replace/src/views/dialog/Dialog.tsx b/packages/find-replace/src/views/dialog/Dialog.tsx
new file mode 100644
index 0000000000..10b5b46290
--- /dev/null
+++ b/packages/find-replace/src/views/dialog/Dialog.tsx
@@ -0,0 +1,150 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { IContextService, LocaleService } from '@univerjs/core';
+import { Button, FormLayout, Input, InputWithSlot, Pager, Select, useObservable } from '@univerjs/design';
+import { LayoutService } from '@univerjs/ui';
+import type { IDisposable } from '@wendellhu/redi';
+import { useDependency } from '@wendellhu/redi/react-bindings';
+import React, { Fragment, useCallback, useEffect, useRef, useState } from 'react';
+
+import { IFindReplaceService } from '../../services/find-replace.service';
+import styles from './Dialog.module.less';
+
+const FIND_THROTTLE_TIME = 500;
+
+export function FindReplaceDialog() {
+ const findReplaceService = useDependency(IFindReplaceService);
+ const localeService = useDependency(LocaleService);
+ const contextService = useDependency(IContextService);
+ const layoutService = useDependency(LayoutService);
+
+ const [findString, setFindString] = useState<string>('');
+ const [replaceString, setReplaceString] = useState<string>('');
+
+ const dialogContainerRef = useRef<HTMLDivElement>(null);
+
+ const state = useObservable(findReplaceService.state$);
+ const { matchesCount, matchesPosition } = state;
+ const revealReplace = useCallback(() => findReplaceService.revealReplace(), [findReplaceService]);
+
+ const updateFindString = useCallback(
+ (findString: string) => findReplaceService.changeFindString(findString),
+ // FIXME@wzhudev: this throttle function has no leading and taling config hence has some problems
+ // throttle((findString: string) => findReplaceService.changeFindString(findString), FIND_THROTTLE_TIME),
+ [findReplaceService]
+ );
+
+ const onFindInputChange = useCallback(
+ (findString: string) => {
+ setFindString(findString);
+ updateFindString(findString);
+ },
+ [findReplaceService]
+ );
+
+ const onReplaceInputChange = useCallback(
+ (replaceString: string) => {
+ setReplaceString(replaceString);
+ },
+ [findReplaceService]
+ );
+
+ useEffect(() => {
+ let disposable: IDisposable | undefined;
+ if (dialogContainerRef.current) {
+ disposable = layoutService.registerContainer(dialogContainerRef.current);
+ }
+
+ return () => disposable?.dispose();
+ }, [dialogContainerRef.current]);
+
+ function renderFindDialog() {
+ return (
+ <Fragment>
+ <InputWithSlot
+ autoFocus={true}
+ placeholder={localeService.t('univer.find-replace.dialog.find-placeholder')}
+ slot={
+ <Pager
+ loop={true}
+ value={matchesPosition}
+ total={matchesCount}
+ onChange={(newIndex) => {
+ if (matchesPosition === matchesCount && newIndex === 1) {
+ findReplaceService.moveToNextMatch();
+ } else if (matchesPosition === 1 && newIndex === matchesCount) {
+ findReplaceService.moveToPreviousMatch();
+ } else if (newIndex < matchesPosition) {
+ findReplaceService.moveToPreviousMatch();
+ } else {
+ findReplaceService.moveToNextMatch();
+ }
+ }}
+ />
+ }
+ value={findString}
+ onChange={(value) => onFindInputChange(value)}
+ />
+
+ <div className={styles.findReplaceExpandContainer}>
+ <Button type={'text'} size="small" onClick={revealReplace}>
+ {localeService.t('univer.find-replace.dialog.advanced-finding')}
+ </Button>
+ </div>
+ </Fragment>
+ );
+ }
+
+ function renderReplaceDialog() {
+ /*
+ * TODO@wzhudev: this form should be configure by business (maybe with a schema?) Here we just
+ * simply hard coded them here for a quick implementation.
+ */
+
+ return (
+ <Fragment>
+ <FormLayout label={localeService.t('univer.find-replace.dialog.find')}>
+ <Input
+ placeholder={localeService.t('univer.find-replace.dialog.find-placeholder')}
+ autoFocus={true}
+ value={findString}
+ onChange={(value) => onReplaceInputChange(value)}
+ />
+ </FormLayout>
+ <FormLayout label={localeService.t('univer.find-replace.dialog.replace')}>
+ <Input
+ placeholder={localeService.t('univer.find-replace.dialog.replace-placeholder')}
+ value={replaceString}
+ onChange={(value) => onReplaceInputChange(value)}
+ />
+ </FormLayout>
+ <FormLayout label={localeService.t('univer.find-replace.dialog.find-range')}>
+ <Select value={'123'} onChange={() => {}} />
+ </FormLayout>
+ <Button type="primary">{localeService.t('univer.find-replace.dialog.find')}</Button>
+ <Button>{localeService.t('univer.find-replace.dialog.replace')}</Button>
+ <Button>{localeService.t('univer.find-replace.dialog.replace-all')}</Button>
+ </Fragment>
+ );
+ }
+
+ return (
+ <div className={styles.findReplaceDialogContainer} ref={dialogContainerRef}>
+ {!state.replaceRevealed ? renderFindDialog() : renderReplaceDialog()}
+ </div>
+ );
+}
diff --git a/packages/find-replace/src/views/dialog/mock/mocks.tsx b/packages/find-replace/src/views/dialog/mock/mocks.tsx
new file mode 100644
index 0000000000..41abe9f08f
--- /dev/null
+++ b/packages/find-replace/src/views/dialog/mock/mocks.tsx
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Observable } from 'rxjs';
+import { BehaviorSubject } from 'rxjs';
+
+import { FindReplaceState, type IFindReplaceDialogService } from '../../../services/find-replace-dialog.service';
+
+export class StorybookFindReplaceDialogService implements IFindReplaceDialogService {
+ private readonly _state = new BehaviorSubject<FindReplaceState>(FindReplaceState.FIND);
+ readonly state$: Observable<FindReplaceState> = this._state.asObservable();
+
+ get state(): FindReplaceState {
+ return this._state.getValue();
+ }
+
+ toggleFind(): void {
+ this._state.next(FindReplaceState.FIND);
+ }
+
+ toggleReplace(): void {
+ this._state.next(FindReplaceState.REPLACE);
+ }
+
+ closePanel(): void {
+ this._state.next(FindReplaceState.CLOSED);
+ }
+}
diff --git a/packages/find-replace/tsconfig.json b/packages/find-replace/tsconfig.json
index ccde33f16e..fce974769c 100644
--- a/packages/find-replace/tsconfig.json
+++ b/packages/find-replace/tsconfig.json
@@ -4,7 +4,7 @@
"rootDir": ".",
"outDir": "lib",
"esModuleInterop": true,
- "strictPropertyInitialization": false
+ "strictPropertyInitialization": false,
},
"include": ["src/**/*"]
}
diff --git a/packages/sheets-find/README.md b/packages/sheets-find-replace/README.md
similarity index 100%
rename from packages/sheets-find/README.md
rename to packages/sheets-find-replace/README.md
diff --git a/packages/sheets-find/package.json b/packages/sheets-find-replace/package.json
similarity index 85%
rename from packages/sheets-find/package.json
rename to packages/sheets-find-replace/package.json
index 10cc6d0812..527f2d640c 100644
--- a/packages/sheets-find/package.json
+++ b/packages/sheets-find-replace/package.json
@@ -1,7 +1,7 @@
{
- "name": "@univerjs/sheets-find",
+ "name": "@univerjs/sheets-find-replace",
"version": "0.1.0-beta.2",
- "description": "UniverSheet normal plugin find",
+ "description": "UniverSheet find replace plugin",
"keywords": [],
"author": "DreamNum <[email protected]>",
"license": "Apache-2.0",
@@ -40,11 +40,17 @@
"**/*.css"
],
"private": true,
- "scripts": {},
+ "scripts": {
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "coverage": "vitest run --coverage",
+ "build": "tsc && vite build"
+ },
"dependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
+ "@univerjs/find-replace": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
@@ -66,6 +72,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
+ "@univerjs/find-replace": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
diff --git a/packages/sheets-find/src/action/action-find.ts b/packages/sheets-find-replace/src/action/action-find.ts
similarity index 100%
rename from packages/sheets-find/src/action/action-find.ts
rename to packages/sheets-find-replace/src/action/action-find.ts
diff --git a/packages/sheets-find/src/action/i-action-set.ts b/packages/sheets-find-replace/src/action/i-action-set.ts
similarity index 100%
rename from packages/sheets-find/src/action/i-action-set.ts
rename to packages/sheets-find-replace/src/action/i-action-set.ts
diff --git a/packages/sheets-find/src/action/i-action.ts b/packages/sheets-find-replace/src/action/i-action.ts
similarity index 100%
rename from packages/sheets-find/src/action/i-action.ts
rename to packages/sheets-find-replace/src/action/i-action.ts
diff --git a/packages/sheets-find/src/action/index.ts b/packages/sheets-find-replace/src/action/index.ts
similarity index 100%
rename from packages/sheets-find/src/action/index.ts
rename to packages/sheets-find-replace/src/action/index.ts
diff --git a/packages/sheets-find/src/base/cache.ts b/packages/sheets-find-replace/src/base/cache.ts
similarity index 100%
rename from packages/sheets-find/src/base/cache.ts
rename to packages/sheets-find-replace/src/base/cache.ts
diff --git a/packages/sheets-find/src/base/index.ts b/packages/sheets-find-replace/src/base/index.ts
similarity index 100%
rename from packages/sheets-find/src/base/index.ts
rename to packages/sheets-find-replace/src/base/index.ts
diff --git a/packages/sheets-find/src/base/state.ts b/packages/sheets-find-replace/src/base/state.ts
similarity index 100%
rename from packages/sheets-find/src/base/state.ts
rename to packages/sheets-find-replace/src/base/state.ts
diff --git a/packages/sheets-find-replace/src/controllers/__tests__/utils.spec.ts b/packages/sheets-find-replace/src/controllers/__tests__/utils.spec.ts
new file mode 100644
index 0000000000..edfebcf212
--- /dev/null
+++ b/packages/sheets-find-replace/src/controllers/__tests__/utils.spec.ts
@@ -0,0 +1,198 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import {
+ isBeforePositionWithColumnPriority,
+ isBeforePositionWithRowPriority,
+ isBehindPositionWithColumnPriority,
+ isBehindPositionWithRowPriority,
+ isSamePosition,
+} from '../utils';
+
+describe('Test sheet find replace utils', () => {
+ it('Should "isSamePosition" work as expected', () => {
+ expect(
+ isSamePosition(
+ { startRow: 12, endColumn: 24, startColumn: 22, endRow: 25 },
+ { startRow: 12, endRow: 23, startColumn: 22, endColumn: 28 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isSamePosition(
+ { startRow: 13, endColumn: 24, startColumn: 22, endRow: 25 },
+ { startRow: 12, endRow: 23, startColumn: 22, endColumn: 28 }
+ )
+ ).toBeFalsy();
+
+ expect(
+ isSamePosition(
+ { startRow: 12, endColumn: 24, startColumn: 24, endRow: 25 },
+ { startRow: 12, endRow: 23, startColumn: 22, endColumn: 28 }
+ )
+ ).toBeFalsy();
+ });
+
+ it('Should "isBehindPositionWithRowPriority" work as expected', () => {
+ expect(
+ isBehindPositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBehindPositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 2, endColumn: 2 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBehindPositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 2, endRow: 2, startColumn: 0, endColumn: 0 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBehindPositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 0, endRow: 0, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeFalsy();
+
+ expect(
+ isBehindPositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 0, endColumn: 0 }
+ )
+ ).toBeFalsy();
+ });
+
+ it('Should "isBehindPositionWithColumnPriority" work as expected', () => {
+ expect(
+ isBehindPositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBehindPositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 2, endColumn: 2 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBehindPositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 2, endRow: 2, startColumn: 0, endColumn: 0 }
+ )
+ ).toBeFalsy();
+
+ expect(
+ isBehindPositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 0, endRow: 0, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeFalsy();
+
+ expect(
+ isBehindPositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 2, endRow: 2, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeTruthy();
+ });
+
+ it('Should "isBeforePositionWithRowPriority" work as expected', () => {
+ expect(
+ isBeforePositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBeforePositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 2, endColumn: 2 }
+ )
+ ).toBeFalsy();
+
+ expect(
+ isBeforePositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 2, endRow: 2, startColumn: 0, endColumn: 0 }
+ )
+ ).toBeFalsy();
+
+ expect(
+ isBeforePositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 0, endRow: 0, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBeforePositionWithRowPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 0, endColumn: 0 }
+ )
+ ).toBeTruthy();
+ });
+
+ it('Should "isBeforePositionWithColumnPriority" work as expected', () => {
+ expect(
+ isBeforePositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBeforePositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 1, endRow: 1, startColumn: 2, endColumn: 2 }
+ )
+ ).toBeFalsy();
+
+ expect(
+ isBeforePositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 2, endRow: 2, startColumn: 0, endColumn: 0 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBeforePositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 0, endRow: 0, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeTruthy();
+
+ expect(
+ isBeforePositionWithColumnPriority(
+ { startRow: 1, endRow: 1, startColumn: 1, endColumn: 1 },
+ { startRow: 2, endRow: 2, startColumn: 1, endColumn: 1 }
+ )
+ ).toBeFalsy();
+ });
+});
diff --git a/packages/sheets-find-replace/src/controllers/find-replace.controller.ts b/packages/sheets-find-replace/src/controllers/find-replace.controller.ts
new file mode 100644
index 0000000000..7d44639200
--- /dev/null
+++ b/packages/sheets-find-replace/src/controllers/find-replace.controller.ts
@@ -0,0 +1,391 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { ICellData, IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';
+import { Disposable, ICommandService, IUniverInstanceService, LifecycleStages, OnLifecycle } from '@univerjs/core';
+import { IRenderManagerService } from '@univerjs/engine-render';
+import type { IFindComplete, IFindMatch, IFindQuery, IFindReplaceProvider } from '@univerjs/find-replace';
+import { FindModel, IFindReplaceService } from '@univerjs/find-replace';
+import { SelectionManagerService, SheetInterceptorService } from '@univerjs/sheets';
+import { getCoordByCell, getSheetObject, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
+import { type IDisposable, Inject, Injector } from '@wendellhu/redi';
+
+import type { ISheetFindReplaceHighlightShapeProps } from '../views/shapes/find-replace-highlight.shape';
+import { SheetFindReplaceHighlightShape } from '../views/shapes/find-replace-highlight.shape';
+import { isBeforePositionWithRowPriority, isBehindPositionWithRowPriority, isSamePosition } from './utils';
+
+@OnLifecycle(LifecycleStages.Steady, SheetsFindReplaceController)
+export class SheetsFindReplaceController extends Disposable implements IDisposable {
+ private _provider: SheetsFindReplaceProvider;
+
+ constructor(
+ @Inject(Injector) private readonly _injector: Injector,
+ @IFindReplaceService private readonly _findReplaceService: IFindReplaceService
+ ) {
+ super();
+
+ this._init();
+ }
+
+ override dispose(): void {
+ super.dispose();
+
+ this._provider.dispose();
+ }
+
+ private _init(): void {
+ const provider = this._injector.createInstance(SheetsFindReplaceProvider);
+ this._provider = provider;
+ this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(provider));
+ }
+}
+
+const SHEETS_FIND_REPLACE_PROVIDER_NAME = 'sheets-find-replace-provider';
+const FIND_REPLACE_Z_INDEX = 10000;
+
+export interface ISheetCellMatch extends IFindMatch {
+ provider: typeof SHEETS_FIND_REPLACE_PROVIDER_NAME;
+ range: {
+ unitId: string;
+ subUnitId: string;
+ range: IRange;
+ };
+}
+
+/**
+ * This class executes finding in a workbook and subscribe to the content change event so when its results changes
+ * FindReplaceService would know that and update searching results. Also this class in responsible for
+ * highlighting matched cells.
+ */
+export class SheetFindModel extends FindModel {
+ private _matchesCount = 0;
+ private _matchesPosition = 0; // position starts from 1
+ private _matches: ISheetCellMatch[] = [];
+
+ private _highlightShapes: Nullable<Set<SheetFindReplaceHighlightShape>>;
+
+ get unitId(): string {
+ return this._workbook.getUnitId();
+ }
+
+ get matchesCount(): number {
+ return this._matchesCount;
+ }
+
+ get matchesPosition(): number {
+ return this._matchesPosition;
+ }
+
+ get currentMatch(): Nullable<ISheetCellMatch> {
+ return this._matchesPosition > 0 ? this._matches[this._matchesPosition - 1] : null;
+ }
+
+ constructor(
+ private readonly _workbook: Workbook,
+ @ICommandService private readonly _commandService: ICommandService,
+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
+ @IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
+ @Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService,
+ @Inject(SelectionManagerService) private readonly _selectionManagerService: SelectionManagerService,
+ @Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService
+ ) {
+ super();
+ }
+
+ override dispose(): void {
+ this._highlightShapes?.forEach((shape) => shape.dispose());
+ }
+
+ getMatches(): IFindMatch[] {
+ return this._matches;
+ }
+
+ findInActiveWorksheet(query: IFindQuery): IFindComplete {
+ const currentWorksheet = this._workbook.getActiveSheet();
+ const unitId = this._workbook.getUnitId();
+
+ const complete = this._findTheActiveWorksheet(currentWorksheet, query, unitId);
+ this._matches = complete.results;
+ this._matchesCount = complete.results.length;
+
+ return complete;
+ }
+
+ private _getStartPosition(): IRange | null {
+ if (!this._isSelfFocused()) {
+ return null;
+ }
+
+ if (this.currentMatch) {
+ return this.currentMatch.range.range;
+ }
+
+ const selections = this._selectionManagerService.getSelections();
+ return selections?.length ? selections[0].range : null;
+ }
+
+ override moveToNextMatch(loop = false): ISheetCellMatch | null {
+ const startPosition = this._getStartPosition();
+ const matchToMove: [ISheetCellMatch, number] | null = startPosition
+ ? this._findNextMatch(startPosition, loop)
+ : [this._matches[0], 0];
+
+ if (matchToMove) {
+ this._matchesPosition = matchToMove[1] + 1;
+ return matchToMove[0];
+ }
+
+ this._matchesPosition = 0;
+ return null;
+ }
+
+ override moveToPreviousMatch(loop = false): ISheetCellMatch | null {
+ const startPosition = this._getStartPosition();
+ const matchToMove: [ISheetCellMatch, number] | null = startPosition
+ ? this._findPreviousMatch(startPosition, loop)
+ : [this._matches[0], 0];
+
+ if (matchToMove) {
+ this._matchesPosition = matchToMove[1] + 1;
+ return matchToMove[0];
+ }
+
+ this._matchesPosition = 0;
+ return null;
+ }
+
+ private _findPreviousMatch(range: IRange, loop = false): [ISheetCellMatch, number] | null {
+ let index = this._matches.findLastIndex((match) => {
+ const matchRange = match.range.range;
+ const isBefore = isBeforePositionWithRowPriority(range, matchRange);
+ if (!isBefore) {
+ return false;
+ }
+
+ if (!this.currentMatch) {
+ return true;
+ }
+
+ return !isSamePosition(range, matchRange);
+ });
+
+ if (index === -1 && !this.currentMatch) {
+ index = 0;
+ }
+
+ if (index === -1 && loop) {
+ index = this._matches.length - 1;
+ }
+
+ return index > -1 ? [this._matches[index], index] : null;
+ }
+
+ private _findNextMatch(range: IRange, loop = false): [ISheetCellMatch, number] | null {
+ let index = this._matches.findIndex((match) => {
+ const matchRange = match.range.range;
+ const isBehind = isBehindPositionWithRowPriority(range, matchRange);
+ if (!isBehind) {
+ return false;
+ }
+
+ if (!this.currentMatch) {
+ return true;
+ }
+
+ return !isSamePosition(range, matchRange);
+ });
+
+ if (index === -1 && !this.currentMatch) {
+ index = this._matches.length - 1;
+ }
+
+ if (index === -1 && loop) {
+ index = 0;
+ }
+
+ return index > -1 ? [this._matches[index], index] : null;
+ }
+
+ private _findTheActiveWorksheet(
+ worksheet: Worksheet,
+ query: IFindQuery,
+ unitId: string
+ ): IFindComplete<ISheetCellMatch> {
+ if (!query.text) {
+ return {
+ results: [],
+ };
+ }
+
+ const subUnitId = worksheet.getSheetId();
+ const rowCount = worksheet.getRowCount();
+ const colCount = worksheet.getColumnCount();
+
+ const results: ISheetCellMatch[] = [];
+ worksheet.getMatrixWithMergedCells(0, 0, rowCount, colCount).forValue((row, col, value) => {
+ // We should get value from the view model.
+ // TODO: this may change because sometime we need to search the raw value.
+ const displayValue = worksheet.getCell(row, col);
+ const hit = hitCell(displayValue, query);
+ if (hit) {
+ const result: ISheetCellMatch = {
+ provider: SHEETS_FIND_REPLACE_PROVIDER_NAME,
+ unitId,
+ range: {
+ unitId,
+ subUnitId,
+ range: {
+ startRow: row,
+ startColumn: col,
+ endColumn: col + (value.rowSpan ?? 0),
+ endRow: row + (value.colSpan ?? 0),
+ },
+ },
+ };
+
+ results.push(result);
+ }
+ });
+
+ const complete = {
+ results,
+ };
+
+ this._updateFindHighlight(complete);
+ return complete;
+ }
+
+ private _updateFindHighlight(findComplete: IFindComplete): void {
+ this._highlightShapes?.forEach((shape) => shape.dispose());
+
+ const skeleton = this._sheetSkeletonManagerService.getCurrent()?.skeleton;
+ if (!skeleton) {
+ return;
+ }
+
+ const sheetObjects = this._getSheetObject();
+ if (!sheetObjects) {
+ return;
+ }
+
+ const unitId = this._workbook.getUnitId();
+ const currentRender = this._renderManagerService.getRenderById(unitId);
+ if (currentRender == null) {
+ return;
+ }
+
+ const { scene } = currentRender;
+ const results = findComplete.results as ISheetCellMatch[];
+ const highlightShapes = results.map((find, index) => {
+ const { startColumn, startRow, endColumn, endRow } = find.range.range;
+ const startPosition = getCoordByCell(startRow, startColumn, scene, skeleton);
+ const endPosition = getCoordByCell(endRow, endColumn, scene, skeleton);
+ const { startX, startY } = startPosition;
+ const { endX, endY } = endPosition;
+ const width = endX - startX;
+ const height = endY - startY;
+
+ // TODO@wzhudev: we may need an edge detection to decide to put label on the top or on the bottom of the rect.
+ const props: ISheetFindReplaceHighlightShapeProps = {
+ left: startX,
+ top: startY,
+ width,
+ height,
+ evented: false,
+ };
+
+ return new SheetFindReplaceHighlightShape(`find-highlight-${index}`, props);
+ });
+
+ // TODO@wzhudev: there is a change that re-render is not triggered
+ scene.addObjects(highlightShapes, FIND_REPLACE_Z_INDEX);
+ this._highlightShapes = new Set(highlightShapes);
+ }
+
+ private _getSheetObject() {
+ return getSheetObject(this._univerInstanceService, this._renderManagerService);
+ }
+
+ private _isSelfFocused(): boolean {
+ return this._univerInstanceService.getFocusedUniverInstance()?.getUnitId() === this._workbook.getUnitId();
+ }
+}
+
+/**
+ * This module is responsible for searching and replacing in the sheets.
+ * It also adds the search results to the search view by highlighting them.
+ */
+class SheetsFindReplaceProvider extends Disposable implements IFindReplaceProvider {
+ /**
+ * Hold all find results in this kind of univer business instances (Workbooks).
+ */
+ private readonly _findModels: SheetFindModel[] = [];
+ private readonly _findModelsByUnitId = new Map<string, SheetFindModel>();
+
+ constructor(
+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
+ @Inject(Injector) private readonly _injector: Injector
+ ) {
+ super();
+ }
+
+ async find(query: IFindQuery): Promise<SheetFindModel[]> {
+ this._cancelFinding();
+
+ const currentWorkbook = this._univerInstanceService.getCurrentUniverSheetInstance();
+ if (currentWorkbook) {
+ const sheetFind = this._injector.createInstance(SheetFindModel, currentWorkbook);
+ this._findModels.push(sheetFind);
+ this._findModelsByUnitId.set(currentWorkbook.getUnitId(), sheetFind);
+
+ sheetFind.findInActiveWorksheet(query);
+ return [sheetFind];
+ }
+
+ return [];
+ }
+
+ cancel(): void {
+ this._cancelFinding();
+ }
+
+ private _cancelFinding(): void {
+ this._findModels.forEach((model) => model.dispose());
+ this._findModelsByUnitId.clear();
+ }
+}
+
+/**
+ * This function determines if a cell's content matches what is looked for.
+ * @param value
+ * @param query
+ * @returns
+ */
+function hitCell(value: Nullable<ICellData>, query: IFindQuery): boolean {
+ if (value == null) {
+ return false;
+ }
+
+ const { v } = value;
+
+ if (typeof v === 'string') {
+ return v.toLowerCase().includes(query.text.toLowerCase());
+ }
+
+ // TODO@wzhudev: there are a lot of implementation details.
+
+ return false;
+}
diff --git a/packages/sheets-find-replace/src/controllers/utils.ts b/packages/sheets-find-replace/src/controllers/utils.ts
new file mode 100644
index 0000000000..f15ed35469
--- /dev/null
+++ b/packages/sheets-find-replace/src/controllers/utils.ts
@@ -0,0 +1,67 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { IRange } from '@univerjs/core';
+
+export function isSamePosition(range1: IRange, range2: IRange): boolean {
+ return range1.startRow === range2.startRow && range1.startColumn === range2.startColumn;
+}
+
+/**
+ * Tell if `range2` is after (or the same as) `range1` with row direction is at priority.
+ * @param range1
+ * @param range2
+ * @returns
+ */
+export function isBehindPositionWithRowPriority(range1: IRange, range2: IRange): boolean {
+ return (
+ range1.startRow < range2.startRow ||
+ (range1.startRow === range2.startRow && range1.startColumn <= range2.startColumn)
+ );
+}
+
+/**
+ * Tell if `range2` is after (or the same as) `range1` with column direction is at priority.
+ * @param range1
+ * @param range2
+ * @returns
+ */
+export function isBehindPositionWithColumnPriority(range1: IRange, range2: IRange): boolean {
+ return (
+ range1.startColumn < range2.startColumn ||
+ (range1.startColumn === range2.startColumn && range1.startRow <= range2.startRow)
+ );
+}
+
+/**
+ * Tell if `range2` is before (or the same as) `range1` with column direction is at priority.
+ * @param range1
+ * @param range2
+ * @returns
+ */
+export function isBeforePositionWithRowPriority(range1: IRange, range2: IRange): boolean {
+ return (
+ range1.startRow > range2.startRow ||
+ (range1.startRow === range2.startRow && range1.startColumn >= range2.startColumn)
+ );
+}
+
+export function isBeforePositionWithColumnPriority(range1: IRange, range2: IRange): boolean {
+ return (
+ range1.startColumn > range2.startColumn ||
+ (range1.startColumn === range2.startColumn && range1.startRow >= range2.startRow)
+ );
+}
diff --git a/packages/sheets-find/src/index.ts b/packages/sheets-find-replace/src/index.ts
similarity index 92%
rename from packages/sheets-find/src/index.ts
rename to packages/sheets-find-replace/src/index.ts
index 9ad5d2512a..3faf1bd5b9 100644
--- a/packages/sheets-find/src/index.ts
+++ b/packages/sheets-find-replace/src/index.ts
@@ -14,5 +14,5 @@
* limitations under the License.
*/
-export { UniverSheetsFindPlugin } from './find-plugin';
export { enUS, zhCN } from './locale';
+export { UniverSheetsFindPlugin } from './plugin';
diff --git a/packages/sheets-find/src/locale/en-US.ts b/packages/sheets-find-replace/src/locale/en-US.ts
similarity index 100%
rename from packages/sheets-find/src/locale/en-US.ts
rename to packages/sheets-find-replace/src/locale/en-US.ts
diff --git a/packages/sheets-find/src/conflict/index.ts b/packages/sheets-find-replace/src/locale/index.ts
similarity index 87%
rename from packages/sheets-find/src/conflict/index.ts
rename to packages/sheets-find-replace/src/locale/index.ts
index e15c6dbe48..1eff5fc204 100644
--- a/packages/sheets-find/src/conflict/index.ts
+++ b/packages/sheets-find-replace/src/locale/index.ts
@@ -14,5 +14,5 @@
* limitations under the License.
*/
-export * from './conflict-find';
-export * from './i-conflict';
+export { default as enUS } from './en-US';
+export { default as zhCN } from './zh-CN';
diff --git a/packages/sheets-find/src/locale/zh-CN.ts b/packages/sheets-find-replace/src/locale/zh-CN.ts
similarity index 100%
rename from packages/sheets-find/src/locale/zh-CN.ts
rename to packages/sheets-find-replace/src/locale/zh-CN.ts
diff --git a/packages/sheets-find-replace/src/plugin.ts b/packages/sheets-find-replace/src/plugin.ts
new file mode 100644
index 0000000000..e154f26834
--- /dev/null
+++ b/packages/sheets-find-replace/src/plugin.ts
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Plugin, PluginType } from '@univerjs/core';
+import type { Dependency } from '@wendellhu/redi';
+import { Inject, Injector } from '@wendellhu/redi';
+
+import { SheetsFindReplaceController } from './controllers/find-replace.controller';
+
+export interface IFindPluginConfig {}
+
+const NAME = 'UNIVER_SHEETS_FIND_REPLACE_PLUGIN';
+
+export class UniverSheetsFindPlugin extends Plugin {
+ static override type = PluginType.Sheet;
+
+ constructor(
+ _config: Partial<IFindPluginConfig>,
+ @Inject(Injector) protected readonly _injector: Injector
+ ) {
+ super(NAME);
+ }
+
+ override onStarting(injector: Injector): void {
+ ([[SheetsFindReplaceController]] as Dependency[]).forEach((d) => {
+ injector.add(d);
+ });
+ }
+}
diff --git a/packages/sheets-find-replace/src/views/shapes/find-replace-highlight.shape.ts b/packages/sheets-find-replace/src/views/shapes/find-replace-highlight.shape.ts
new file mode 100644
index 0000000000..662b05bcfa
--- /dev/null
+++ b/packages/sheets-find-replace/src/views/shapes/find-replace-highlight.shape.ts
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { IShapeProps, UniverRenderingContext } from '@univerjs/engine-render';
+import { Rect, Shape } from '@univerjs/engine-render';
+
+export interface ISheetFindReplaceHighlightShapeProps extends IShapeProps {
+ activated?: boolean;
+}
+
+export class SheetFindReplaceHighlightShape extends Shape<ISheetFindReplaceHighlightShapeProps> {
+ protected _activated = false;
+
+ constructor(key?: string, props?: ISheetFindReplaceHighlightShapeProps) {
+ super(key, props);
+
+ if (props) {
+ this.setShapeProps(props);
+ }
+ }
+
+ setShapeProps(props: Partial<ISheetFindReplaceHighlightShapeProps>): void {
+ this._activated = !!props.activated;
+
+ this.transformByState({
+ width: props.width!,
+ height: props.height!,
+ });
+ }
+
+ protected override _draw(ctx: CanvasRenderingContext2D): void {
+ Rect.drawWith(ctx as UniverRenderingContext, {
+ width: this.width,
+ height: this.height,
+ fill: 'rgba(89, 208, 30, 0.2)',
+ evented: false,
+ });
+ }
+}
diff --git a/packages/sheets-find/src/vite-env.d.ts b/packages/sheets-find-replace/src/vite-env.d.ts
similarity index 100%
rename from packages/sheets-find/src/vite-env.d.ts
rename to packages/sheets-find-replace/src/vite-env.d.ts
diff --git a/packages/sheets-find/tsconfig.json b/packages/sheets-find-replace/tsconfig.json
similarity index 100%
rename from packages/sheets-find/tsconfig.json
rename to packages/sheets-find-replace/tsconfig.json
diff --git a/packages/sheets-find/vite.config.ts b/packages/sheets-find-replace/vite.config.ts
similarity index 100%
rename from packages/sheets-find/vite.config.ts
rename to packages/sheets-find-replace/vite.config.ts
diff --git a/packages/sheets-find/src/commands/operations/show-modal.operation.ts b/packages/sheets-find/src/commands/operations/show-modal.operation.ts
deleted file mode 100644
index 0acb027cea..0000000000
--- a/packages/sheets-find/src/commands/operations/show-modal.operation.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { ICommand } from '@univerjs/core';
-import { CommandType } from '@univerjs/core';
-import type { IAccessor } from '@wendellhu/redi';
-
-import { FindService } from '../../services/find.service';
-
-export const ShowModalOperation: ICommand = {
- id: 'find.operation.show-modal',
- type: CommandType.OPERATION,
- handler: async (accessor: IAccessor) => {
- const findService = accessor.get(FindService);
- findService.showModal(true);
- return true;
- },
-};
-export const HideModalOperation: ICommand = {
- id: 'find.operation.hide-modal',
- type: CommandType.OPERATION,
- handler: async (accessor: IAccessor) => {
- const findService = accessor.get(FindService);
- findService.showModal(false);
- return true;
- },
-};
diff --git a/packages/sheets-find/src/conflict/i-conflict.ts b/packages/sheets-find/src/conflict/i-conflict.ts
deleted file mode 100644
index ee845479ee..0000000000
--- a/packages/sheets-find/src/conflict/i-conflict.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export class IConflict {}
diff --git a/packages/sheets-find/src/controllers/find-controller.ts b/packages/sheets-find/src/controllers/find-controller.ts
deleted file mode 100644
index 7472d435a4..0000000000
--- a/packages/sheets-find/src/controllers/find-controller.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { Disposable, ICommandService } from '@univerjs/core';
-import { ComponentManager, IMenuService } from '@univerjs/ui';
-import type { IDisposable } from '@wendellhu/redi';
-import { Inject, Injector } from '@wendellhu/redi';
-
-import { HideModalOperation, ShowModalOperation } from '../commands/operations/show-modal.operation';
-import { FindModalController } from './find-modal-controller';
-import { FindMenuItemFactory } from './menu';
-
-export class FindController extends Disposable implements IDisposable {
- constructor(
- @Inject(FindModalController) private _findModalController: FindModalController,
- @Inject(ComponentManager) private readonly _componentManager: ComponentManager,
- @Inject(Injector) private readonly _injector: Injector,
- @IMenuService private readonly _menuService: IMenuService,
- @ICommandService private readonly _commandService: ICommandService
- ) {
- super();
- // this._componentManager.register('SearchIcon', Icon.SearchIcon);
-
- this._initializeContextMenu();
-
- [ShowModalOperation, HideModalOperation].forEach((command) =>
- this.disposeWithMe(this._commandService.registerCommand(command))
- );
- }
-
- private _initializeContextMenu() {
- [FindMenuItemFactory].forEach((factory) => {
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));
- });
- }
-}
diff --git a/packages/sheets-find/src/controllers/find-modal-controller.ts b/packages/sheets-find/src/controllers/find-modal-controller.ts
deleted file mode 100644
index 78aa4557e2..0000000000
--- a/packages/sheets-find/src/controllers/find-modal-controller.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { ComponentManager } from '@univerjs/ui';
-import { Inject } from '@wendellhu/redi';
-
-import { TextFinder } from '../domain';
-import { FindModal } from '../views/ui/FindModal';
-
-export class FindModalController {
- private _findModal: FindModal | null = null;
-
- constructor(
- @Inject(TextFinder) private _textFinder: TextFinder,
- @Inject(ComponentManager) private _componentManager: ComponentManager
- ) {
- this._initialize();
- }
-
- getComponent(ref: FindModal) {
- this._findModal = ref;
- }
-
- showModal(show: boolean) {
- this._findModal?.showFindModal(show);
- }
-
- findNext(text: string) {
- const res = this._textFinder.searchText(text);
- if (!res) return { count: 0, current: 0 };
- this._textFinder.findNext();
- return this._getCountInfo();
- }
-
- findPrevious(text: string) {
- const res = this._textFinder.searchText(text);
- if (!res) return { count: 0, current: 0 };
- this._textFinder.findPrevious();
- return this._getCountInfo();
- }
-
- replaceText(text: string) {
- if (!this._textFinder) return;
- const replaceCount = this._textFinder.replaceWith(text);
- return {
- ...this._getCountInfo(),
- replaceCount,
- };
- }
-
- replaceAll(text: string) {
- if (!this._textFinder) return;
- const replaceCount = this._textFinder.replaceAllWith(text);
- return {
- ...this._getCountInfo(),
- replaceCount,
- };
- }
-
- matchCase(matchCase: boolean) {
- if (!this._textFinder) return;
- this._textFinder.matchCase(matchCase);
- }
-
- matchEntireCell(matchEntire: boolean) {
- if (!this._textFinder) return;
- this._textFinder.matchEntireCell(matchEntire);
- }
-
- private _getCountInfo() {
- const count = this._textFinder?.getCount() ?? 0;
- const current = this._textFinder?.getCurrentIndex() ?? 0;
- return {
- count,
- current: current + 1,
- };
- }
-
- private _initialize() {
- this._componentManager.register(FindModal.name, FindModal);
- }
-}
diff --git a/packages/sheets-find/src/controllers/location-content-controller.ts b/packages/sheets-find/src/controllers/location-content-controller.ts
deleted file mode 100644
index 4ffd50e0b4..0000000000
--- a/packages/sheets-find/src/controllers/location-content-controller.ts
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// export class LocationContentController {
-// private _plugin: FindPlugin;
-
-// private _locationData: any;
-
-// constructor(plugin: FindPlugin) {
-// this._plugin = plugin;
-
-// this._locationData = [
-// {
-// locale: 'find.locationConstant',
-// children: [
-// {
-// locale: 'find.date',
-// disabled: true,
-// checked: true,
-// value: '1',
-// },
-// {
-// locale: 'find.number',
-// checked: true,
-// value: '2',
-// },
-// {
-// locale: 'find.string',
-// checked: true,
-// value: '3',
-// },
-// {
-// locale: 'find.locationBool',
-// checked: true,
-// disabled: true,
-// value: '4',
-// },
-// {
-// locale: 'find.error',
-// checked: true,
-// value: '5',
-// },
-// ],
-// value: '1',
-// },
-// {
-// locale: 'find.locationFormula',
-// children: [
-// {
-// locale: 'find.date',
-// checked: true,
-// disabled: true,
-// value: '1',
-// },
-// {
-// locale: 'find.number',
-// disabled: true,
-// checked: true,
-// value: '2',
-// },
-// {
-// locale: 'find.string',
-// disabled: true,
-// checked: true,
-// value: '3',
-// },
-// {
-// locale: 'find.locationBool',
-// checked: true,
-// disabled: true,
-// value: '4',
-// },
-// {
-// locale: 'find.error',
-// checked: true,
-// disabled: true,
-// value: '5',
-// },
-// ],
-// value: '2',
-// },
-// {
-// locale: 'find.locationNull',
-// value: '3',
-// },
-// {
-// locale: 'find.locationCondition',
-// value: '4',
-// },
-// {
-// locale: 'find.locationRowSpan',
-// value: '5',
-// },
-// {
-// locale: 'find.locationColumnSpan',
-// value: '6',
-// },
-// ];
-// }
-// }
diff --git a/packages/sheets-find/src/controllers/menu.ts b/packages/sheets-find/src/controllers/menu.ts
deleted file mode 100644
index bf53a36829..0000000000
--- a/packages/sheets-find/src/controllers/menu.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { IMenuButtonItem } from '@univerjs/ui';
-import { MenuItemType, MenuPosition } from '@univerjs/ui';
-import type { IAccessor } from '@wendellhu/redi';
-
-import { ShowModalOperation } from '../commands/operations/show-modal.operation';
-
-export function FindMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
- return {
- id: ShowModalOperation.id,
- type: MenuItemType.BUTTON,
- icon: 'SearchIcon',
- title: 'find.findLabel',
- tooltip: 'find.findLabel',
- positions: [MenuPosition.TOOLBAR_START],
- // TODO@Dushusir disabled$ status
- };
-}
diff --git a/packages/sheets-find/src/controllers/search-content-controller.ts b/packages/sheets-find/src/controllers/search-content-controller.ts
deleted file mode 100644
index 36ead843dd..0000000000
--- a/packages/sheets-find/src/controllers/search-content-controller.ts
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// export class SearchContentController {
-// private _searchData;
-
-// private _plugin: FindPlugin;
-
-// private _searchContent: SearchContent;
-
-// private _searchText: string;
-
-// private _matchList: string[];
-
-// constructor(plugin: FindPlugin) {
-// this._plugin = plugin;
-
-// this._searchData = {
-// tab: [
-// {
-// locale: 'find.find',
-// key: 'find',
-// },
-// {
-// locale: 'find.replace',
-// key: 'replace',
-// },
-// ],
-// content: [
-// {
-// locale: 'find.findTextbox',
-// },
-// {
-// locale: 'find.replaceTextbox',
-// },
-// ],
-// buttons: [
-// {
-// locale: 'find.allFindBtn',
-// key: 'find',
-// // onClick: () => this.findText(true),
-// },
-// {
-// locale: 'find.findBtn',
-// key: 'find',
-// // onClick: () => this.findText(),
-// },
-// {
-// locale: 'find.allReplaceBtn',
-// key: 'replace',
-// },
-// {
-// locale: 'find.replaceBtn',
-// key: 'replace',
-// },
-// ],
-// match: [
-// {
-// locale: 'find.regexTextbox',
-// value: 'regex',
-// },
-// {
-// locale: 'find.wholeTextbox',
-// value: 'whole',
-// },
-// {
-// locale: 'find.distinguishTextbox',
-// value: 'capsLock',
-// },
-// ],
-// changeSearchText: this.changeSearchText,
-// getMatch: this.getMatch,
-// };
-
-// this.init();
-// }
-
-// init() {
-// const plugin = this._plugin.getContext().getPluginManager().getPluginByName<FindPlugin>(FIND_PLUGIN_NAME)!;
-
-// plugin.getObserver('onSearchContentDidMountObservable')!.add((component) => {
-// this._searchContent = component;
-
-// this.resetSearchData();
-// });
-// }
-
-// resetSearchData() {
-// const locale = this._plugin.getContext().getLocale();
-
-// for (const k in this._searchData) {
-// if (this._searchData[k] instanceof Array) {
-// for (let i = 0; i < this._searchData[k].length; i++) {
-// this._searchData[k][i].label = locale.get(this._searchData[k][i].locale);
-// }
-// }
-// }
-
-// this._searchContent.setSearchData(this._searchData);
-// }
-
-// findText(isFull?: boolean) {
-// // @ts-ignore
-// // TODO ...
-// // BUG
-// // let textFinder = this._context.getPluginManager().getPluginByName<FindPlugin>('pluginFind')!.createTextFinder('A1:B10', this._searchText);
-// // if (this._matchList.includes('capslock')) textFinder = textFinder.matchCase(true);
-// // if (this._matchList.includes('whole')) textFinder = textFinder.matchEntireCell(true);
-// // if (isFull) {
-// // textFinder.findAll();
-// // } else {
-// // textFinder.findNext();
-// // }
-// }
-
-// // get search text
-// changeSearchText(e: Event) {
-// const target = e.target as HTMLInputElement;
-// this._searchText = target.value;
-// }
-
-// // get match condition
-// getMatch = (value: string[]) => {
-// this._matchList = value;
-// };
-// }
diff --git a/packages/sheets-find/src/domain/index.ts b/packages/sheets-find/src/domain/index.ts
deleted file mode 100644
index ea898c4f60..0000000000
--- a/packages/sheets-find/src/domain/index.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from './text-find';
diff --git a/packages/sheets-find/src/domain/text-find.ts b/packages/sheets-find/src/domain/text-find.ts
deleted file mode 100644
index 299329458d..0000000000
--- a/packages/sheets-find/src/domain/text-find.ts
+++ /dev/null
@@ -1,378 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { ICellData, IGridRange, Nullable, Range, Worksheet } from '@univerjs/core';
-import { FormatType, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';
-import { SelectionManagerService, transformCellDataToSelectionData } from '@univerjs/sheets';
-import { ISelectionRenderService } from '@univerjs/sheets-ui';
-import { Inject } from '@wendellhu/redi';
-
-import type { FindType } from '../i-data';
-import { getRegExpStr } from '../util/util';
-import { SelectSearch } from '../views/ui/FindModal';
-
-export class TextFinder {
- private _text: string | FormatType = '';
-
- private _type: FindType = 'text'; // 查找类型
-
- private _searchRange: SelectSearch = SelectSearch.CurrentSheet; //查找范围
-
- private _range: IGridRange[] = []; // 保存匹配到的单元格range格式
-
- private _rangeData: IGridRange[] = []; // rangList每个单元格range格式
-
- private _index: number = -1;
-
- private _matchCase: boolean = false; // 大小写匹配
-
- private _matchEntire: boolean = false; // 完全匹配
-
- private _useRegEx: boolean = false; // 正则匹配
-
- private _matchFormula: boolean = false; // 匹配公式文字
-
- private _startRange: Nullable<Range>; // 从这个位置后开始找
-
- constructor(
- @IUniverInstanceService private readonly _currentUniverService: IUniverInstanceService,
- @Inject(SelectionManagerService) private readonly _selectionManagerService: SelectionManagerService,
- @ISelectionRenderService
- private readonly _selectionRenderService: ISelectionRenderService
- ) {}
-
- /**
- * Returns all cells matching the search criteria.
- */
- findAll(): Nullable<TextFinder> {
- this._match();
- if (!this._range.length) return null;
- return this;
- }
-
- /**
- * Returns the next cell matching the search criteria.
- */
- findNext(): Nullable<TextFinder> {
- if (this._range.length === 0) return null;
- this._index++;
- if (this._index > this._range.length - 1) this._index = 0;
- this._highlightCell(this._range[this._index]);
- return this;
- }
-
- /**
- * Returns the previous cell matching the search criteria.
- */
- findPrevious(): Nullable<TextFinder> {
- if (this._range.length === 0) return null;
- this._index--;
- if (this._index < 0) this._index = this._range.length - 1;
- this._highlightCell(this._range[this._index]);
- return this;
- }
-
- getCount(): number {
- return this._range.length;
- }
-
- getCurrentIndex(): number {
- return this._index;
- }
-
- /**
- * If true, configures the search to match the search text's case exactly, otherwise the search defaults to case-insensitive matching.
- */
- matchCase(matchCase: boolean): TextFinder {
- this._matchCase = matchCase;
- return this;
- }
-
- /**
- * If true, configures the search to match the entire contents of a cell; otherwise, the search defaults to partial matching.
- */
- matchEntireCell(matchEntire: boolean): TextFinder {
- this._matchEntire = matchEntire;
- return this;
- }
-
- /**
- * If true, configures the search to return matches that appear within formula text; otherwise cells with formulas are considered based on their displayed value.
- */
- matchFormulaText(matchFormulaText: boolean): TextFinder {
- this._matchFormula = matchFormulaText;
- return this;
- }
-
- /**
- * If true, configures the search to interpret the search string as a regular expression; otherwise the search interprets the search string as normal text.
- */
- useRegularExpression(useRegEx: boolean): TextFinder {
- this._useRegEx = useRegEx;
- return this;
- }
-
- /**
- * TODO
- * 替换还需考虑编辑模式和保护模式,整个workbook
- */
- /**
- * Replaces all matches with the specified text. Returns the number of occurrences replaced, which may be different from the number of matched cells.
- */
- replaceAllWith(replaceText: string): number {
- if (!this._range.length) return 0;
-
- let count = 0;
- const sheetId = this._range[0].sheetId;
- let sheet = this._currentUniverService.getCurrentUniverSheetInstance().getSheetBySheetId(sheetId);
- for (let i = 0; i < this._range.length; i++) {
- if (sheetId !== this._range[i].sheetId) {
- sheet = this._currentUniverService
- .getCurrentUniverSheetInstance()
-
- .getSheetBySheetId(this._range[i].sheetId);
- }
- const range = this._range[i];
- if (!sheet) continue;
-
- this._replaceText(sheet, range, replaceText);
- count++;
- }
- this._range = [];
- this._index = -1;
-
- return count;
- }
-
- /**
- * Replaces the search text in the currently matched cell with the specified text and returns the number of occurrences replaced.
- */
- replaceWith(replaceText: string): number {
- if (!this._range.length) return 0;
- const range = this._range[this._index];
- const sheet = this._currentUniverService
- .getCurrentUniverSheetInstance()
-
- .getSheetBySheetId(range.sheetId);
- if (!sheet) return 0;
-
- this._replaceText(sheet, range, replaceText);
-
- this._range.splice(this._index, 1);
- this._highlightCell(this._range[this._index]);
- return 1;
- }
-
- /**
- * Configures the search to start searching immediately after the specified cell range.
- */
- startFrom(startRange: Range): TextFinder {
- this._startRange = startRange;
- return this;
- }
-
- /**
- * Returns the current cell matching the search criteria.
- */
- getCurrentMatch(): IGridRange | null {
- if (this._index < 0) return null;
- return this._range[this._index];
- }
-
- // 开始查找
- searchText(
- text: string | FormatType,
- type: FindType = 'text',
- searchRange: SelectSearch = SelectSearch.CurrentSheet
- ): TextFinder | null {
- if (!text) return null;
- // 查找范围变化或者初始化rangeData
- if (this._searchRange !== searchRange || !this._rangeData.length) {
- this._getRange(searchRange);
- }
- // 查找文字或者类型变化
- if (this._text !== text || this._type !== type) {
- this._type = type;
- this._text = text;
- this._index = -1;
- this.findAll();
- }
- return this;
- }
-
- private _getRange(searchRange: SelectSearch) {
- if (searchRange === SelectSearch.CurrentSheet) {
- const sheet = this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet();
- const sheetId = sheet.getSheetId();
- const rangeList: IGridRange = {
- sheetId,
- range: {
- startRow: 0,
- endRow: sheet.getLastRowWithContent(),
- startColumn: 0,
- endColumn: sheet.getLastColumnWithContent(),
- },
- };
- this._rangeData = [rangeList];
- }
- }
-
- /**
- * match rule
- */
- private _match = () => {
- const matchMap = new Map<string | FormatType, () => IGridRange[]>([
- ['text', this._mathTxt.bind(this)],
- // ['condition', this._matchCondition],
- // ['intervalRow', () => this._matchInterval('row')],
- // ['intervalColumn', () => this._matchInterval('column')],
- // ['null', this._matchNull],
- // ['format', this._matchFormat],
- ]);
- let range;
- if (this._type in FormatType) {
- range = matchMap.get('format')!();
- } else {
- range = matchMap.get(this._type)!();
- }
- // range.sort((a, b) => a.getRangeData().startRow - b.getRangeData().startRow).sort((a, b) => a.getRangeData().startColumn - b.getRangeData().startColumn);
- // if (this._startRange) {
- // const startRange = this._startRange.getRangeData();
- // for (let i = 0; i < range.length; i++) {
- // const cell = range[i].getRangeData();
- // if (cell.startColumn <= startRange.endColumn) {
- // range.splice(i, 1);
- // i--;
- // } else if (cell.startRow < startRange.startRow) {
- // range.splice(i, 1);
- // i--;
- // }
- // }
- // }
- this._range = range;
- };
-
- // 查找文本
- private _mathTxt(): IGridRange[] {
- const range: IGridRange[] = [];
- for (let i = 0; i < this._rangeData.length; i++) {
- const sheet = this._currentUniverService
- .getCurrentUniverSheetInstance()
-
- .getSheetBySheetId(this._rangeData[i].sheetId);
- if (!sheet) return [];
- let matrix: ObjectMatrix<Nullable<ICellData>> = new ObjectMatrix<Nullable<ICellData>>();
- if (this._matchFormula) {
- // matrix = this._rangeData[i].getValue().f;
- } else {
- matrix = sheet.getRange(this._rangeData[i].range).getMatrix();
- }
-
- if (this._matchEntire) {
- matrix.forValue((row, col, value) => {
- if (value == null || !value.v) return;
- if (
- (this._matchCase && value.v === this._text) ||
- (this._text as string).toLowerCase() === `${value.v}`.toLowerCase()
- ) {
- range.push({
- sheetId: this._rangeData[i].sheetId,
- range: {
- startRow: row,
- endRow: row,
- startColumn: col,
- endColumn: col,
- },
- });
- }
- });
- }
- // else if (this._useRegEx) {
- // let reg;
- // if (this._matchCase) {
- // reg = new RegExp(getRegExpStr(this._text), 'g');
- // } else {
- // reg = new RegExp(getRegExpStr(this._text), 'ig');
- // }
-
- // if (reg.test(value)) {
- // range.push(this._rangeData[i]);
- // }
- // }
- else {
- const reg = new RegExp(getRegExpStr(this._text as string), this._matchCase ? 'g' : 'ig');
-
- matrix.forValue((row, col, value) => {
- if (value == null || !value.v) return;
- if (reg.test(`${value.v}`)) {
- reg.lastIndex = 0;
- range.push({
- sheetId: this._rangeData[i].sheetId,
- range: {
- startRow: row,
- endRow: row,
- startColumn: col,
- endColumn: col,
- },
- });
- }
- });
- }
- }
- return range;
- }
-
- // 高亮匹配单元格
- private _highlightCell(range: IGridRange) {
- if (!range) return;
- const workbook = this._currentUniverService.getCurrentUniverSheetInstance();
- const unitId = workbook.getUnitId();
- const sheetId = range.sheetId;
- const mergeData = workbook.getActiveSheet().getMergeData();
-
- const selectionRange = transformCellDataToSelectionData(
- range.range.startColumn,
- range.range.endColumn,
- mergeData
- );
- if (selectionRange == null) {
- return;
- }
-
- this._selectionManagerService.replace([
- {
- ...selectionRange,
- ...this._selectionManagerService.createDefaultSelection(),
- },
- ]);
- }
-
- private _replaceText(sheet: Worksheet, range: IGridRange, text: string) {
- const value = sheet.getRange(range.range).getValue();
- if (!value || !value.v) return 0;
- if (!this._matchEntire) {
- let match;
- match = 'ig';
- if (this._matchCase) {
- match = 'g';
- }
- const reg = new RegExp(getRegExpStr(this._text as string), match);
- // sheet.getRange(range.range).setValue(value.m.replace(reg, text));
- } else {
- // sheet.getRange(range.range).setValue(text);
- }
- }
-}
diff --git a/packages/sheets-find/src/find-plugin.ts b/packages/sheets-find/src/find-plugin.ts
deleted file mode 100644
index 2613666e51..0000000000
--- a/packages/sheets-find/src/find-plugin.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { IUniverInstanceService, LocaleService, Plugin, PluginType } from '@univerjs/core';
-// import { TextFinder } from './domain/text-find';
-import type { Dependency } from '@wendellhu/redi';
-import { Inject, Injector } from '@wendellhu/redi';
-
-import { FIND_PLUGIN_NAME } from './const/plugin-name';
-import { FindController } from './controllers/find-controller';
-import { FindModalController } from './controllers/find-modal-controller';
-import { TextFinder } from './domain/text-find';
-import { zhCN } from './locale';
-import { FindService } from './services/find.service';
-// import { FindPluginObserve, install } from './basics/observer';
-// import { FindModalController } from './controllers/find-modal-controller';
-// import { TextFinder } from './domain';
-
-export interface IFindPluginConfig {}
-
-export class UniverSheetsFindPlugin extends Plugin {
- static override type = PluginType.Sheet;
-
- private _config: IFindPluginConfig = {};
-
- private _findController: FindController | null = null;
-
- private _findModalController: FindModalController | null = null;
-
- constructor(
- config: Partial<IFindPluginConfig>,
- @IUniverInstanceService private readonly _currentUniverService: IUniverInstanceService,
- @Inject(LocaleService) private readonly _localeService: LocaleService,
- @Inject(Injector) protected readonly _injector: Injector
- ) {
- super(FIND_PLUGIN_NAME);
-
- this.initializeDependencies(_injector);
- }
-
- // installTo(universheetInstance: UniverSheet) {
- // universheetInstance.installPlugin(this);
- // }
-
- // installTo(universheetInstance: UniverSheet) {
- // universheetInstance.installPlugin(this);
-
- // this._textFinder = new TextFinder(this);
- // this._findModalController = new FindModalController(this);
- // this._findController = new FindController(this);
-
- // const context = this.getContext();
- // let sheetsPlugin = context.getUniver().getGlobalContext().getPluginManager().getRequirePluginByName<UniverSheetsUI>(SHEET_UI_PLUGIN_NAME);
- // sheetsPlugin?.UIDidMount(() => {
- // sheetsPlugin.getComponentManager().register('SearchIcon', Icon.SearchIcon);
- // sheetsPlugin.addToolButton(this._findController.getFindList());
- // });
- // }
-
- initialize(): void {
- this._localeService.load({
- zhCN,
- });
-
- this.initController();
- }
-
- // createTextFinder(workSheet: Worksheet, type: FindType, text: string) {
- // // return new TextFinder(workSheet, type, text);
- // }
-
- override onRendered(): void {
- this.initialize();
- }
-
- initController() {
- this._findController = this._injector.get(FindController);
- this._findModalController = this._injector.get(FindModalController);
- }
-
- initializeDependencies(sheetInjector: Injector) {
- const dependencies: Dependency[] = [[FindController], [TextFinder], [FindModalController], [FindService]];
-
- dependencies.forEach((d) => {
- sheetInjector.add(d);
- });
- }
-}
diff --git a/packages/sheets-find/src/i-data/index.ts b/packages/sheets-find/src/i-data/index.ts
deleted file mode 100644
index 7ae6bb6d4f..0000000000
--- a/packages/sheets-find/src/i-data/index.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from './i-find';
diff --git a/packages/sheets-find/src/proxy-data/i-proxy-data-set.ts b/packages/sheets-find/src/proxy-data/i-proxy-data-set.ts
deleted file mode 100644
index b7721225ce..0000000000
--- a/packages/sheets-find/src/proxy-data/i-proxy-data-set.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export class IProxyDataSet {}
diff --git a/packages/sheets-find/src/proxy-data/i-proxy-data.ts b/packages/sheets-find/src/proxy-data/i-proxy-data.ts
deleted file mode 100644
index f4e0464c17..0000000000
--- a/packages/sheets-find/src/proxy-data/i-proxy-data.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export class IProxyData {}
diff --git a/packages/sheets-find/src/proxy-data/index.ts b/packages/sheets-find/src/proxy-data/index.ts
deleted file mode 100644
index f3afc8c062..0000000000
--- a/packages/sheets-find/src/proxy-data/index.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from './i-proxy-data';
-export * from './i-proxy-data-set';
-export * from './proxy-data-find';
diff --git a/packages/sheets-find/src/proxy-data/proxy-data-find.ts b/packages/sheets-find/src/proxy-data/proxy-data-find.ts
deleted file mode 100644
index 61dc210138..0000000000
--- a/packages/sheets-find/src/proxy-data/proxy-data-find.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export class IProxyDataFind {}
diff --git a/packages/sheets-find/src/services/find-service.ts b/packages/sheets-find/src/services/find-service.ts
deleted file mode 100644
index e45863dba1..0000000000
--- a/packages/sheets-find/src/services/find-service.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export class FindService {}
diff --git a/packages/sheets-find/src/services/index.ts b/packages/sheets-find/src/services/index.ts
deleted file mode 100644
index daf87fbcce..0000000000
--- a/packages/sheets-find/src/services/index.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from './find-service';
diff --git a/packages/sheets-find/src/types/index.d.ts b/packages/sheets-find/src/types/index.d.ts
deleted file mode 100644
index 2da002dd94..0000000000
--- a/packages/sheets-find/src/types/index.d.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from '../index';
-declare module '@univerjs/sheets-find' {}
diff --git a/packages/sheets-find/src/util/util.ts b/packages/sheets-find/src/util/util.ts
deleted file mode 100644
index 6656793946..0000000000
--- a/packages/sheets-find/src/util/util.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export const getRegExpStr = (str: string) =>
- str.replace('~*', '\\*').replace('~?', '\\?').replace('.', '\\.').replace('*', '.*').replace('?', '.');
diff --git a/packages/sheets-find/src/views/event.ts b/packages/sheets-find/src/views/event.ts
deleted file mode 100644
index 2b2d08db70..0000000000
--- a/packages/sheets-find/src/views/event.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export class Event {}
diff --git a/packages/sheets-find/src/views/index.ts b/packages/sheets-find/src/views/index.ts
deleted file mode 100644
index d697c5a836..0000000000
--- a/packages/sheets-find/src/views/index.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export * from './event';
-export * from './observer-list';
-export * from './render';
diff --git a/packages/sheets-find/src/views/observer-list.ts b/packages/sheets-find/src/views/observer-list.ts
deleted file mode 100644
index f993ef173d..0000000000
--- a/packages/sheets-find/src/views/observer-list.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export class ObserverList {}
diff --git a/packages/sheets-find/src/views/render.ts b/packages/sheets-find/src/views/render.ts
deleted file mode 100644
index f8ca2ec638..0000000000
--- a/packages/sheets-find/src/views/render.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export class Render {}
diff --git a/packages/sheets-find/src/views/ui/FindModal.tsx b/packages/sheets-find/src/views/ui/FindModal.tsx
deleted file mode 100644
index 6f50139b1d..0000000000
--- a/packages/sheets-find/src/views/ui/FindModal.tsx
+++ /dev/null
@@ -1,288 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { ICheckboxGroupProps } from '@univerjs/design';
-import type { BaseComponentProps } from '@univerjs/ui';
-import React, { Component } from 'react';
-
-interface searchResult {
- count: number;
- current: number;
- replaceCount: number;
-}
-
-// Types for props
-export interface IProps extends BaseComponentProps {
- findNext: (value: string) => searchResult;
- replaceText: (value: string) => searchResult;
- replaceAll: (value: string) => searchResult;
- findPrevious: (value: string) => searchResult;
- matchCase: (matchCase: boolean) => void;
- matchEntireCell: (matchEntire: boolean) => void;
-}
-
-// Types for state
-interface IState {
- show: boolean;
- hideAdvanced: boolean;
- showRange: boolean;
- current: number;
- count: number;
- replaceCount: number;
- value: string;
-}
-
-export enum SelectSearch {
- CurrentSheet,
- AllSheets,
- Range,
-}
-
-export class FindModal extends Component<IProps, IState> {
- private _matchGroup: ICheckboxGroupProps[] = [];
-
- private _select: any[] = [];
-
- constructor(props: IProps) {
- super(props);
- this.state = {
- show: false,
- hideAdvanced: true,
- showRange: false,
- current: 0,
- count: 0,
- replaceCount: 0,
- value: '',
- };
-
- // this._matchGroup = [
- // {
- // name: '',
- // label: 'find.matchCase',
- // value: '1',
- // },
- // {
- // name: '',
- // label: 'find.matchAll',
- // value: '2',
- // },
- // {
- // name: '',
- // label: 'find.matchInFormula',
- // value: '3',
- // },
- // ];
-
- this._select = [
- {
- label: 'find.searchTargetSheet',
- value: SelectSearch.CurrentSheet,
- },
- {
- label: 'find.searchAll',
- value: SelectSearch.AllSheets,
- },
- {
- label: 'find.specific',
- value: SelectSearch.Range,
- },
- ];
- }
-
- override componentDidMount() {
- this.props.getComponent?.(this);
- }
-
- showFindModal(show: boolean) {
- this.setState({
- show,
- });
- }
-
- // 国际化checkbox
- getMatchGroup() {
- const arr: ICheckboxGroupProps[] = JSON.parse(JSON.stringify(this._matchGroup));
- // arr.forEach((element: ICheckboxGroupProps) => {
- // element.label = <CustomLabel label={element.label} />;
- // });
- return arr;
- }
-
- // 国际化Select
- getSelect() {
- const arr: any[] = JSON.parse(JSON.stringify(this._select));
- // arr.forEach((element: ICheckboxGroupProps) => {
- // element.label = <CustomLabel label={element.label} />;
- // });
- return arr;
- }
-
- handleChange(value: string[]) {
- this.props.matchCase(!!value.includes('1'));
- this.props.matchEntireCell(!!value.includes('2'));
- }
-
- handleHideAdvanced(hide: boolean) {
- this.setState({
- hideAdvanced: hide,
- });
- }
-
- selectSearch(value: number) {
- if (value === SelectSearch.Range) {
- this.setState({
- showRange: true,
- });
- return;
- }
- this.setState({
- showRange: false,
- });
- }
-
- findNext() {
- const value = this.state.value;
- if (!value) return;
- const { count, current } = this.props.findNext(value);
- this.setState({
- count,
- current,
- });
- }
-
- findPrevious() {
- const value = this.state.value;
- if (!value) return;
- const { count, current } = this.props.findPrevious(value);
- this.setState({
- count,
- current,
- });
- }
-
- replaceText() {
- const value = this.state.value;
- if (!value) return;
- const replaceCount = this.props.replaceText(value);
- this.setState({
- ...replaceCount,
- });
- }
-
- replaceAll() {
- const value = this.state.value;
- if (!value) return;
- const replaceCount = this.props.replaceAll(value);
- this.setState({
- ...replaceCount,
- });
- }
-
- onChange(e: React.ChangeEvent<HTMLInputElement>) {
- const value = e.target.value;
- this.setState({
- value,
- });
- }
-
- /**
- * Render the component's HTML
- *
- * @returns {void}
- */
- override render() {
- const { show, hideAdvanced, showRange, current, count } = this.state;
- // Set Provider for entire Container
- return (
- // <Modal
- // onCancel={() => this.handleHideAdvanced(true)}
- // className={styles.findModal}
- // isDrag
- // footer={false}
- // mask={false}
- // title={<CustomLabel label={hideAdvanced ? 'find.find' : 'find.findLabel'} />}
- // visible={show}
- // >
- // <div className={styles.box}>
- // {hideAdvanced ? null : (
- // <span>
- // <CustomLabel label="find.find" />
- // </span>
- // )}
- // <Input onValueChange={this.findNext.bind(this)} onChange={(e) => this.onChange(e)}></Input>
- // {count ? (
- // <div className={styles.count}>
- // <span onClick={this.findPrevious.bind(this)}>
- // {/* <Icon.Format.NextIcon rotate={90}></Icon.Format.NextIcon> */}
- // </span>
- // {current}/{count}
- // <span onClick={this.findNext.bind(this)}>
- // {/* <Icon.Format.NextIcon rotate={-90}></Icon.Format.NextIcon> */}
- // </span>
- // </div>
- // ) : null}
- // </div>
- // {hideAdvanced ? (
- // <p
- // style={{ display: hideAdvanced ? 'block' : 'none' }}
- // onClick={() => this.handleHideAdvanced(false)}
- // >
- // <CustomLabel label="find.replace" />/<CustomLabel label="find.advanced" />
- // {/* <Icon.Format.NextIcon /> */}
- // </p>
- // ) : (
- // <>
- // <div className={styles.box}>
- // <span>
- // <CustomLabel label="find.replaceWith" />
- // </span>
- // <Input></Input>
- // </div>
- // <div className={styles.box}>
- // <span>
- // <CustomLabel label="find.search" />
- // </span>
- // <Select onClick={this.selectSearch.bind(this)} children={this.getSelect()}></Select>
- // {showRange ? <CellRange onClick={() => {}} /> : null}
- // </div>
- // <div className={styles.box}>
- // <span></span>
- // {/* <CheckboxGroup
- // options={this.getMatchGroup()}
- // onChange={this.handleChange.bind(this)}
- // ></CheckboxGroup> */}
- // </div>
- // <div className={styles.buttonGroup}>
- // <Button type="primary">
- // <CustomLabel label="button.cancel" />
- // </Button>
- // <Button onClick={this.replaceAll.bind(this)}>
- // <CustomLabel label="find.allReplaceBtn" />
- // </Button>
- // <Button onClick={this.replaceText.bind(this)}>
- // <CustomLabel label="find.replace" />
- // </Button>
- // <Button onClick={this.findNext.bind(this)}>
- // <CustomLabel label="find.find" />
- // </Button>
- // </div>
- // </>
- // )}
- // </Modal>
- <></>
- );
- }
-}
diff --git a/packages/sheets-find/src/views/ui/LocationContent.tsx b/packages/sheets-find/src/views/ui/LocationContent.tsx
deleted file mode 100644
index a52de29a48..0000000000
--- a/packages/sheets-find/src/views/ui/LocationContent.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import React, { Component } from 'react';
-
-interface LocationProps {
- config: any;
-}
-interface LocationState {
- radioGroup: LabelProps[];
- active: string | number;
-}
-interface LabelProps {
- locale: string;
- label?: string;
- value: string;
- disabled?: boolean;
- children?: LabelProps[];
- checked?: boolean;
-}
-
-export class LocationContent extends Component<LocationProps, LocationState> {
- // private _localeObserver: Nullable<Observer<Workbook>>;
-
- // initialize() {
- // this.state = {
- // radioGroup: [],
- // active: '1',
- // };
- // }
-
- // handleChange = (value: string) => {
- // let { radioGroup } = this.state;
- // radioGroup.forEach((item) => {
- // if (item.children) {
- // item.children.forEach((ele) => {
- // ele.disabled = true;
- // });
- // }
- // });
-
- // radioGroup.forEach((item) => {
- // if (item.value === value) {
- // if (item.children) {
- // item.children.forEach((ele) => {
- // ele.disabled = false;
- // });
- // }
- // this.setValue({ active: value, radioGroup });
- // }
- // });
- // };
-
- // handleCheckbox = (value: string[], locale: string) => {
- // let { radioGroup } = this.state;
- // let index = radioGroup.findIndex((item) => item.locale === locale);
- // radioGroup[index].children!.forEach((ele) => {
- // if (value.includes(ele.value)) {
- // ele.checked = true;
- // } else {
- // ele.checked = false;
- // }
- // });
- // this.setValue({ radioGroup });
- // };
-
- override render() {
- // const CheckboxGroup = this.Render.renderFunction('CheckboxGroup');
- // const Radio = this.Render.renderFunction('Radio');
- // const RadioGroup = this.Render.renderFunction('RadioGroup');
- // const { radioGroup, active } = this.state;
- return (
- <div />
- // <div className={styles.locationContent}>
- // <RadioGroup vertical={true} onChange={this.handleChange} active={active}>
- // {radioGroup.map((item) => {
- // if (item.children) {
- // return (
- // <Radio value={item.value} label={item.label}>
- // <CheckboxGroup options={item.children} onChange={(value) => this.handleCheckbox(value, item.locale)} />
- // </Radio>
- // );
- // }
- // return <Radio value={item.value} label={item.label}></Radio>;
- // })}
- // </RadioGroup>
- // </div>
- );
- }
-}
diff --git a/packages/sheets-find/src/views/ui/SearchContent.tsx b/packages/sheets-find/src/views/ui/SearchContent.tsx
deleted file mode 100644
index 054fe6ef72..0000000000
--- a/packages/sheets-find/src/views/ui/SearchContent.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { Nullable } from '@univerjs/core';
-import React, { Component } from 'react';
-
-interface SearchProps {
- config: any;
- activeKey?: string;
- keys?: string;
-}
-
-interface SearchState {
- tab: LabelProps[];
- content: LabelProps[];
- match: LabelProps[];
- buttons: LabelProps[];
- changeSearchText: Nullable<(e: Event) => void>;
- getMatch: Nullable<(value: string[]) => void>;
-}
-
-interface LabelProps {
- locale?: string;
- label?: string;
- value?: string;
- key?: string;
- onClick?: () => void;
-}
-
-export class SearchContent extends Component<SearchProps, SearchState> {
- // initialize() {
- // this.state = {
- // tab: [],
- // content: [],
- // buttons: [],
- // match: [],
- // changeSearchText: null,
- // getMatch: null,
- // };
- // }
-
- // componentDidMount() {
- // const plugin = this._context.getPluginManager().getPluginByName<FindPlugin>(FIND_PLUGIN_NAME)!;
- // plugin.getObserver('onSearchContentDidMountObservable')!.notifyObservers(this);
- // }
-
- // setSearchData(data: any) {
- // this.setState({
- // ...data,
- // });
- // }
-
- override render() {
- // const Tab = this.Render.renderFunction('Tab');
- // const TabPane = this.Render.renderFunction('TabPane');
- // const Button = this.Render.renderFunction('Button');
- // const CheckboxGroup = this.Render.renderFunction('CheckboxGroup');
- // const Input = this.Render.renderFunction('Input');
- // const { tab, content, match, buttons, changeSearchText, getMatch } = state;
- // const { activeKey } = props;
-
- // if (!changeSearchText || !getMatch) return;
-
- return (
- <div />
- // <Tab activeKey={activeKey} type="card">
- // {tab.map((item, index) => (
- // <TabPane tab={item.label} keys={item.key} key={index}>
- // <div className={styles.tabBox}>
- // <div className={styles.inputBox}>
- // <div className={styles.textBox}>
- // <div>
- // <span>{content[0].label}: </span>
- // <Input onChange={(e: Event) => changeSearchText(e)} />
- // </div>
- // {item.key === 'replace' ? (
- // <div>
- // <span>{content[1].label}: </span>
- // <Input />
- // </div>
- // ) : (
- // <></>
- // )}
- // </div>
- // <div>
- // <CheckboxGroup options={match} onChange={getMatch}></CheckboxGroup>
- // </div>
- // </div>
- // <div className={styles.btnBox}>
- // {buttons.map((item, index) => {
- // if (item.key === 'replace') {
- // return (
- // <Button key={index} onClick={item.onClick}>
- // {item.label}
- // </Button>
- // );
- // }
- // return (
- // <Button key={index} onClick={item.onClick}>
- // {item.label}
- // </Button>
- // );
- // })}
- // </div>
- // </div>
- // </TabPane>
- // ))}
- // </Tab>
- );
- }
-}
diff --git a/packages/sheets-find/src/views/ui/index.module.less b/packages/sheets-find/src/views/ui/index.module.less
deleted file mode 100644
index d6322e4d5a..0000000000
--- a/packages/sheets-find/src/views/ui/index.module.less
+++ /dev/null
@@ -1,93 +0,0 @@
-.find-modal {
- input {
- height: 36px;
- border: 1px solid #dadce0;
- border-radius: 4px;
- }
-
- .cell-range-modal {
- width: 30%;
- margin-left: 1rem;
-
- input {
- height: 36px;
- }
- }
-
- p {
- cursor: pointer;
- text-align: center;
- }
-
- .box {
- position: relative;
-
- display: flex;
- align-items: center;
-
- margin-bottom: 1.5rem;
-
- font-size: 14px;
-
- &:first-of-type {
- margin-top: .5rem;
- }
-
- .count {
- position: absolute;
- z-index: 1;
- top: 0;
- right: 0;
-
- height: 36px;
-
- line-height: 36px;
-
- >span {
- cursor: pointer;
- padding: 0 5px;
- }
- }
-
- >span {
- flex-shrink: 0;
- width: 60px
- }
-
- .select-component {
- cursor: pointer;
- height: 36px;
- border: 1px solid #dadce0;
- }
-
- .drop-content {
- height: 36px;
- }
- }
-
- .checkbox-group {
- display: flex;
- flex-direction: column;
-
- .checkbox-wrapper {
- margin-bottom: 1rem;
- }
- }
-
- .button-group {
- display: flex;
- flex-direction: row-reverse;
- margin-top: 2rem;
-
- button {
- height: 36px;
- margin-left: .5rem;
- padding: 9px 24px 11px;
-
- line-height: 16px;
- letter-spacing: 0.25px;
-
- border-radius: 4px;
- }
- }
-}
\ No newline at end of file
diff --git a/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts b/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts
index 619748e1f6..607dd070e3 100644
--- a/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts
+++ b/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts
@@ -15,7 +15,7 @@
*/
import { DeviceInputEventType } from '@univerjs/engine-render';
-import { whenEditorInputFormulaActivated } from '@univerjs/sheets-ui';
+import { whenFormulaEditorActivated } from '@univerjs/sheets-ui';
import type { IShortcutItem } from '@univerjs/ui';
import { KeyCode, MetaKeys } from '@univerjs/ui';
@@ -38,7 +38,7 @@ export function promptSelectionShortcutItem() {
shortcutList.push({
id: SelectEditorFormulaOperation.id,
binding: keycode,
- preconditions: (contextService) => whenEditorInputFormulaActivated(contextService),
+ preconditions: (contextService) => whenFormulaEditorActivated(contextService),
staticParameters: {
eventType: DeviceInputEventType.Keyboard,
keycode,
@@ -54,7 +54,7 @@ export function promptSelectionShortcutItemShift() {
shortcutList.push({
id: SelectEditorFormulaOperation.id,
binding: keycode | MetaKeys.SHIFT,
- preconditions: (contextService) => whenEditorInputFormulaActivated(contextService),
+ preconditions: (contextService) => whenFormulaEditorActivated(contextService),
staticParameters: {
eventType: DeviceInputEventType.Keyboard,
keycode,
@@ -71,7 +71,7 @@ export function promptSelectionShortcutItemCtrl() {
shortcutList.push({
id: SelectEditorFormulaOperation.id,
binding: keycode | MetaKeys.CTRL_COMMAND,
- preconditions: (contextService) => whenEditorInputFormulaActivated(contextService),
+ preconditions: (contextService) => whenFormulaEditorActivated(contextService),
staticParameters: {
eventType: DeviceInputEventType.Keyboard,
keycode,
@@ -88,7 +88,7 @@ export function promptSelectionShortcutItemCtrlAndShift() {
shortcutList.push({
id: SelectEditorFormulaOperation.id,
binding: keycode | MetaKeys.SHIFT | MetaKeys.CTRL_COMMAND,
- preconditions: (contextService) => whenEditorInputFormulaActivated(contextService),
+ preconditions: (contextService) => whenFormulaEditorActivated(contextService),
staticParameters: {
eventType: DeviceInputEventType.Keyboard,
keycode,
@@ -102,5 +102,5 @@ export function promptSelectionShortcutItemCtrlAndShift() {
export const ChangeRefToAbsoluteShortcut: IShortcutItem = {
id: ReferenceAbsoluteOperation.id,
binding: KeyCode.F4,
- preconditions: (contextService) => whenEditorInputFormulaActivated(contextService),
+ preconditions: (contextService) => whenFormulaEditorActivated(contextService),
};
diff --git a/packages/sheets-ui/src/commands/commands/clipboard.command.ts b/packages/sheets-ui/src/commands/commands/clipboard.command.ts
index 65ad54209f..608c4837c0 100644
--- a/packages/sheets-ui/src/commands/commands/clipboard.command.ts
+++ b/packages/sheets-ui/src/commands/commands/clipboard.command.ts
@@ -19,7 +19,7 @@ import { CommandType, ICommandService, ILogService } from '@univerjs/core';
import { CopyCommand, CutCommand, IClipboardInterfaceService, PasteCommand } from '@univerjs/ui';
import type { IAccessor } from '@wendellhu/redi';
-import { whenEditorNotActivated } from '../../controllers/shortcuts/utils';
+import { whenSheetEditorFocused } from '../../controllers/shortcuts/utils';
import { ISheetClipboardService, PREDEFINED_HOOK_NAME } from '../../services/clipboard/clipboard.service';
export const SheetCopyCommand: IMultiCommand = {
@@ -28,7 +28,7 @@ export const SheetCopyCommand: IMultiCommand = {
type: CommandType.COMMAND,
multi: true,
priority: 1000,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
handler: async (accessor) => {
const sheetClipboardService = accessor.get(ISheetClipboardService);
return sheetClipboardService.copy();
@@ -41,7 +41,7 @@ export const SheetCutCommand: IMultiCommand = {
type: CommandType.COMMAND,
multi: true,
priority: 1000,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
handler: async (accessor) => {
const sheetClipboardService = accessor.get(ISheetClipboardService);
return sheetClipboardService.cut();
@@ -58,7 +58,7 @@ export const SheetPasteCommand: IMultiCommand = {
multi: true,
name: 'sheet.command.paste',
priority: 1000,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
handler: async (accessor: IAccessor, params: ISheetPasteParams) => {
const logService = accessor.get(ILogService);
diff --git a/packages/sheets-ui/src/commands/commands/inline-format.command.ts b/packages/sheets-ui/src/commands/commands/inline-format.command.ts
index 62360e53ed..d31812f7fa 100644
--- a/packages/sheets-ui/src/commands/commands/inline-format.command.ts
+++ b/packages/sheets-ui/src/commands/commands/inline-format.command.ts
@@ -15,7 +15,7 @@
*/
import type { ICommand } from '@univerjs/core';
-import { CommandType, FOCUSING_EDITOR, ICommandService, IContextService } from '@univerjs/core';
+import { CommandType, EDITOR_ACTIVATED, ICommandService, IContextService } from '@univerjs/core';
import {
SetInlineFormatBoldCommand,
SetInlineFormatFontFamilyCommand,
@@ -49,7 +49,7 @@ export const SetRangeBoldCommand: ICommand = {
handler: async (accessor) => {
const commandService = accessor.get(ICommandService);
const contextService = accessor.get(IContextService);
- const isCellEditorFocus = contextService.getContextValue(FOCUSING_EDITOR);
+ const isCellEditorFocus = contextService.getContextValue(EDITOR_ACTIVATED);
if (isCellEditorFocus) {
return commandService.executeCommand(SetInlineFormatBoldCommand.id);
@@ -65,7 +65,7 @@ export const SetRangeItalicCommand: ICommand = {
handler: async (accessor) => {
const commandService = accessor.get(ICommandService);
const contextService = accessor.get(IContextService);
- const isCellEditorFocus = contextService.getContextValue(FOCUSING_EDITOR);
+ const isCellEditorFocus = contextService.getContextValue(EDITOR_ACTIVATED);
if (isCellEditorFocus) {
return commandService.executeCommand(SetInlineFormatItalicCommand.id);
@@ -81,7 +81,7 @@ export const SetRangeUnderlineCommand: ICommand = {
handler: async (accessor) => {
const commandService = accessor.get(ICommandService);
const contextService = accessor.get(IContextService);
- const isCellEditorFocus = contextService.getContextValue(FOCUSING_EDITOR);
+ const isCellEditorFocus = contextService.getContextValue(EDITOR_ACTIVATED);
if (isCellEditorFocus) {
return commandService.executeCommand(SetInlineFormatUnderlineCommand.id);
@@ -97,7 +97,7 @@ export const SetRangeStrickThroughCommand: ICommand = {
handler: async (accessor) => {
const commandService = accessor.get(ICommandService);
const contextService = accessor.get(IContextService);
- const isCellEditorFocus = contextService.getContextValue(FOCUSING_EDITOR);
+ const isCellEditorFocus = contextService.getContextValue(EDITOR_ACTIVATED);
if (isCellEditorFocus) {
return commandService.executeCommand(SetInlineFormatStrikethroughCommand.id);
@@ -113,7 +113,7 @@ export const SetRangeSubscriptCommand: ICommand = {
handler: async (accessor) => {
const commandService = accessor.get(ICommandService);
const contextService = accessor.get(IContextService);
- const isCellEditorFocus = contextService.getContextValue(FOCUSING_EDITOR);
+ const isCellEditorFocus = contextService.getContextValue(EDITOR_ACTIVATED);
if (isCellEditorFocus) {
return commandService.executeCommand(SetInlineFormatSubscriptCommand.id);
@@ -129,7 +129,7 @@ export const SetRangeSuperscriptCommand: ICommand = {
handler: async (accessor) => {
const commandService = accessor.get(ICommandService);
const contextService = accessor.get(IContextService);
- const isCellEditorFocus = contextService.getContextValue(FOCUSING_EDITOR);
+ const isCellEditorFocus = contextService.getContextValue(EDITOR_ACTIVATED);
if (isCellEditorFocus) {
return commandService.executeCommand(SetInlineFormatSuperscriptCommand.id);
@@ -145,7 +145,7 @@ export const SetRangeFontSizeCommand: ICommand = {
handler: async (accessor, params) => {
const commandService = accessor.get(ICommandService);
const contextService = accessor.get(IContextService);
- const isCellEditorFocus = contextService.getContextValue(FOCUSING_EDITOR);
+ const isCellEditorFocus = contextService.getContextValue(EDITOR_ACTIVATED);
if (isCellEditorFocus) {
return commandService.executeCommand(SetInlineFormatFontSizeCommand.id, params);
@@ -161,7 +161,7 @@ export const SetRangeFontFamilyCommand: ICommand = {
handler: async (accessor, params) => {
const commandService = accessor.get(ICommandService);
const contextService = accessor.get(IContextService);
- const isCellEditorFocus = contextService.getContextValue(FOCUSING_EDITOR);
+ const isCellEditorFocus = contextService.getContextValue(EDITOR_ACTIVATED);
if (isCellEditorFocus) {
return commandService.executeCommand(SetInlineFormatFontFamilyCommand.id, params);
@@ -177,7 +177,7 @@ export const SetRangeTextColorCommand: ICommand = {
handler: async (accessor, params) => {
const commandService = accessor.get(ICommandService);
const contextService = accessor.get(IContextService);
- const isCellEditorFocus = contextService.getContextValue(FOCUSING_EDITOR);
+ const isCellEditorFocus = contextService.getContextValue(EDITOR_ACTIVATED);
if (isCellEditorFocus) {
return commandService.executeCommand(SetInlineFormatTextColorCommand.id, params);
diff --git a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts
index 3dac2bdaaa..4f8d9aeb82 100644
--- a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts
@@ -20,7 +20,7 @@ import {
Direction,
Disposable,
DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
- FOCUSING_EDITOR,
+ EDITOR_ACTIVATED,
FOCUSING_EDITOR_BUT_HIDDEN,
FOCUSING_EDITOR_INPUT_FORMULA,
FOCUSING_FORMULA_EDITOR,
@@ -245,7 +245,7 @@ export class EndEditController extends Disposable {
private _exitInput(param: IEditorBridgeServiceVisibleParam) {
this._contextService.setContextValue(FOCUSING_EDITOR_INPUT_FORMULA, false);
- this._contextService.setContextValue(FOCUSING_EDITOR, false);
+ this._contextService.setContextValue(EDITOR_ACTIVATED, false);
this._contextService.setContextValue(FOCUSING_EDITOR_BUT_HIDDEN, false);
this._contextService.setContextValue(FOCUSING_FORMULA_EDITOR, false);
diff --git a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts
index e640f233a1..ec49923426 100644
--- a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts
@@ -18,7 +18,7 @@ import type { ICommandInfo, IParagraph, ITextRun, Nullable } from '@univerjs/cor
import {
DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
- FOCUSING_EDITOR,
+ EDITOR_ACTIVATED,
FOCUSING_EDITOR_BUT_HIDDEN,
FOCUSING_FORMULA_EDITOR,
HorizontalAlign,
@@ -109,7 +109,7 @@ export class FormulaEditorController extends RxDisposable {
this._formulaEditorManagerService.fxBtnClick$.pipe(takeUntil(this.dispose$)).subscribe(() => {
const isFocusButHidden =
this._contextService.getContextValue(FOCUSING_EDITOR_BUT_HIDDEN) &&
- !this._contextService.getContextValue(FOCUSING_EDITOR);
+ !this._contextService.getContextValue(EDITOR_ACTIVATED);
if (isFocusButHidden) {
this._univerInstanceService.setCurrentUniverDocInstance(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
diff --git a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts
index fb028682c8..9693ab9f6d 100644
--- a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts
@@ -20,7 +20,7 @@ import {
Disposable,
DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
- FOCUSING_EDITOR,
+ EDITOR_ACTIVATED,
FOCUSING_EDITOR_BUT_HIDDEN,
FOCUSING_FORMULA_EDITOR,
FOCUSING_SHEET,
@@ -493,7 +493,7 @@ export class StartEditController extends Disposable {
const { document, scene } = editorObject;
- this._contextService.setContextValue(FOCUSING_EDITOR, true);
+ this._contextService.setContextValue(EDITOR_ACTIVATED, true);
const { documentModel: documentDataModel } = documentLayoutObject;
diff --git a/packages/sheets-ui/src/controllers/menu/menu.ts b/packages/sheets-ui/src/controllers/menu/menu.ts
index bc60baa204..d5f47e61a7 100644
--- a/packages/sheets-ui/src/controllers/menu/menu.ts
+++ b/packages/sheets-ui/src/controllers/menu/menu.ts
@@ -17,7 +17,7 @@
import {
BooleanNumber,
DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
- FOCUSING_EDITOR,
+ EDITOR_ACTIVATED,
FOCUSING_SHEET,
FontItalic,
FontWeight,
@@ -169,7 +169,7 @@ export function BoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
if (
(id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) &&
- contextService.getContextValue(FOCUSING_EDITOR) &&
+ contextService.getContextValue(EDITOR_ACTIVATED) &&
contextService.getContextValue(FOCUSING_SHEET)
) {
const textRun = getFontStyleAtCursor(accessor);
@@ -224,7 +224,7 @@ export function ItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
if (
(id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) &&
- contextService.getContextValue(FOCUSING_EDITOR) &&
+ contextService.getContextValue(EDITOR_ACTIVATED) &&
contextService.getContextValue(FOCUSING_SHEET)
) {
const textRun = getFontStyleAtCursor(accessor);
@@ -278,7 +278,7 @@ export function UnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
if (
(id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) &&
- contextService.getContextValue(FOCUSING_EDITOR) &&
+ contextService.getContextValue(EDITOR_ACTIVATED) &&
contextService.getContextValue(FOCUSING_SHEET)
) {
const textRun = getFontStyleAtCursor(accessor);
@@ -332,7 +332,7 @@ export function StrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonIt
if (
(id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) &&
- contextService.getContextValue(FOCUSING_EDITOR) &&
+ contextService.getContextValue(EDITOR_ACTIVATED) &&
contextService.getContextValue(FOCUSING_SHEET)
) {
const textRun = getFontStyleAtCursor(accessor);
@@ -572,7 +572,7 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec
if (
(id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) &&
- contextService.getContextValue(FOCUSING_EDITOR) &&
+ contextService.getContextValue(EDITOR_ACTIVATED) &&
contextService.getContextValue(FOCUSING_SHEET)
) {
const textRun = getFontStyleAtCursor(accessor);
diff --git a/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts b/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts
index 77b1c5a558..edc17953c8 100644
--- a/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts
+++ b/packages/sheets-ui/src/controllers/shortcuts/editor.shortcut.ts
@@ -25,10 +25,10 @@ import {
} from '../../commands/operations/cell-edit.operation';
import {
whenEditorActivated,
- whenEditorActivatedIsVisible,
whenEditorDidNotInputFormulaActivated,
- whenEditorFocusIsHidden,
whenFormulaEditorFocused,
+ whenSheetEditorActivated,
+ whenSheetEditorFocused,
} from './utils';
export const ARROW_SELECTION_KEYCODE_LIST = [
@@ -101,7 +101,7 @@ export const EditorCursorEscShortcut: IShortcutItem = {
binding: KeyCode.ESC,
description: 'shortcut.sheet.abort-editing',
group: '4_sheet-edit',
- preconditions: (contextService) => whenEditorActivated(contextService),
+ preconditions: (contextService) => whenSheetEditorActivated(contextService),
staticParameters: {
visible: false,
eventType: DeviceInputEventType.Keyboard,
@@ -113,14 +113,13 @@ export const EditorBreakLineShortcut: IShortcutItem = {
id: BreakLineCommand.id,
description: 'shortcut.sheet.break-line',
group: '4_sheet-edit',
- preconditions: (contextService) => whenEditorActivated(contextService),
+ preconditions: (contextService) => whenSheetEditorActivated(contextService),
binding: KeyCode.ENTER | MetaKeys.ALT,
};
export const EditorDeleteLeftShortcut: IShortcutItem = {
id: DeleteLeftCommand.id,
- preconditions: (contextService) =>
- whenEditorActivatedIsVisible(contextService) || whenFormulaEditorFocused(contextService),
+ preconditions: (contextService) => whenEditorActivated(contextService) || whenFormulaEditorFocused(contextService),
binding: KeyCode.BACKSPACE,
};
@@ -129,7 +128,7 @@ export const EditorDeleteLeftShortcutInActive: IShortcutItem = {
description: 'shortcut.sheet.delete-and-start-editing',
group: '4_sheet-edit',
preconditions: (contextService) =>
- whenEditorFocusIsHidden(contextService) && !whenFormulaEditorFocused(contextService),
+ whenSheetEditorFocused(contextService) && !whenFormulaEditorFocused(contextService),
binding: KeyCode.BACKSPACE,
staticParameters: {
visible: true,
diff --git a/packages/sheets-ui/src/controllers/shortcuts/operation.shortcut.ts b/packages/sheets-ui/src/controllers/shortcuts/operation.shortcut.ts
index 0bbc938712..023f0278c9 100644
--- a/packages/sheets-ui/src/controllers/shortcuts/operation.shortcut.ts
+++ b/packages/sheets-ui/src/controllers/shortcuts/operation.shortcut.ts
@@ -18,32 +18,32 @@ import { SetColHiddenCommand, SetRowHiddenCommand } from '@univerjs/sheets';
import type { IShortcutItem } from '@univerjs/ui';
import { KeyCode, MetaKeys } from '@univerjs/ui';
-import { whenEditorNotActivated } from './utils';
+import { whenSheetEditorFocused } from './utils';
// export const SetUndoShortcutItem: IShortcutItem = {
// id: UndoCommand.id,
// // when focusing on any other input tag do not trigger this shortcut
-// preconditions: (contextService) => whenEditorNotActivated(contextService),
+// preconditions: (contextService) => whenSheetEditorFocused(contextService),
// binding: KeyCode.Z | MetaKeys.CTRL_COMMAND,
// };
// export const SetRedoShortcutItem: IShortcutItem = {
// id: RedoCommand.id,
// // when focusing on any other input tag do not trigger this shortcut
-// preconditions: (contextService) => whenEditorNotActivated(contextService),
+// preconditions: (contextService) => whenSheetEditorFocused(contextService),
// binding: KeyCode.Y | MetaKeys.CTRL_COMMAND,
// };
export const SetRowHiddenShortcutItem: IShortcutItem = {
id: SetRowHiddenCommand.id,
// when focusing on any other input tag do not trigger this shortcut
- preconditions: (contextService) => whenEditorNotActivated(contextService),
+ preconditions: (contextService) => whenSheetEditorFocused(contextService),
binding: KeyCode.Digit9 | MetaKeys.CTRL_COMMAND,
};
export const SetColHiddenShortcutItem: IShortcutItem = {
id: SetColHiddenCommand.id,
// when focusing on any other input tag do not trigger this shortcut
- preconditions: (contextService) => whenEditorNotActivated(contextService),
+ preconditions: (contextService) => whenSheetEditorFocused(contextService),
binding: KeyCode.Digit0 | MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT,
};
diff --git a/packages/sheets-ui/src/controllers/shortcuts/selection.shortcut.ts b/packages/sheets-ui/src/controllers/shortcuts/selection.shortcut.ts
index 9808e7c0f4..3c463d20e1 100644
--- a/packages/sheets-ui/src/controllers/shortcuts/selection.shortcut.ts
+++ b/packages/sheets-ui/src/controllers/shortcuts/selection.shortcut.ts
@@ -31,7 +31,7 @@ import {
MoveSelectionEnterAndTabCommand,
SelectAllCommand,
} from '../../commands/commands/set-selection.command';
-import { whenEditorNotActivated } from './utils';
+import { whenSheetEditorFocused } from './utils';
export const MoveSelectionDownShortcutItem: IShortcutItem<IMoveSelectionCommandParams> = {
id: MoveSelectionCommand.id,
@@ -39,7 +39,7 @@ export const MoveSelectionDownShortcutItem: IShortcutItem<IMoveSelectionCommandP
group: '3_sheet-view',
binding: KeyCode.ARROW_DOWN,
priority: 100,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.DOWN,
},
@@ -51,7 +51,7 @@ export const MoveSelectionUpShortcutItem: IShortcutItem<IMoveSelectionCommandPar
group: '3_sheet-view',
binding: KeyCode.ARROW_UP,
priority: 100,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.UP,
},
@@ -63,7 +63,7 @@ export const MoveSelectionLeftShortcutItem: IShortcutItem<IMoveSelectionCommandP
group: '3_sheet-view',
binding: KeyCode.ARROW_LEFT,
priority: 100,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.LEFT,
},
@@ -75,7 +75,7 @@ export const MoveSelectionRightShortcutItem: IShortcutItem<IMoveSelectionCommand
group: '3_sheet-view',
binding: KeyCode.ARROW_RIGHT,
priority: 100,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.RIGHT,
},
@@ -87,7 +87,7 @@ export const MoveSelectionTabShortcutItem: IShortcutItem<IMoveSelectionEnterAndT
group: '3_sheet-view',
binding: KeyCode.TAB,
priority: 100,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.RIGHT,
keycode: KeyCode.TAB,
@@ -100,7 +100,7 @@ export const MoveSelectionTabLeftShortcutItem: IShortcutItem<IMoveSelectionEnter
group: '3_sheet-view',
binding: KeyCode.TAB | MetaKeys.SHIFT,
priority: 100,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.LEFT,
keycode: KeyCode.TAB,
@@ -113,7 +113,7 @@ export const MoveSelectionEnterShortcutItem: IShortcutItem<IMoveSelectionEnterAn
group: '3_sheet-view',
binding: KeyCode.ENTER,
priority: 100,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.DOWN,
keycode: KeyCode.ENTER,
@@ -126,7 +126,7 @@ export const MoveSelectionEnterUpShortcutItem: IShortcutItem<IMoveSelectionEnter
group: '3_sheet-view',
binding: KeyCode.ENTER | MetaKeys.SHIFT,
priority: 100,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.UP,
keycode: KeyCode.ENTER,
@@ -139,7 +139,7 @@ export const MoveSelectionEnterUpShortcutItem: IShortcutItem<IMoveSelectionEnter
// group: '3_sheet-view',
// binding: KeyCode.TAB | MetaKeys.SHIFT,
// priority: 100,
-// preconditions: whenEditorNotActivated,
+// preconditions: whenSheetEditorFocused,
// staticParameters: {
// direction: Direction.LEFT,
// },
@@ -152,7 +152,7 @@ export const MoveSelectionEndDownShortcutItem: IShortcutItem<IMoveSelectionComma
description: 'shortcut.sheet.select-below-value-cell',
group: '3_sheet-view',
binding: KeyCode.ARROW_DOWN | MetaKeys.CTRL_COMMAND,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.DOWN,
jumpOver: JumpOver.moveGap,
@@ -164,7 +164,7 @@ export const MoveSelectionEndUpShortcutItem: IShortcutItem<IMoveSelectionCommand
description: 'shortcut.sheet.select-up-value-cell',
group: '3_sheet-view',
binding: KeyCode.ARROW_UP | MetaKeys.CTRL_COMMAND,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.UP,
jumpOver: JumpOver.moveGap,
@@ -176,7 +176,7 @@ export const MoveSelectionEndLeftShortcutItem: IShortcutItem<IMoveSelectionComma
description: 'shortcut.sheet.select-left-value-cell',
group: '3_sheet-view',
binding: KeyCode.ARROW_LEFT | MetaKeys.CTRL_COMMAND,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.LEFT,
jumpOver: JumpOver.moveGap,
@@ -188,7 +188,7 @@ export const MoveSelectionEndRightShortcutItem: IShortcutItem<IMoveSelectionComm
description: 'shortcut.sheet.select-right-value-cell',
group: '3_sheet-view',
binding: KeyCode.ARROW_RIGHT | MetaKeys.CTRL_COMMAND,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.RIGHT,
jumpOver: JumpOver.moveGap,
@@ -200,7 +200,7 @@ export const ExpandSelectionDownShortcutItem: IShortcutItem<IExpandSelectionComm
description: 'shortcut.sheet.expand-selection-down',
group: '3_sheet-view',
binding: KeyCode.ARROW_DOWN | MetaKeys.SHIFT,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.DOWN,
},
@@ -211,7 +211,7 @@ export const ExpandSelectionUpShortcutItem: IShortcutItem<IExpandSelectionComman
description: 'shortcut.sheet.expand-selection-up',
group: '3_sheet-view',
binding: KeyCode.ARROW_UP | MetaKeys.SHIFT,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.UP,
},
@@ -222,7 +222,7 @@ export const ExpandSelectionLeftShortcutItem: IShortcutItem<IExpandSelectionComm
description: 'shortcut.sheet.expand-selection-left',
group: '3_sheet-view',
binding: KeyCode.ARROW_LEFT | MetaKeys.SHIFT,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.LEFT,
},
@@ -233,7 +233,7 @@ export const ExpandSelectionRightShortcutItem: IShortcutItem<IExpandSelectionCom
description: 'shortcut.sheet.expand-selection-right',
group: '3_sheet-view',
binding: KeyCode.ARROW_RIGHT | MetaKeys.SHIFT,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.RIGHT,
},
@@ -246,7 +246,7 @@ export const ExpandSelectionEndDownShortcutItem: IShortcutItem<IExpandSelectionC
description: 'shortcut.sheet.expand-selection-to-below-gap',
group: '3_sheet-view',
binding: KeyCode.ARROW_DOWN | MetaKeys.SHIFT | MetaKeys.CTRL_COMMAND,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.DOWN,
jumpOver: JumpOver.moveGap,
@@ -258,7 +258,7 @@ export const ExpandSelectionEndUpShortcutItem: IShortcutItem<IExpandSelectionCom
description: 'shortcut.sheet.expand-selection-to-up-gap',
group: '3_sheet-view',
binding: KeyCode.ARROW_UP | MetaKeys.SHIFT | MetaKeys.CTRL_COMMAND,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.UP,
jumpOver: JumpOver.moveGap,
@@ -270,7 +270,7 @@ export const ExpandSelectionEndLeftShortcutItem: IShortcutItem<IExpandSelectionC
description: 'shortcut.sheet.expand-selection-to-left-gap',
group: '3_sheet-view',
binding: KeyCode.ARROW_LEFT | MetaKeys.SHIFT | MetaKeys.CTRL_COMMAND,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.LEFT,
jumpOver: JumpOver.moveGap,
@@ -282,7 +282,7 @@ export const ExpandSelectionEndRightShortcutItem: IShortcutItem<IExpandSelection
description: 'shortcut.sheet.expand-selection-to-right-gap',
group: '3_sheet-view',
binding: KeyCode.ARROW_RIGHT | MetaKeys.SHIFT | MetaKeys.CTRL_COMMAND,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
direction: Direction.RIGHT,
jumpOver: JumpOver.moveGap,
@@ -294,7 +294,7 @@ export const SelectAllShortcutItem: IShortcutItem<ISelectAllCommandParams> = {
description: 'shortcut.sheet.select-all',
group: '3_sheet-view',
binding: KeyCode.A | MetaKeys.CTRL_COMMAND,
- preconditions: whenEditorNotActivated,
+ preconditions: whenSheetEditorFocused,
staticParameters: {
expandToGapFirst: true,
loop: true,
diff --git a/packages/sheets-ui/src/controllers/shortcuts/style.shortcut.ts b/packages/sheets-ui/src/controllers/shortcuts/style.shortcut.ts
index 1a0afed1e4..5a1244539c 100644
--- a/packages/sheets-ui/src/controllers/shortcuts/style.shortcut.ts
+++ b/packages/sheets-ui/src/controllers/shortcuts/style.shortcut.ts
@@ -23,13 +23,13 @@ import {
SetRangeStrickThroughCommand,
SetRangeUnderlineCommand,
} from '../../commands/commands/inline-format.command';
-import { whenEditorNotActivated } from './utils';
+import { whenSheetEditorFocused } from './utils';
export const SetBoldShortcutItem: IShortcutItem = {
id: SetRangeBoldCommand.id,
description: 'shortcut.sheet.set-bold',
group: '4_sheet-edit',
- preconditions: (contextService) => whenEditorNotActivated(contextService),
+ preconditions: (contextService) => whenSheetEditorFocused(contextService),
binding: KeyCode.B | MetaKeys.CTRL_COMMAND,
};
@@ -37,7 +37,7 @@ export const SetItalicShortcutItem: IShortcutItem = {
id: SetRangeItalicCommand.id,
description: 'shortcut.sheet.set-italic',
group: '4_sheet-edit',
- preconditions: (contextService) => whenEditorNotActivated(contextService),
+ preconditions: (contextService) => whenSheetEditorFocused(contextService),
binding: KeyCode.I | MetaKeys.CTRL_COMMAND,
};
@@ -45,7 +45,7 @@ export const SetUnderlineShortcutItem: IShortcutItem = {
id: SetRangeUnderlineCommand.id,
description: 'shortcut.sheet.set-underline',
group: '4_sheet-edit',
- preconditions: (contextService) => whenEditorNotActivated(contextService),
+ preconditions: (contextService) => whenSheetEditorFocused(contextService),
binding: KeyCode.U | MetaKeys.CTRL_COMMAND,
};
@@ -53,6 +53,6 @@ export const SetStrikeThroughShortcutItem: IShortcutItem = {
id: SetRangeStrickThroughCommand.id,
description: 'shortcut.sheet.set-strike-through',
group: '4_sheet-edit',
- preconditions: (contextService) => whenEditorNotActivated(contextService),
+ preconditions: (contextService) => whenSheetEditorFocused(contextService),
binding: KeyCode.X | MetaKeys.SHIFT | MetaKeys.CTRL_COMMAND,
};
diff --git a/packages/sheets-ui/src/controllers/shortcuts/utils.ts b/packages/sheets-ui/src/controllers/shortcuts/utils.ts
index 3ed0022abc..b2a8f060c9 100644
--- a/packages/sheets-ui/src/controllers/shortcuts/utils.ts
+++ b/packages/sheets-ui/src/controllers/shortcuts/utils.ts
@@ -16,57 +16,75 @@
import type { IContextService } from '@univerjs/core';
import {
- FOCUSING_EDITOR,
- FOCUSING_EDITOR_BUT_HIDDEN,
+ EDITOR_ACTIVATED,
FOCUSING_EDITOR_INPUT_FORMULA,
FOCUSING_FORMULA_EDITOR,
FOCUSING_SHEET,
+ FOCUSING_UNIVER_EDITOR,
} from '@univerjs/core';
-export function whenEditorNotActivated(contextService: IContextService) {
- return contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_EDITOR);
-}
-
-export function whenEditorActivated(contextService: IContextService) {
- return contextService.getContextValue(FOCUSING_SHEET) && contextService.getContextValue(FOCUSING_EDITOR);
-}
+// TODO@wzhudev: some definition here is pretty ambiguous and not very consistent. Rename them.
-export function whenEditorFocusIsHidden(contextService: IContextService) {
+/**
+ * Requires the currently focused unit to be Workbook and the sheet editor is focused but not activated.
+ * @param contextService
+ * @returns
+ */
+export function whenSheetEditorFocused(contextService: IContextService) {
return (
- contextService.getContextValue(FOCUSING_EDITOR_BUT_HIDDEN) && !contextService.getContextValue(FOCUSING_EDITOR)
+ contextService.getContextValue(FOCUSING_SHEET) &&
+ contextService.getContextValue(FOCUSING_UNIVER_EDITOR) &&
+ !contextService.getContextValue(EDITOR_ACTIVATED)
);
}
-export function whenEditorActivatedIsVisible(contextService: IContextService) {
+/**
+ * Requires the currently focused unit to be Workbook and the sheet editor is activated.
+ * @param contextService
+ * @returns
+ */
+export function whenSheetEditorActivated(contextService: IContextService) {
return (
- contextService.getContextValue(FOCUSING_EDITOR) && contextService.getContextValue(FOCUSING_EDITOR_BUT_HIDDEN)
+ contextService.getContextValue(FOCUSING_SHEET) &&
+ contextService.getContextValue(FOCUSING_UNIVER_EDITOR) &&
+ contextService.getContextValue(EDITOR_ACTIVATED)
);
}
-export function whenFormulaEditorFocused(contextService: IContextService) {
- return contextService.getContextValue(FOCUSING_FORMULA_EDITOR);
+export function whenEditorActivated(contextService: IContextService) {
+ return contextService.getContextValue(EDITOR_ACTIVATED);
}
-export function whenEditorInputFormulaActivated(contextService: IContextService) {
+/**
+ * Requires the currently focused editor is a formula editor.
+ * @param contextService
+ * @returns
+ */
+export function whenFormulaEditorFocused(contextService: IContextService) {
return (
- contextService.getContextValue(FOCUSING_SHEET) &&
- contextService.getContextValue(FOCUSING_EDITOR) &&
- contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA)
+ contextService.getContextValue(FOCUSING_FORMULA_EDITOR) &&
+ contextService.getContextValue(FOCUSING_UNIVER_EDITOR)
);
}
-export function whenEditorDidNotInputFormulaActivated(contextService: IContextService) {
+/**
+ * Requires the currently focused editor is a formula editor, and it is activated.
+ * @param contextService
+ * @returns
+ */
+export function whenFormulaEditorActivated(contextService: IContextService) {
return (
contextService.getContextValue(FOCUSING_SHEET) &&
- contextService.getContextValue(FOCUSING_EDITOR) &&
- !contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA)
+ contextService.getContextValue(EDITOR_ACTIVATED) &&
+ contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA) &&
+ contextService.getContextValue(FOCUSING_UNIVER_EDITOR)
);
}
-export function whenEditorNotActivatedOrFormulaActivated(contextService: IContextService) {
+export function whenEditorDidNotInputFormulaActivated(contextService: IContextService) {
return (
contextService.getContextValue(FOCUSING_SHEET) &&
- (!contextService.getContextValue(FOCUSING_EDITOR) ||
- contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA))
+ contextService.getContextValue(EDITOR_ACTIVATED) &&
+ !contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA)
);
}
diff --git a/packages/sheets-ui/src/controllers/shortcuts/value.shortcut.ts b/packages/sheets-ui/src/controllers/shortcuts/value.shortcut.ts
index de5c8d84dc..c874382109 100644
--- a/packages/sheets-ui/src/controllers/shortcuts/value.shortcut.ts
+++ b/packages/sheets-ui/src/controllers/shortcuts/value.shortcut.ts
@@ -18,12 +18,12 @@ import { ClearSelectionContentCommand } from '@univerjs/sheets';
import type { IShortcutItem } from '@univerjs/ui';
import { KeyCode } from '@univerjs/ui';
-import { whenEditorNotActivated } from './utils';
+import { whenSheetEditorFocused } from './utils';
export const ClearSelectionValueShortcutItem: IShortcutItem = {
id: ClearSelectionContentCommand.id,
// when focusing on any other input tag do not trigger this shortcut
- preconditions: (contextService) => whenEditorNotActivated(contextService),
+ preconditions: (contextService) => whenSheetEditorFocused(contextService),
binding: KeyCode.DELETE,
mac: KeyCode.BACKSPACE,
};
diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.ts
index af7250796f..4038f9c06e 100644
--- a/packages/sheets-ui/src/index.ts
+++ b/packages/sheets-ui/src/index.ts
@@ -28,7 +28,7 @@ export { VIEWPORT_KEY } from './common/keys';
export { RangeSelector } from './components/range-selector/RangeSelector';
export { AutoFillController } from './controllers/auto-fill.controller';
export { PASTE_SPECIAL_MENU_ID } from './controllers/menu/menu';
-export { whenEditorInputFormulaActivated } from './controllers/shortcuts/utils';
+export { whenFormulaEditorActivated } from './controllers/shortcuts/utils';
export {
getCoordByCell,
getCoordByOffset,
diff --git a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts b/packages/sheets/src/commands/mutations/set-range-values.mutation.ts
index 89598ece63..210f0fef56 100644
--- a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts
+++ b/packages/sheets/src/commands/mutations/set-range-values.mutation.ts
@@ -17,7 +17,7 @@
import type {
IBorderData,
ICellData,
- ICellV,
+ CellValue,
ICopyToOptionsData,
IDocumentData,
IKeyValue,
@@ -232,7 +232,7 @@ export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, bo
},
};
-function checkCellValueType(v: Nullable<ICellV>): Nullable<CellValueType> {
+function checkCellValueType(v: Nullable<CellValue>): Nullable<CellValueType> {
if (v === null) return null;
if (typeof v === 'string') {
diff --git a/packages/sheets-find/src/services/find.service.ts b/packages/ui/src/components/hooks/locale.ts
similarity index 64%
rename from packages/sheets-find/src/services/find.service.ts
rename to packages/ui/src/components/hooks/locale.ts
index 234e87398f..37f140b6b3 100644
--- a/packages/sheets-find/src/services/find.service.ts
+++ b/packages/ui/src/components/hooks/locale.ts
@@ -14,14 +14,13 @@
* limitations under the License.
*/
-import { Inject } from '@wendellhu/redi';
+import { LocaleService } from '@univerjs/core';
+import { useDependency } from '@wendellhu/redi/react-bindings';
-import { FindModalController } from '../controllers/find-modal-controller';
-
-export class FindService {
- constructor(@Inject(FindModalController) private _findModalController: FindModalController) {}
+export function useLocaleService() {
+ return useDependency(LocaleService);
+}
- showModal(show: boolean) {
- this._findModalController.showModal(show);
- }
+export function t(localeService: LocaleService, key: string, ...args: Array<number | string>): string {
+ return localeService.t(key);
}
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index d680d7426c..cb40c453c7 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -18,6 +18,7 @@ export * from './BaseComponent';
export * from './common';
export { getMenuHiddenObservable } from './common/menu-hidden-observable';
export * from './components';
+export { t } from './components/hooks/locale';
export { useObservable } from './components/hooks/observable';
export {
CopyShortcutItem,
@@ -47,6 +48,7 @@ export {
} from './services/contextmenu/contextmenu.service';
export { DesktopDialogService } from './services/dialog/desktop-dialog.service';
export { IDialogService } from './services/dialog/dialog.service';
+export { IFocusService } from './services/focus/focus.service';
export { LayoutService } from './services/layout/layout.service';
export {
type ICustomComponentProps,
diff --git a/packages/ui/src/services/focus/focus.service.ts b/packages/ui/src/services/focus/focus.service.ts
index d0ef2db67e..430fea2364 100644
--- a/packages/ui/src/services/focus/focus.service.ts
+++ b/packages/ui/src/services/focus/focus.service.ts
@@ -14,19 +14,27 @@
* limitations under the License.
*/
-import type { ContextService } from '@univerjs/core';
-import { Disposable, IContextService, LifecycleStages, OnLifecycle, toDisposable } from '@univerjs/core';
+import type { ContextService, Nullable } from '@univerjs/core';
+import {
+ Disposable,
+ FOCUSING_UNIVER_EDITOR,
+ IContextService,
+ ILogService,
+ LifecycleStages,
+ OnLifecycle,
+ toDisposable,
+} from '@univerjs/core';
import { createIdentifier } from '@wendellhu/redi';
import { fromEvent } from 'rxjs';
-import type { Nullable } from 'vitest';
/**
* FocusService manages focusing state of the Univer application instance.
*/
export const IFocusService = createIdentifier<IFocusService>('univer.focus-service');
-
export interface IFocusService {
readonly isFocused: boolean;
+
+ forceFocus(): void;
setContainerElement(container: HTMLElement): void;
}
@@ -42,11 +50,17 @@ export class DesktopFocusService extends Disposable implements IFocusService {
return this._isUniverFocused;
}
- constructor(@IContextService private readonly _contextService: ContextService) {
+ constructor(
+ @IContextService private readonly _contextService: ContextService,
+ @ILogService private readonly _logService: ILogService
+ ) {
super();
this._initFocusListener();
- // TODO: we may call context service to set context values
+ this._initEditorStatus();
+
+ // @ts-ignore
+ window._contextService = this;
}
override dispose(): void {
@@ -59,6 +73,8 @@ export class DesktopFocusService extends Disposable implements IFocusService {
this._containerElement = container;
}
+ forceFocus(): void {}
+
private _initFocusListener(): void {
this.disposeWithMe(
toDisposable(
@@ -70,16 +86,19 @@ export class DesktopFocusService extends Disposable implements IFocusService {
}
this._contextService.setContextValue(FOCUSING_UNIVER, this._isUniverFocused);
+ this._contextService.setContextValue(
+ FOCUSING_UNIVER_EDITOR,
+ (event.target as HTMLElement).classList.contains('univer-editor')
+ );
})
)
);
+ }
- // this.disposeWithMe(
- // toDisposable(
- // fromEvent(window, 'focusout').subscribe((element) => {
- // console.log('focusing out element', element.target);
- // })
- // )
- // );
+ private _initEditorStatus(): void {
+ this._contextService.setContextValue(
+ FOCUSING_UNIVER_EDITOR,
+ !!document.activeElement?.classList.contains('univer-editor')
+ );
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 89f7a519f7..9c38c8e68b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -164,6 +164,9 @@ importers:
'@univerjs/sheets':
specifier: workspace:*
version: link:../packages/sheets
+ '@univerjs/sheets-find-replace':
+ specifier: workspace:*
+ version: link:../packages/sheets-find-replace
'@univerjs/sheets-formula':
specifier: workspace:*
version: link:../packages/sheets-formula
@@ -328,6 +331,9 @@ importers:
react-transition-group:
specifier: ^4.4.5
+ rxjs:
+ specifier: ^7.8.1
+ version: 7.8.1
devDependencies:
'@testing-library/react':
specifier: ^14.1.2
@@ -632,12 +638,24 @@ importers:
'@univerjs/core':
specifier: workspace:*
version: link:../core
+ '@univerjs/design':
+ specifier: workspace:*
+ version: link:../design
+ '@univerjs/icons':
+ specifier: ^0.1.25
'@univerjs/ui':
specifier: workspace:*
version: link:../ui
'@wendellhu/redi':
specifier: ^0.12.13
version: 0.12.13
+ react:
+ specifier: ^18.2.0
+ version: 18.2.0
+ react-dom:
+ specifier: ^18.2.0
+ version: 18.2.0([email protected])
rxjs:
specifier: ^7.8.1
version: 7.8.1
@@ -809,7 +827,7 @@ importers:
specifier: ^1.1.1
- packages/sheets-find:
+ packages/sheets-find-replace:
dependencies:
'@univerjs/core':
specifier: workspace:*
@@ -820,6 +838,9 @@ importers:
'@univerjs/engine-render':
specifier: workspace:*
version: link:../engine-render
+ '@univerjs/find-replace':
+ specifier: workspace:*
+ version: link:../find-replace
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
diff --git a/tsconfig.json b/tsconfig.json
index 6b7b87cc5e..067b0c6ec0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -65,7 +65,7 @@
"path": "./packages/sheets"
},
{
- "path": "./packages/sheets-find"
+ "path": "./packages/sheets-find-replace"
},
{
"path": "./packages/sheets-formula"