Skip to content

Commit

Permalink
refactor: data-validation model (#3383)
Browse files Browse the repository at this point in the history
  • Loading branch information
weird94 authored Sep 12, 2024
1 parent d016318 commit f61277f
Show file tree
Hide file tree
Showing 213 changed files with 1,782 additions and 1,664 deletions.
2 changes: 2 additions & 0 deletions examples/src/data/sheets/demo/default-workbook-data-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ const dataValidation: IDataValidationRule[] = [
startColumn: 0,
endColumn: 5,
}],
formula1: 'TRUE',
formula2: 'FALSE',
},
{
uid: 'xxx-3',
Expand Down
6 changes: 3 additions & 3 deletions examples/src/sheets/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

import type { Plugin, PluginCtor } from '@univerjs/core';
import { UniverActionRecorderPlugin } from '@univerjs/action-recorder';
import { UniverSheetsCrosshairHighlightPlugin } from '@univerjs/sheets-crosshair-highlight';
import { UniverSheetsFilterUIPlugin } from '@univerjs/sheets-filter-ui';
import { UniverSheetsFindReplacePlugin } from '@univerjs/sheets-find-replace';
import { UniverSheetsCrosshairHighlightPlugin } from '@univerjs/sheets-crosshair-highlight';
import { UniverUniscriptPlugin } from '@univerjs/uniscript';
import { UniverActionRecorderPlugin } from '@univerjs/action-recorder';
import type { Plugin, PluginCtor } from '@univerjs/core';

export default function getLazyPlugins(): Array<[PluginCtor<Plugin>] | [PluginCtor<Plugin>, unknown]> {
return [
Expand Down
44 changes: 24 additions & 20 deletions examples/src/sheets/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@
* limitations under the License.
*/

import type { Nullable } from '@univerjs/core';
import { LocaleType, LogLevel, Univer, UniverInstanceType, UserManagerService } from '@univerjs/core';
import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverDebuggerPlugin } from '@univerjs/debugger';
import { defaultTheme } from '@univerjs/design';
import { UniverUIPlugin } from '@univerjs/ui';
import { UniverDocsPlugin } from '@univerjs/docs';
import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
import { FUniver } from '@univerjs/facade';
import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsPlugin } from '@univerjs/sheets';
import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';
import { UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting';
import { UniverSheetsConditionalFormattingUIPlugin } from '@univerjs/sheets-conditional-formatting-ui';

import { UniverDebuggerPlugin } from '@univerjs/debugger';
import { UniverSheetsHyperLinkUIPlugin } from '@univerjs/sheets-hyper-link-ui';
import type { IThreadCommentMentionDataSource } from '@univerjs/thread-comment-ui';
import { IThreadCommentMentionDataService, UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';
import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment';
import type { IUniverRPCMainThreadConfig } from '@univerjs/rpc';
import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';
import { UniverSheetsDataValidationPlugin } from '@univerjs/sheets-data-validation';
import { FUniver } from '@univerjs/facade';
import { UniverSheetsZenEditorPlugin } from '@univerjs/sheets-zen-editor';
import { UniverSheetsSortUIPlugin } from '@univerjs/sheets-sort-ui';
import { UniverSheetsDrawingUIPlugin } from '@univerjs/sheets-drawing-ui';
import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { enUS, ruRU, viVN, zhCN, zhTW } from '../locales';
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
import { UniverSheetsHyperLinkUIPlugin } from '@univerjs/sheets-hyper-link-ui';
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';
import { UniverSheetsSortUIPlugin } from '@univerjs/sheets-sort-ui';
import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment';
import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';
import { UniverSheetsZenEditorPlugin } from '@univerjs/sheets-zen-editor';
import { IThreadCommentMentionDataService, UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';
import { UniverUIPlugin } from '@univerjs/ui';
import type { Nullable } from '@univerjs/core';
import type { IUniverRPCMainThreadConfig } from '@univerjs/rpc';
import type { IThreadCommentMentionDataSource } from '@univerjs/thread-comment-ui';
import { DEFAULT_WORKBOOK_DATA_DEMO } from '../data/sheets/demo/default-workbook-data-demo';
import { enUS, ruRU, viVN, zhCN, zhTW } from '../locales';

/* eslint-disable-next-line node/prefer-global/process */
const IS_E2E: boolean = !!process.env.IS_E2E;
Expand Down Expand Up @@ -84,8 +84,12 @@ univer.registerPlugin(UniverSheetsFormulaPlugin, { notExecuteFormula: true });
univer.registerPlugin(UniverSheetsFilterPlugin);
// hyperlink
univer.registerPlugin(UniverSheetsHyperLinkUIPlugin);
// data validation
univer.registerPlugin(UniverSheetsDataValidationPlugin);

// mock lazy load data validation
setTimeout(() => {
univer.registerPlugin(UniverSheetsDataValidationPlugin);
}, 500);

// sort
univer.registerPlugin(UniverSheetsSortUIPlugin);
// condition formatting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

import { CommandType, type ICommand } from '@univerjs/core';
import { IMessageService } from '@univerjs/ui';
import { MessageType } from '@univerjs/design';
import { IMessageService } from '@univerjs/ui';
import { ActionReplayService } from '../../services/replay.service';

export const ReplayLocalRecordCommand: ICommand = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import type { IOperation } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
import type { IOperation } from '@univerjs/core';
import { ActionRecorderService } from '../../services/action-recorder.service';

export const OpenRecordPanelOperation: IOperation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
*/

import { connectInjector, Disposable, ICommandService, Inject, Injector } from '@univerjs/core';
import { BuiltInUIPart, ComponentManager, IMenuManagerService, IUIPartsService } from '@univerjs/ui';
import { RecordSingle } from '@univerjs/icons';
import { CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, InsertColAfterCommand, InsertColBeforeCommand, InsertRowAfterCommand, InsertRowBeforeCommand, InsertSheetCommand, RemoveSheetCommand, SetFrozenCancelCommand, SetFrozenCommand, SetHorizontalTextAlignCommand, SetOverlineCommand, SetRangeProtectionCommand, SetRangeValuesCommand, SetSelectionsOperation, SetStrikeThroughCommand, SetStyleCommand, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetVerticalTextAlignCommand, SetWorksheetActivateCommand, SetWorksheetActiveOperation } from '@univerjs/sheets';
import { SetRangeBoldCommand, SetRangeFontFamilyCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SheetCopyCommand, SheetCutCommand, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand } from '@univerjs/sheets-ui';
import { RemoveSheetFilterCommand, SetSheetFilterRangeCommand, SetSheetsFilterCriteriaCommand } from '@univerjs/sheets-filter-ui';
import { RecordSingle } from '@univerjs/icons';
import { CloseRecordPanelOperation, OpenRecordPanelOperation } from '../commands/operations/operation';
import { RecorderPanel } from '../views/components/RecorderPanel';
import { SetRangeBoldCommand, SetRangeFontFamilyCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SheetCopyCommand, SheetCutCommand, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand } from '@univerjs/sheets-ui';
import { BuiltInUIPart, ComponentManager, IMenuManagerService, IUIPartsService } from '@univerjs/ui';
import { CompleteRecordingActionCommand, StartRecordingActionCommand, StopRecordingActionCommand } from '../commands/commands/record.command';
import { ActionRecorderService } from '../services/action-recorder.service';
import { ReplayLocalRecordCommand } from '../commands/commands/replay.command';
import { CloseRecordPanelOperation, OpenRecordPanelOperation } from '../commands/operations/operation';
import { ActionRecorderService } from '../services/action-recorder.service';
import { RecorderPanel } from '../views/components/RecorderPanel';
import { menuSchema } from './action-recorder.menu';

export class ActionRecorderController extends Disposable {
Expand Down
4 changes: 2 additions & 2 deletions packages-experimental/action-recorder/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import type { Dependency } from '@univerjs/core';
import { Inject, Injector, Plugin } from '@univerjs/core';
import { ActionRecorderService } from './services/action-recorder.service';
import type { Dependency } from '@univerjs/core';
import { ActionRecorderController } from './controllers/action-recorder.controller';
import { ActionRecorderService } from './services/action-recorder.service';
import { ActionReplayService } from './services/replay.service';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

import type { ICommand, ICommandInfo, IDisposable, Nullable } from '@univerjs/core';
import { CommandType, Disposable, ICommandService, ILogService } from '@univerjs/core';
import { SetSelectionsOperation } from '@univerjs/sheets';
import { ILocalFileService } from '@univerjs/ui';
import { BehaviorSubject } from 'rxjs';
import type { ICommand, ICommandInfo, IDisposable, Nullable } from '@univerjs/core';

/**
* This service is for recording commands. What commands should be recorded can be configured by other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import type { ICommandInfo } from '@univerjs/core';
import { Disposable, ICommandService, ILogService, IUniverInstanceService } from '@univerjs/core';
import { MessageType } from '@univerjs/design';
import { ILocalFileService, IMessageService } from '@univerjs/ui';
import type { ICommandInfo } from '@univerjs/core';

/**
* This service is for replaying user actions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/

import { ICommandService, useDependency } from '@univerjs/core';
import React, { useCallback } from 'react';
import { useObservable } from '@univerjs/ui';
import { Button } from '@univerjs/design';
import { RecordSingle } from '@univerjs/icons';
import { useObservable } from '@univerjs/ui';
import clsx from 'clsx';
import { ActionRecorderService } from '../../services/action-recorder.service';
import React, { useCallback } from 'react';
import { CompleteRecordingActionCommand, StartRecordingActionCommand, StopRecordingActionCommand } from '../../commands/commands/record.command';
import { CloseRecordPanelOperation } from '../../commands/operations/operation';
import { ActionRecorderService } from '../../services/action-recorder.service';
import styles from './index.module.less';

export function RecorderPanel() {
Expand Down
4 changes: 2 additions & 2 deletions packages-experimental/uni-docs-ui/src/controllers/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* limitations under the License.
*/

import type { IAccessor } from '@univerjs/core';
import { BooleanNumber, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { DocSelectionManagerService, DocSkeletonManagerService, SetTextSelectionsOperation } from '@univerjs/docs';
import { SetInlineFormatCommand } from '@univerjs/docs-ui';
import { DocumentEditArea, IRenderManagerService } from '@univerjs/engine-render';

import { getHeaderFooterMenuHiddenObservable, getMenuHiddenObservable, type IMenuButtonItem, type IMenuItem, MenuItemType } from '@univerjs/ui';

import { combineLatest, Observable } from 'rxjs';
import type { IAccessor } from '@univerjs/core';

export const DOC_ITALIC_MUTATION_ID = 'doc.command.uni-italic';
export const DOC_BOLD_MUTATION_ID = 'doc.command.uni-bold';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

import { ICommandService, IConfigService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
import { IMAGE_MENU_ID as DocsImageMenuId } from '@univerjs/docs-drawing-ui';
import { BulletListCommand, DocCreateTableOperation, DocUIController, OrderListCommand, SetInlineFormatBoldCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand } from '@univerjs/docs-ui';
import { ComponentManager, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';
import { BuiltinUniToolbarItemId, generateCloneMutation, UniToolbarService } from '@univerjs/uniui';
import { BulletListCommand, DocCreateTableOperation, DocUIController, OrderListCommand, SetInlineFormatBoldCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand } from '@univerjs/docs-ui';
import { IMAGE_MENU_ID as DocsImageMenuId } from '@univerjs/docs-drawing-ui';
import { DOC_BOLD_MUTATION_ID, DOC_ITALIC_MUTATION_ID, DOC_STRIKE_MUTATION_ID, DOC_TABLE_MUTATION_ID, DOC_UNDERLINE_MUTATION_ID } from './menu';
import { menuSchema } from './menu.schema';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

import type { ICommand, IDocumentBody, IMutationInfo } from '@univerjs/core';
import { CommandType, CustomRangeType, generateRandomId, ICommandService, LocaleService, makeCustomRangeStream, sequenceExecute } from '@univerjs/core';
import { makeSelection, replaceSelectionFactory } from '@univerjs/docs-ui';
import type { IAddDocUniFormulaMutationParams, IRemoveDocUniFormulaMutationParams, IUpdateDocUniFormulaMutationParams } from '@univerjs/uni-formula';
import { AddDocUniFormulaMutation, RemoveDocUniFormulaMutation, UpdateDocUniFormulaMutation } from '@univerjs/uni-formula';
import type { ICommand, IDocumentBody, IMutationInfo } from '@univerjs/core';
import type { IAddDocUniFormulaMutationParams, IRemoveDocUniFormulaMutationParams, IUpdateDocUniFormulaMutationParams } from '@univerjs/uni-formula';

export interface IAddDocUniFormulaCommandParams {
unitId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import type { ICommand, IDocumentBody } from '@univerjs/core';
import { CommandType, CustomRangeType, generateRandomId, ICommandService, LocaleService, makeCustomRangeStream } from '@univerjs/core';
import { SLIDE_EDITOR_ID } from '@univerjs/slides-ui';
import { makeSelection, replaceSelectionFactory } from '@univerjs/docs-ui';
import { SLIDE_EDITOR_ID } from '@univerjs/slides-ui';
import type { ICommand, IDocumentBody } from '@univerjs/core';
import { SlideUIFormulaCacheService } from '../../services/slide-ui-formula-cache.service';

export interface IAddSlideUniFormulaCommandParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
* limitations under the License.
*/

import type { DocumentDataModel } from '@univerjs/core';
import { CustomRangeType, Disposable, ICommandService, ILogService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
import { DocSelectionManagerService } from '@univerjs/docs';
import { IEditorService } from '@univerjs/ui';
import type { IInsertCommandParams } from '@univerjs/docs-ui';
import { DeleteLeftCommand, DocEventManagerService, InsertCommand, MoveCursorOperation } from '@univerjs/docs-ui';

import { filter, map, mergeMap } from 'rxjs';
import { IRenderManagerService } from '@univerjs/engine-render';
import { IEditorService } from '@univerjs/ui';
import { filter, map, mergeMap } from 'rxjs';

import type { DocumentDataModel } from '@univerjs/core';
import type { IInsertCommandParams } from '@univerjs/docs-ui';
import { AddDocUniFormulaCommand, RemoveDocUniFormulaCommand, UpdateDocUniFormulaCommand } from '../commands/commands/doc.command';
import type { IShowFormulaPopupOperationParams } from '../commands/operations/operation';
import { CloseFormulaPopupOperation, ShowFormulaPopupOperation } from '../commands/operations/operation';
import { UNI_FORMULA_EDITOR_ID } from '../views/components/DocFormulaPopup';
import { UniFormulaPopupService } from '../services/formula-popup.service';
import { UNI_FORMULA_EDITOR_ID } from '../views/components/DocFormulaPopup';
import type { IShowFormulaPopupOperationParams } from '../commands/operations/operation';

const FORMULA_INPUT_TRIGGER_CHAR = '=';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
*/

import { Disposable, ICommandService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
import { IEditorService } from '@univerjs/ui';
import { DocSelectionManagerService } from '@univerjs/docs';
import { InsertCommand } from '@univerjs/docs-ui';
import { ISlideEditorBridgeService } from '@univerjs/slides-ui';
import { IEditorService } from '@univerjs/ui';
import type { IInsertCommandParams } from '@univerjs/docs-ui';
import { InsertCommand } from '@univerjs/docs-ui';
import { AddSlideUniFormulaCommand } from '../commands/commands/slide.command';
import { UNI_FORMULA_EDITOR_ID } from '../views/components/DocFormulaPopup';
import { CloseFormulaPopupOperation, ShowFormulaPopupOperation } from '../commands/operations/operation';
import { UniFormulaPopupService } from '../services/formula-popup.service';
import { UNI_FORMULA_EDITOR_ID } from '../views/components/DocFormulaPopup';
import type { IShowFormulaPopupOperationParams, ISlidePopupPosition } from '../commands/operations/operation';
import { CloseFormulaPopupOperation, ShowFormulaPopupOperation } from '../commands/operations/operation';

const FORMULA_INPUT_TRIGGER_CHAR = '=';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
* limitations under the License.
*/

import type { IDisposable, Nullable } from '@univerjs/core';
import { Disposable, FORMULA_EDITOR_ACTIVATED, ICommandService, IContextService, ILogService, Inject } from '@univerjs/core';
import { DocCanvasPopManagerService, makeSelection } from '@univerjs/docs-ui';
import { BehaviorSubject, Subject } from 'rxjs';
import type { IShortcutItem } from '@univerjs/ui';
import { IShortcutService, KeyCode } from '@univerjs/ui';
import { FORMULA_PROMPT_ACTIVATED } from '@univerjs/sheets-formula';
import { IShortcutService, KeyCode } from '@univerjs/ui';
import { IUniFormulaService } from '@univerjs/uni-formula';
import type { IAddDocUniFormulaCommandParams } from '../commands/commands/doc.command';
import { BehaviorSubject, Subject } from 'rxjs';
import type { IDisposable, Nullable } from '@univerjs/core';
import type { IShortcutItem } from '@univerjs/ui';
import { AddDocUniFormulaCommand } from '../commands/commands/doc.command';
import type { IPopupPosition } from '../commands/operations/operation';
import { AddSlideUniFormulaCommand } from '../commands/commands/slide.command';
import { ConfirmFormulaPopupCommand, isSlidePosition } from '../commands/operations/operation';
import type { IAddDocUniFormulaCommandParams } from '../commands/commands/doc.command';
import type { IAddSlideUniFormulaCommandParams } from '../commands/commands/slide.command';
import { AddSlideUniFormulaCommand } from '../commands/commands/slide.command';
import type { IPopupPosition } from '../commands/operations/operation';

export const DOC_FORMULA_POPUP_KEY = 'DOC_FORMULA_POPUP' as const;

Expand Down
Loading

0 comments on commit f61277f

Please sign in to comment.