From 057fca00d4d644f0dd43740bb4ecccda0788d839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E7=86=B1?= Date: Sat, 13 Jun 2026 17:30:41 +0800 Subject: [PATCH] refactor: rename view files to PascalCase (#7083) --- package.json | 16 +- packages/design/src/helper/class-utilities.ts | 1 + packages/design/src/index.ts | 1 + .../doc-drawing-printing.controller.tsx | 4 +- .../index.tsx => DocPrintingFloatDom.tsx} | 2 +- .../__tests__/ui.controller.spec.ts | 2 +- .../src/controllers/ui.controller.ts | 4 +- .../src/services/hyper-link-popup.service.ts | 4 +- .../index.tsx => DocHyperLinkEdit.tsx} | 8 +- .../index.tsx => DocLinkPopup.tsx} | 6 +- .../controllers/doc-mention-ui.controller.ts | 2 +- .../src/services/doc-mention-popup.service.ts | 2 +- .../index.tsx => MentionEditPopup.tsx} | 6 +- .../index.tsx => MentionList.tsx} | 0 .../doc-thread-comment-ui.controller.spec.ts | 2 +- .../doc-thread-comment-ui.controller.ts | 2 +- .../index.tsx => DocThreadCommentPanel.tsx} | 16 +- .../operations/open-page-setting.operation.ts | 2 +- .../__tests__/paragraph-menu.spec.ts | 532 ----- .../src/controllers/doc-ui.controller.ts | 8 +- packages/docs-ui/src/index.ts | 2 +- packages/docs-ui/src/menu/menu.ts | 2 +- .../doc-paragraph-menu.service.spec.ts | 2 +- .../services/doc-paragraph-menu.service.ts | 2 +- packages/docs-ui/src/services/doc-zoom.ts | 2 +- .../src/services/float-menu.service.ts | 2 +- .../{side-menu/index.tsx => DocSideMenu.tsx} | 14 +- .../index.tsx => PageSettings.tsx} | 0 .../index.tsx => views/ParagraphMenu.tsx} | 55 +- .../index.tsx => RichTextEditor.tsx} | 14 +- .../index.tsx => views/SideMenu.tsx} | 0 .../src/{components => views}/const.ts | 0 .../src/{components => views}/editor/utils.ts | 0 .../float-toolbar/FloatToolbar.stories.tsx | 0 .../float-toolbar/FloatToolbar.tsx | 0 .../__tests__/FloatToolbar.spec.ts | 0 .../list-type-picker/Picker.tsx | 0 .../list-type-picker/index.ts | 0 .../paragraph-menu/component-keys.ts | 0 .../src/views/paragraph-setting/Setting.tsx | 52 +- .../side-menu/SideMenu.stories.tsx | 4 +- packages/drawing-ui/src/index.ts | 1 - .../src/controllers/cf.panel.controller.ts | 2 +- .../index.tsx => views/ColorPicker.tsx} | 0 .../ConditionFormattingPanel.tsx} | 4 +- .../ConditionalStyleEditor.tsx} | 2 +- .../preview/index.tsx => views/Preview.tsx} | 0 .../index.tsx => views/panel/RuleEdit.tsx} | 16 +- .../index.tsx => views/panel/RuleList.tsx} | 4 +- .../panel/rule-edit/ColorScale.tsx | 4 +- .../panel/rule-edit/DataBar.tsx | 4 +- .../panel/rule-edit/Formula.tsx | 4 +- .../panel/rule-edit/HighlightCell.tsx | 4 +- .../panel/rule-edit/IconSet.tsx | 0 .../panel/rule-edit/Rank.tsx | 4 +- .../panel/rule-edit/styles.ts | 0 .../panel/rule-edit/type.ts | 0 .../wrapper-error/WrapperError.tsx | 0 .../src/controllers/dv-ui.controller.ts | 4 +- .../sheets-data-validation-ui/src/index.ts | 1 - .../index.tsx => DataValidationDetail.tsx} | 4 +- .../index.tsx => DataValidationItem.tsx} | 0 .../index.tsx => DataValidationList.tsx} | 4 +- .../index.tsx => DataValidationOptions.tsx} | 0 .../index.tsx => DataValidationPanel.tsx} | 6 +- .../index.tsx => DateShowTimeOption.tsx} | 0 .../index.tsx => ListRenderModeInput.tsx} | 0 .../src/views/components/index.ts | 2 +- .../validator-views/date-validator-view.ts | 2 +- .../validator-views/list-validator-view.ts | 2 +- .../sheet-drawing-printing.controller.tsx | 4 +- packages/sheets-drawing-ui/src/index.ts | 17 +- .../index.tsx => PrintingFloatDom.tsx} | 2 +- .../index.tsx => CellLinkEdit.tsx} | 14 +- .../index.tsx => CellLinkPopup.tsx} | 10 +- packages/sheets-note-ui/src/index.ts | 1 - .../src/controllers/numfmt.controller.ts | 4 +- .../index.tsx => SheetNumfmtPanel.tsx} | 20 +- .../components/stories/Panel.stories.tsx | 4 +- .../sheets-thread-comment.controller.ts | 4 +- .../index.tsx => SheetsThreadCommentCell.tsx} | 2 +- ...index.tsx => SheetsThreadCommentPanel.tsx} | 4 +- .../mobile/mobile-sheet-ui.controller.ts | 10 +- .../sheet-permission-render.controller.ts | 2 +- .../src/controllers/sheet-ui.controller.ts | 10 +- packages/sheets-ui/src/index.ts | 6 +- packages/sheets-ui/src/menu/border.menu.ts | 2 +- packages/sheets-ui/src/menu/frozen.menu.ts | 2 +- packages/sheets-ui/src/menu/insert.menu.ts | 2 +- packages/sheets-ui/src/menu/menu.ts | 2 +- .../{cell-popup/index.tsx => CellPopup.tsx} | 4 +- .../AutoFillPopupMenu.tsx | 2 +- .../border-panel/BorderPanel.tsx | 0 .../border-panel/border-line/BorderLine.tsx | 0 .../border-line/icons/BorderDashDot.tsx | 0 .../border-line/icons/BorderDashDotDot.tsx | 0 .../border-line/icons/BorderDashed.tsx | 0 .../border-line/icons/BorderDotted.tsx | 0 .../border-line/icons/BorderDouble.tsx | 0 .../border-line/icons/BorderHair.tsx | 0 .../border-line/icons/BorderMedium.tsx | 0 .../border-line/icons/BorderMediumDashDot.tsx | 0 .../icons/BorderMediumDashDotDot.tsx | 0 .../border-line/icons/BorderMediumDashed.tsx | 0 .../border-line/icons/BorderThick.tsx | 0 .../border-line/icons/BorderThin.tsx | 0 .../border-panel/interface.ts | 0 .../views/clipboard/ClipboardPopupMenu.tsx | 2 +- .../src/{components => views}/const.ts | 0 .../index.tsx => CascaderDropdown.tsx} | 2 +- .../index.tsx => ColorDropdown.tsx} | 2 +- .../index.tsx => DateDropdown.tsx} | 2 +- .../index.tsx => ListDropDown.tsx} | 4 +- .../sheets-ui/src/views/dropdown/index.ts | 24 +- .../src/{components => views}/hook.ts | 0 .../menu-item-frozen/MenuItemFrozen.tsx | 0 .../menu-item-frozen/index.ts | 0 .../menu-item-frozen/interface.ts | 0 .../menu-item-input/MenuItemInput.tsx | 0 .../menu-item-input/index.ts | 0 .../menu-item-input/interface.ts | 0 .../views/mobile/sheet-bar/MobileSheetBar.tsx | 2 +- .../index.tsx => AlertDialog.tsx} | 0 .../index.tsx => SheetPermissionDialog.tsx} | 4 +- .../index.tsx => SheetPermissionPanel.tsx} | 8 +- ...index.tsx => SheetPermissionPanelList.tsx} | 10 +- ...ndex.tsx => SheetPermissionUserDialog.tsx} | 6 +- .../permission/{spin/index.tsx => Spin.tsx} | 0 .../sheets-ui/src/views/permission/index.ts | 8 +- .../src/views/sheet-bar/SheetBar.tsx | 2 +- .../sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx | 2 +- .../views/sheet-container/SheetContainer.tsx | 2 +- .../src/views/sheet-slider/ZoomSlider.tsx | 2 +- .../operations/insert-shape.operation.ts | 2 +- .../src/controllers/slide-ui.controller.ts | 8 +- packages/slides-ui/src/index.ts | 2 - .../src/menu/popup-menu.controller.ts | 2 +- .../image-popup-menu/ImagePopupMenu.tsx | 0 .../image-popup-menu/component-name.ts | 0 .../panels/ArrangePanel.tsx | 0 .../panels/FillPanel.tsx | 0 .../panels/TransformPanel.tsx | 0 .../{components => views}/sidebar/Sidebar.tsx | 2 +- .../slide-bar/SlideBar.tsx | 0 packages/thread-comment-ui/src/index.ts | 8 +- .../index.tsx => ThreadCommentEditor.tsx} | 4 +- .../index.tsx => ThreadCommentPanel.tsx} | 12 +- .../index.tsx => ThreadCommentTree.tsx} | 10 +- .../__tests__/index.spec.tsx | 15 +- .../__tests__/util.spec.ts | 2 +- .../src/views/thread-comment-tree/util.ts | 2 +- .../controllers/ui/ui-desktop.controller.tsx | 14 +- .../controllers/ui/ui-mobile.controller.tsx | 14 +- packages/ui/src/index.ts | 20 +- .../__tests__/desktop-services.spec.ts | 4 +- .../message/desktop-message.service.ts | 2 +- .../desktop-notification.service.ts | 4 +- .../notification/notification.service.ts | 2 +- .../index.tsx => views/CommonLabel.tsx} | 2 +- .../index.tsx => views/HeadingItem.tsx} | 2 +- .../color-picker/interface.ts | 0 .../components/confirm-part/ConfirmPart.tsx | 2 +- .../components/confirm-part/interface.ts | 2 +- .../context-menu/ContextMenuPanel.tsx | 6 +- .../context-menu/MobileContextMenu.tsx | 2 +- .../__tests__/ContextMenuPanel.spec.tsx | 4 +- .../components/dialog-part/DialogPart.tsx | 2 +- .../views/components/dialog-part/interface.ts | 2 +- .../src/views/components/popup/RectPopup.tsx | 2 +- .../views/components/ribbon/MobileRibbon.tsx | 7 +- .../views/components/ribbon/ToolbarItem.tsx | 2 +- .../ribbon/TooltipButtonWrapper.tsx | 2 +- .../__tests__/TooltipButtonWrapper.spec.tsx | 2 +- .../src/views/components/sidebar/Sidebar.tsx | 4 +- .../custom-label/CustomLabel.tsx | 0 .../custom-label/index.ts | 0 .../font-family/FontFamily.tsx | 0 .../font-family/FontFamilyItem.tsx | 0 .../font-family/index.ts | 0 .../font-family/interface.ts | 0 .../font-size/FontSize.tsx | 0 .../font-size/interface.ts | 0 .../hooks/__tests__/observable.spec.ts | 0 .../src/{components => views}/hooks/event.ts | 0 .../src/{components => views}/hooks/index.ts | 0 .../src/{components => views}/hooks/layout.ts | 0 .../hooks/update-effect.ts | 0 .../hooks/use-click-out-side.ts | 0 .../hooks/use-debounce.ts | 0 .../hooks/virtual-list.ts | 0 .../ui/src/{components => views}/index.ts | 8 +- .../{components => views}/menu/common/hook.ts | 0 .../menu/desktop/DesignTinyMenuGroup.tsx | 13 +- .../menu/desktop/TinyMenuGroup.tsx | 0 .../__tests__/DesignTinyMenuGroup.spec.tsx | 16 + .../desktop/__tests__/TinyMenuGroup.spec.ts | 0 .../menu/mobile/MobileMenu.stories.tsx | 0 .../menu/mobile/MobileMenu.tsx | 2 +- .../src/{components => views}/menu/types.ts | 0 .../message/MessageContainer.tsx | 0 .../notification/Notification.stories.tsx | 0 .../notification/Notification.tsx | 0 .../progress-bar/ProgressBar.tsx | 0 .../slider/Slider.stories.tsx | 0 .../{components => views}/slider/Slider.tsx | 0 .../slider/__tests__/Slider.spec.tsx | 0 .../src/{components => views}/slider/index.ts | 0 packages/ui/src/views/workbench/Workbench.tsx | 2 +- pnpm-lock.yaml | 1769 +++++++++-------- 209 files changed, 1277 insertions(+), 1760 deletions(-) rename packages/docs-drawing-ui/src/views/{printing-float-dom/index.tsx => DocPrintingFloatDom.tsx} (96%) rename packages/docs-hyper-link-ui/src/views/{hyper-link-edit/index.tsx => DocHyperLinkEdit.tsx} (95%) rename packages/docs-hyper-link-ui/src/views/{hyper-link-popup/index.tsx => DocLinkPopup.tsx} (95%) rename packages/docs-mention-ui/src/views/{mention-edit-popup/index.tsx => MentionEditPopup.tsx} (94%) rename packages/docs-mention-ui/src/views/{mention-list/index.tsx => MentionList.tsx} (100%) rename packages/docs-thread-comment-ui/src/views/{doc-thread-comment-panel/index.tsx => DocThreadCommentPanel.tsx} (87%) delete mode 100644 packages/docs-ui/src/components/paragraph-menu/__tests__/paragraph-menu.spec.ts rename packages/docs-ui/src/views/{side-menu/index.tsx => DocSideMenu.tsx} (94%) rename packages/docs-ui/src/views/{page-settings/index.tsx => PageSettings.tsx} (100%) rename packages/docs-ui/src/{components/paragraph-menu/index.tsx => views/ParagraphMenu.tsx} (96%) rename packages/docs-ui/src/views/{rich-text-editor/index.tsx => RichTextEditor.tsx} (93%) rename packages/docs-ui/src/{components/side-menu/index.tsx => views/SideMenu.tsx} (100%) rename packages/docs-ui/src/{components => views}/const.ts (100%) rename packages/docs-ui/src/{components => views}/editor/utils.ts (100%) rename packages/docs-ui/src/{components => views}/float-toolbar/FloatToolbar.stories.tsx (100%) rename packages/docs-ui/src/{components => views}/float-toolbar/FloatToolbar.tsx (100%) rename packages/docs-ui/src/{components => views}/float-toolbar/__tests__/FloatToolbar.spec.ts (100%) rename packages/docs-ui/src/{components => views}/list-type-picker/Picker.tsx (100%) rename packages/docs-ui/src/{components => views}/list-type-picker/index.ts (100%) rename packages/docs-ui/src/{components => views}/paragraph-menu/component-keys.ts (100%) rename packages/docs-ui/src/{components => views}/side-menu/SideMenu.stories.tsx (97%) rename packages/sheets-conditional-formatting-ui/src/{components/color-picker/index.tsx => views/ColorPicker.tsx} (100%) rename packages/sheets-conditional-formatting-ui/src/{components/panel/index.tsx => views/ConditionFormattingPanel.tsx} (95%) rename packages/sheets-conditional-formatting-ui/src/{components/conditional-style-editor/index.tsx => views/ConditionalStyleEditor.tsx} (99%) rename packages/sheets-conditional-formatting-ui/src/{components/preview/index.tsx => views/Preview.tsx} (100%) rename packages/sheets-conditional-formatting-ui/src/{components/panel/rule-edit/index.tsx => views/panel/RuleEdit.tsx} (96%) rename packages/sheets-conditional-formatting-ui/src/{components/panel/rule-list/index.tsx => views/panel/RuleList.tsx} (99%) rename packages/sheets-conditional-formatting-ui/src/{components => views}/panel/rule-edit/ColorScale.tsx (99%) rename packages/sheets-conditional-formatting-ui/src/{components => views}/panel/rule-edit/DataBar.tsx (99%) rename packages/sheets-conditional-formatting-ui/src/{components => views}/panel/rule-edit/Formula.tsx (98%) rename packages/sheets-conditional-formatting-ui/src/{components => views}/panel/rule-edit/HighlightCell.tsx (99%) rename packages/sheets-conditional-formatting-ui/src/{components => views}/panel/rule-edit/IconSet.tsx (100%) rename packages/sheets-conditional-formatting-ui/src/{components => views}/panel/rule-edit/Rank.tsx (98%) rename packages/sheets-conditional-formatting-ui/src/{components => views}/panel/rule-edit/styles.ts (100%) rename packages/sheets-conditional-formatting-ui/src/{components => views}/panel/rule-edit/type.ts (100%) rename packages/sheets-conditional-formatting-ui/src/{components => views}/wrapper-error/WrapperError.tsx (100%) rename packages/sheets-data-validation-ui/src/views/components/{detail/index.tsx => DataValidationDetail.tsx} (99%) rename packages/sheets-data-validation-ui/src/views/components/{item/index.tsx => DataValidationItem.tsx} (100%) rename packages/sheets-data-validation-ui/src/views/components/{list/index.tsx => DataValidationList.tsx} (97%) rename packages/sheets-data-validation-ui/src/views/components/{options/index.tsx => DataValidationOptions.tsx} (100%) rename packages/sheets-data-validation-ui/src/views/components/{panel/index.tsx => DataValidationPanel.tsx} (89%) rename packages/sheets-data-validation-ui/src/views/components/{show-time/index.tsx => DateShowTimeOption.tsx} (100%) rename packages/sheets-data-validation-ui/src/views/components/{render-mode/index.tsx => ListRenderModeInput.tsx} (100%) rename packages/sheets-drawing-ui/src/views/{printing-float-dom/index.tsx => PrintingFloatDom.tsx} (97%) rename packages/sheets-hyper-link-ui/src/views/{CellLinkEdit/index.tsx => CellLinkEdit.tsx} (97%) rename packages/sheets-hyper-link-ui/src/views/{CellLinkPopup/index.tsx => CellLinkPopup.tsx} (96%) rename packages/sheets-numfmt-ui/src/views/{components/index.tsx => SheetNumfmtPanel.tsx} (89%) rename packages/sheets-thread-comment-ui/src/views/{sheets-thread-comment-cell/index.tsx => SheetsThreadCommentCell.tsx} (96%) rename packages/sheets-thread-comment-ui/src/views/{sheets-thread-comment-panel/index.tsx => SheetsThreadCommentPanel.tsx} (96%) rename packages/sheets-ui/src/views/{cell-popup/index.tsx => CellPopup.tsx} (91%) rename packages/sheets-ui/src/{components => views}/border-panel/BorderPanel.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/BorderLine.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderDashDot.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderDashDotDot.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderDashed.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderDotted.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderDouble.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderHair.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderMedium.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderMediumDashDot.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderMediumDashDotDot.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderMediumDashed.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderThick.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/border-line/icons/BorderThin.tsx (100%) rename packages/sheets-ui/src/{components => views}/border-panel/interface.ts (100%) rename packages/sheets-ui/src/{components => views}/const.ts (100%) rename packages/sheets-ui/src/views/dropdown/{cascader-dropdown/index.tsx => CascaderDropdown.tsx} (96%) rename packages/sheets-ui/src/views/dropdown/{color-dropdown/index.tsx => ColorDropdown.tsx} (95%) rename packages/sheets-ui/src/views/dropdown/{date-dropdown/index.tsx => DateDropdown.tsx} (98%) rename packages/sheets-ui/src/views/dropdown/{list-dropdown/index.tsx => ListDropDown.tsx} (98%) rename packages/sheets-ui/src/{components => views}/hook.ts (100%) rename packages/sheets-ui/src/{components => views}/menu-item-frozen/MenuItemFrozen.tsx (100%) rename packages/sheets-ui/src/{components => views}/menu-item-frozen/index.ts (100%) rename packages/sheets-ui/src/{components => views}/menu-item-frozen/interface.ts (100%) rename packages/sheets-ui/src/{components => views}/menu-item-input/MenuItemInput.tsx (100%) rename packages/sheets-ui/src/{components => views}/menu-item-input/index.ts (100%) rename packages/sheets-ui/src/{components => views}/menu-item-input/interface.ts (100%) rename packages/sheets-ui/src/views/permission/{error-msg-dialog/index.tsx => AlertDialog.tsx} (100%) rename packages/sheets-ui/src/views/permission/{permission-dialog/index.tsx => SheetPermissionDialog.tsx} (98%) rename packages/sheets-ui/src/views/permission/{panel/index.tsx => SheetPermissionPanel.tsx} (85%) rename packages/sheets-ui/src/views/permission/{panel-list/index.tsx => SheetPermissionPanelList.tsx} (98%) rename packages/sheets-ui/src/views/permission/{user-dialog/index.tsx => SheetPermissionUserDialog.tsx} (96%) rename packages/sheets-ui/src/views/permission/{spin/index.tsx => Spin.tsx} (100%) rename packages/slides-ui/src/{components => views}/image-popup-menu/ImagePopupMenu.tsx (100%) rename packages/slides-ui/src/{components => views}/image-popup-menu/component-name.ts (100%) rename packages/slides-ui/src/{components => views}/panels/ArrangePanel.tsx (100%) rename packages/slides-ui/src/{components => views}/panels/FillPanel.tsx (100%) rename packages/slides-ui/src/{components => views}/panels/TransformPanel.tsx (100%) rename packages/slides-ui/src/{components => views}/sidebar/Sidebar.tsx (96%) rename packages/slides-ui/src/{components => views}/slide-bar/SlideBar.tsx (100%) rename packages/thread-comment-ui/src/views/{thread-comment-editor/index.tsx => ThreadCommentEditor.tsx} (98%) rename packages/thread-comment-ui/src/views/{thread-comment-panel/index.tsx => ThreadCommentPanel.tsx} (95%) rename packages/thread-comment-ui/src/views/{thread-comment-tree/index.tsx => ThreadCommentTree.tsx} (98%) rename packages/ui/src/{components/common-label/index.tsx => views/CommonLabel.tsx} (96%) rename packages/ui/src/{components/heading-item/index.tsx => views/HeadingItem.tsx} (96%) rename packages/ui/src/{components => views}/color-picker/interface.ts (100%) rename packages/ui/src/{components => views}/custom-label/CustomLabel.tsx (100%) rename packages/ui/src/{components => views}/custom-label/index.ts (100%) rename packages/ui/src/{components => views}/font-family/FontFamily.tsx (100%) rename packages/ui/src/{components => views}/font-family/FontFamilyItem.tsx (100%) rename packages/ui/src/{components => views}/font-family/index.ts (100%) rename packages/ui/src/{components => views}/font-family/interface.ts (100%) rename packages/ui/src/{components => views}/font-size/FontSize.tsx (100%) rename packages/ui/src/{components => views}/font-size/interface.ts (100%) rename packages/ui/src/{components => views}/hooks/__tests__/observable.spec.ts (100%) rename packages/ui/src/{components => views}/hooks/event.ts (100%) rename packages/ui/src/{components => views}/hooks/index.ts (100%) rename packages/ui/src/{components => views}/hooks/layout.ts (100%) rename packages/ui/src/{components => views}/hooks/update-effect.ts (100%) rename packages/ui/src/{components => views}/hooks/use-click-out-side.ts (100%) rename packages/ui/src/{components => views}/hooks/use-debounce.ts (100%) rename packages/ui/src/{components => views}/hooks/virtual-list.ts (100%) rename packages/ui/src/{components => views}/index.ts (80%) rename packages/ui/src/{components => views}/menu/common/hook.ts (100%) rename packages/ui/src/{components => views}/menu/desktop/DesignTinyMenuGroup.tsx (93%) rename packages/ui/src/{components => views}/menu/desktop/TinyMenuGroup.tsx (100%) rename packages/ui/src/{components => views}/menu/desktop/__tests__/DesignTinyMenuGroup.spec.tsx (81%) rename packages/ui/src/{components => views}/menu/desktop/__tests__/TinyMenuGroup.spec.ts (100%) rename packages/ui/src/{components => views}/menu/mobile/MobileMenu.stories.tsx (100%) rename packages/ui/src/{components => views}/menu/mobile/MobileMenu.tsx (99%) rename packages/ui/src/{components => views}/menu/types.ts (100%) rename packages/ui/src/{components => views}/message/MessageContainer.tsx (100%) rename packages/ui/src/{components => views}/notification/Notification.stories.tsx (100%) rename packages/ui/src/{components => views}/notification/Notification.tsx (100%) rename packages/ui/src/{components => views}/progress-bar/ProgressBar.tsx (100%) rename packages/ui/src/{components => views}/slider/Slider.stories.tsx (100%) rename packages/ui/src/{components => views}/slider/Slider.tsx (100%) rename packages/ui/src/{components => views}/slider/__tests__/Slider.spec.tsx (100%) rename packages/ui/src/{components => views}/slider/index.ts (100%) diff --git a/package.json b/package.json index 7fadbf718f..1a2fe85c34 100644 --- a/package.json +++ b/package.json @@ -60,18 +60,18 @@ "@antfu/eslint-config": "^9.0.0", "@commitlint/cli": "^21.0.2", "@commitlint/config-conventional": "^21.0.2", - "@eslint-react/eslint-plugin": "^5.8.12", + "@eslint-react/eslint-plugin": "^5.9.0", "@eslint/compat": "^2.1.0", "@playwright/test": "^1.57.0", "@release-it-plugins/workspaces": "^5.0.3", "@release-it/conventional-changelog": "^10.0.6", "@types/fs-extra": "^11.0.4", - "@types/node": "^25.9.1", - "@types/react": "19.2.16", + "@types/node": "^25.9.3", + "@types/react": "19.2.17", "@types/react-dom": "19.2.3", "@univerjs-infra/shared": "workspace:*", "@univerjs/design": "workspace:*", - "eslint": "^10.4.1", + "eslint": "^10.5.0", "eslint-plugin-format": "^2.0.1", "eslint-plugin-react": "^7.37.5", "eslint-plugin-react-hooks": "^7.1.1", @@ -79,20 +79,20 @@ "fs-extra": "^11.3.5", "husky": "^9.1.7", "lint-staged": "^17.0.7", - "posthog-node": "^5.36.2", + "posthog-node": "^5.37.0", "react": "19.2.7", "react-dom": "19.2.7", "release-it": "^19.2.4", "serve": "^14.2.6", "tailwindcss": "3.4.18", - "tsx": "^4.22.3", - "turbo": "^2.9.16", + "tsx": "^4.22.4", + "turbo": "^2.9.18", "typescript": "^6.0.3", "vitest": "^4.1.8" }, "pnpm": { "overrides": { - "@types/react": "19.2.16", + "@types/react": "19.2.17", "@types/react-dom": "19.2.3", "basic-ftp": "5.2.0", "react": "19.2.7", diff --git a/packages/design/src/helper/class-utilities.ts b/packages/design/src/helper/class-utilities.ts index a73d58075b..ec67d8a528 100644 --- a/packages/design/src/helper/class-utilities.ts +++ b/packages/design/src/helper/class-utilities.ts @@ -28,3 +28,4 @@ export const borderBottomClassName = clsx(borderBasicClassName, 'univer-border-l export const borderRightClassName = clsx(borderBasicClassName, 'univer-border-l-0 univer-border-b-0 univer-border-t-0 univer-border-r'); export const divideYClassName = 'univer-divide-gray-200 dark:!univer-divide-gray-600 univer-divide-y univer-divide-x-0 univer-divide-solid'; export const divideXClassName = 'univer-divide-gray-200 dark:!univer-divide-gray-600 univer-divide-x univer-divide-y-0 univer-divide-solid'; +export const resetButtonClassName = 'univer-m-0 univer-flex univer-appearance-none univer-items-center univer-justify-center univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outline-none univer-cursor-pointer'; diff --git a/packages/design/src/index.ts b/packages/design/src/index.ts index 515564b457..cd022e7ce4 100644 --- a/packages/design/src/index.ts +++ b/packages/design/src/index.ts @@ -77,6 +77,7 @@ export { borderTopClassName, divideXClassName, divideYClassName, + resetButtonClassName, scrollbarClassName, } from './helper/class-utilities'; export { clsx } from './helper/clsx'; diff --git a/packages/docs-drawing-ui/src/controllers/doc-drawing-printing.controller.tsx b/packages/docs-drawing-ui/src/controllers/doc-drawing-printing.controller.tsx index 39a61ffbce..1bd7ead975 100644 --- a/packages/docs-drawing-ui/src/controllers/doc-drawing-printing.controller.tsx +++ b/packages/docs-drawing-ui/src/controllers/doc-drawing-printing.controller.tsx @@ -15,14 +15,14 @@ */ import type { IDocFloatDom } from '@univerjs/docs-drawing'; -import type { IPrintingFloatDomProps } from '../views/printing-float-dom'; +import type { IPrintingFloatDomProps } from '../views/DocPrintingFloatDom'; import { Disposable, DOC_DRAWING_PRINTING_COMPONENT_KEY, DrawingTypeEnum, Inject, Injector } from '@univerjs/core'; import { render, unmount } from '@univerjs/design'; import { DocPrintInterceptorService } from '@univerjs/docs-ui'; import { IDrawingManagerService } from '@univerjs/drawing'; import { DrawingRenderService } from '@univerjs/drawing-ui'; import { ComponentManager, connectInjector } from '@univerjs/ui'; -import { DocPrintingFloatDom } from '../views/printing-float-dom'; +import { DocPrintingFloatDom } from '../views/DocPrintingFloatDom'; export class DocDrawingPrintingController extends Disposable { constructor( diff --git a/packages/docs-drawing-ui/src/views/printing-float-dom/index.tsx b/packages/docs-drawing-ui/src/views/DocPrintingFloatDom.tsx similarity index 96% rename from packages/docs-drawing-ui/src/views/printing-float-dom/index.tsx rename to packages/docs-drawing-ui/src/views/DocPrintingFloatDom.tsx index 0057a84840..5d8a8feb85 100644 --- a/packages/docs-drawing-ui/src/views/printing-float-dom/index.tsx +++ b/packages/docs-drawing-ui/src/views/DocPrintingFloatDom.tsx @@ -20,7 +20,7 @@ import type { IFloatDom, IFloatDomLayout } from '@univerjs/ui'; import { PrintFloatDomSingle } from '@univerjs/ui'; import { useMemo } from 'react'; import { BehaviorSubject } from 'rxjs'; -import { calcDocFloatDomPositionByRect } from '../../controllers/doc-float-dom.controller'; +import { calcDocFloatDomPositionByRect } from '../controllers/doc-float-dom.controller'; export interface IPrintingFloatDomProps { floatDomInfos: IDocFloatDom[]; diff --git a/packages/docs-hyper-link-ui/src/controllers/__tests__/ui.controller.spec.ts b/packages/docs-hyper-link-ui/src/controllers/__tests__/ui.controller.spec.ts index 672723486b..faf486b1d6 100644 --- a/packages/docs-hyper-link-ui/src/controllers/__tests__/ui.controller.spec.ts +++ b/packages/docs-hyper-link-ui/src/controllers/__tests__/ui.controller.spec.ts @@ -16,7 +16,7 @@ import { FLOAT_TOOLBAR_MENU_POSITION } from '@univerjs/docs-ui'; import { describe, expect, it, vi } from 'vitest'; -import { DocHyperLinkEdit } from '../../views/hyper-link-edit'; +import { DocHyperLinkEdit } from '../../views/DocHyperLinkEdit'; import { DocHyperLinkUIController } from '../ui.controller'; describe('DocHyperLinkUIController', () => { diff --git a/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts b/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts index e1954aa929..9ea65fdc61 100644 --- a/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts +++ b/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts @@ -25,8 +25,8 @@ import { UpdateDocHyperLinkCommand } from '../commands/commands/update-link.comm import { ClickDocHyperLinkOperation, ShowDocHyperLinkEditPopupOperation, ToggleDocHyperLinkInfoPopupOperation } from '../commands/operations/popup.operation'; import { addLinkShortcut, DOC_LINK_ICON } from '../menu/menu'; import { menuSchema } from '../menu/schema'; -import { DocHyperLinkEdit } from '../views/hyper-link-edit'; -import { DocLinkPopup } from '../views/hyper-link-popup'; +import { DocHyperLinkEdit } from '../views/DocHyperLinkEdit'; +import { DocLinkPopup } from '../views/DocLinkPopup'; export interface IDocHyperLinkUIConfig { menu: MenuConfig; diff --git a/packages/docs-hyper-link-ui/src/services/hyper-link-popup.service.ts b/packages/docs-hyper-link-ui/src/services/hyper-link-popup.service.ts index 148d1eb539..8d003c873c 100644 --- a/packages/docs-hyper-link-ui/src/services/hyper-link-popup.service.ts +++ b/packages/docs-hyper-link-ui/src/services/hyper-link-popup.service.ts @@ -19,8 +19,8 @@ import { Disposable, Inject, IUniverInstanceService, UniverInstanceType } from ' import { DocSelectionManagerService } from '@univerjs/docs'; import { DocCanvasPopManagerService } from '@univerjs/docs-ui'; import { BehaviorSubject } from 'rxjs'; -import { DocHyperLinkEdit } from '../views/hyper-link-edit'; -import { DocLinkPopup } from '../views/hyper-link-popup'; +import { DocHyperLinkEdit } from '../views/DocHyperLinkEdit'; +import { DocLinkPopup } from '../views/DocLinkPopup'; export interface ILinkInfo { unitId: string; diff --git a/packages/docs-hyper-link-ui/src/views/hyper-link-edit/index.tsx b/packages/docs-hyper-link-ui/src/views/DocHyperLinkEdit.tsx similarity index 95% rename from packages/docs-hyper-link-ui/src/views/hyper-link-edit/index.tsx rename to packages/docs-hyper-link-ui/src/views/DocHyperLinkEdit.tsx index 7d7103947b..b393a287cc 100644 --- a/packages/docs-hyper-link-ui/src/views/hyper-link-edit/index.tsx +++ b/packages/docs-hyper-link-ui/src/views/DocHyperLinkEdit.tsx @@ -20,10 +20,10 @@ import { borderClassName, Button, clsx, FormLayout, Input } from '@univerjs/desi import { DocSelectionManagerService } from '@univerjs/docs'; import { KeyCode, useDependency, useObservable } from '@univerjs/ui'; import { useEffect, useState } from 'react'; -import { AddDocHyperLinkCommand } from '../../commands/commands/add-link.command'; -import { UpdateDocHyperLinkCommand } from '../../commands/commands/update-link.command'; -import { DocHyperLinkPopupService } from '../../services/hyper-link-popup.service'; -import { isBlankInput } from './utils'; +import { AddDocHyperLinkCommand } from '../commands/commands/add-link.command'; +import { UpdateDocHyperLinkCommand } from '../commands/commands/update-link.command'; +import { DocHyperLinkPopupService } from '../services/hyper-link-popup.service'; +import { isBlankInput } from './hyper-link-edit/utils'; function hasProtocol(urlString: string) { const pattern = /^[a-zA-Z]+:\/\//; diff --git a/packages/docs-hyper-link-ui/src/views/hyper-link-popup/index.tsx b/packages/docs-hyper-link-ui/src/views/DocLinkPopup.tsx similarity index 95% rename from packages/docs-hyper-link-ui/src/views/hyper-link-popup/index.tsx rename to packages/docs-hyper-link-ui/src/views/DocLinkPopup.tsx index 67259c24af..8389d0cac2 100644 --- a/packages/docs-hyper-link-ui/src/views/hyper-link-popup/index.tsx +++ b/packages/docs-hyper-link-ui/src/views/DocLinkPopup.tsx @@ -19,9 +19,9 @@ import { CustomRangeType, ICommandService, IUniverInstanceService, LocaleService import { borderClassName, clsx, MessageType, Tooltip } from '@univerjs/design'; import { CopyIcon, LinkIcon, UnlinkIcon, WriteIcon } from '@univerjs/icons'; import { IMessageService, useDependency, useObservable } from '@univerjs/ui'; -import { DeleteDocHyperLinkCommand } from '../../commands/commands/delete-link.command'; -import { ShowDocHyperLinkEditPopupOperation } from '../../commands/operations/popup.operation'; -import { DocHyperLinkPopupService } from '../../services/hyper-link-popup.service'; +import { DeleteDocHyperLinkCommand } from '../commands/commands/delete-link.command'; +import { ShowDocHyperLinkEditPopupOperation } from '../commands/operations/popup.operation'; +import { DocHyperLinkPopupService } from '../services/hyper-link-popup.service'; export const DocLinkPopup = () => { const hyperLinkService = useDependency(DocHyperLinkPopupService); diff --git a/packages/docs-mention-ui/src/controllers/doc-mention-ui.controller.ts b/packages/docs-mention-ui/src/controllers/doc-mention-ui.controller.ts index 26f5a85d1e..7c2c19fca0 100644 --- a/packages/docs-mention-ui/src/controllers/doc-mention-ui.controller.ts +++ b/packages/docs-mention-ui/src/controllers/doc-mention-ui.controller.ts @@ -18,7 +18,7 @@ import { Disposable, ICommandService, Inject } from '@univerjs/core'; import { ComponentManager } from '@univerjs/ui'; import { AddDocMentionCommand, DeleteDocMentionCommand } from '../commands/commands/doc-mention.command'; import { CloseMentionEditPopupOperation, CloseMentionInfoPopupOperation, ShowMentionEditPopupOperation, ShowMentionInfoPopupOperation } from '../commands/operations/mention-popup.operation'; -import { MentionEditPopup } from '../views/mention-edit-popup'; +import { MentionEditPopup } from '../views/MentionEditPopup'; export class DocMentionUIController extends Disposable { constructor( diff --git a/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts b/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts index 9dadf379e7..d9f0219d75 100644 --- a/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts +++ b/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts @@ -18,7 +18,7 @@ import type { IDisposable, Nullable } from '@univerjs/core'; import { Disposable, Inject } from '@univerjs/core'; import { DocCanvasPopManagerService } from '@univerjs/docs-ui'; import { BehaviorSubject } from 'rxjs'; -import { MentionEditPopup } from '../views/mention-edit-popup'; +import { MentionEditPopup } from '../views/MentionEditPopup'; import { DocMentionService } from './doc-mention.service'; export class DocMentionPopupService extends Disposable { diff --git a/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx b/packages/docs-mention-ui/src/views/MentionEditPopup.tsx similarity index 94% rename from packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx rename to packages/docs-mention-ui/src/views/MentionEditPopup.tsx index 58cc6e1477..a38f46198d 100644 --- a/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx +++ b/packages/docs-mention-ui/src/views/MentionEditPopup.tsx @@ -21,9 +21,9 @@ import { IEditorService } from '@univerjs/docs-ui'; import { useDependency, useObservable } from '@univerjs/ui'; import { useEffect, useMemo, useState } from 'react'; import { filter } from 'rxjs'; -import { AddDocMentionCommand } from '../../commands/commands/doc-mention.command'; -import { DocMentionPopupService } from '../../services/doc-mention-popup.service'; -import { MentionList } from '../mention-list'; +import { AddDocMentionCommand } from '../commands/commands/doc-mention.command'; +import { DocMentionPopupService } from '../services/doc-mention-popup.service'; +import { MentionList } from './MentionList'; export const MentionEditPopup = () => { const popupService = useDependency(DocMentionPopupService); diff --git a/packages/docs-mention-ui/src/views/mention-list/index.tsx b/packages/docs-mention-ui/src/views/MentionList.tsx similarity index 100% rename from packages/docs-mention-ui/src/views/mention-list/index.tsx rename to packages/docs-mention-ui/src/views/MentionList.tsx diff --git a/packages/docs-thread-comment-ui/src/controllers/__tests__/doc-thread-comment-ui.controller.spec.ts b/packages/docs-thread-comment-ui/src/controllers/__tests__/doc-thread-comment-ui.controller.spec.ts index 314d41604b..fc1015c16b 100644 --- a/packages/docs-thread-comment-ui/src/controllers/__tests__/doc-thread-comment-ui.controller.spec.ts +++ b/packages/docs-thread-comment-ui/src/controllers/__tests__/doc-thread-comment-ui.controller.spec.ts @@ -17,7 +17,7 @@ import { FLOAT_TOOLBAR_MENU_POSITION } from '@univerjs/docs-ui'; import { describe, expect, it, vi } from 'vitest'; import { DOCS_THREAD_COMMENT_PANEL } from '../../common/const'; -import { DocThreadCommentPanel } from '../../views/doc-thread-comment-panel'; +import { DocThreadCommentPanel } from '../../views/DocThreadCommentPanel'; import { DocThreadCommentUIController } from '../doc-thread-comment-ui.controller'; describe('DocThreadCommentUIController', () => { diff --git a/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts b/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts index a21b4bf5b6..a83f52e350 100644 --- a/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts +++ b/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts @@ -23,7 +23,7 @@ import { DeleteDocCommentComment } from '../commands/commands/delete-doc-comment import { ShowCommentPanelOperation, StartAddCommentOperation, ToggleCommentPanelOperation } from '../commands/operations/show-comment-panel.operation'; import { DOCS_THREAD_COMMENT_PANEL } from '../common/const'; import { menuSchema } from '../menu/schema'; -import { DocThreadCommentPanel } from '../views/doc-thread-comment-panel'; +import { DocThreadCommentPanel } from '../views/DocThreadCommentPanel'; export class DocThreadCommentUIController extends Disposable { constructor( diff --git a/packages/docs-thread-comment-ui/src/views/doc-thread-comment-panel/index.tsx b/packages/docs-thread-comment-ui/src/views/DocThreadCommentPanel.tsx similarity index 87% rename from packages/docs-thread-comment-ui/src/views/doc-thread-comment-panel/index.tsx rename to packages/docs-thread-comment-ui/src/views/DocThreadCommentPanel.tsx index ce3ddbf514..9083da825c 100644 --- a/packages/docs-thread-comment-ui/src/views/doc-thread-comment-panel/index.tsx +++ b/packages/docs-thread-comment-ui/src/views/DocThreadCommentPanel.tsx @@ -15,20 +15,20 @@ */ import type { DocumentDataModel } from '@univerjs/core'; -import type { IAddDocCommentComment } from '../../commands/commands/add-doc-comment.command'; -import type { IDeleteDocCommentComment } from '../../commands/commands/delete-doc-comment.command'; +import type { IAddDocCommentComment } from '../commands/commands/add-doc-comment.command'; +import type { IDeleteDocCommentComment } from '../commands/commands/delete-doc-comment.command'; import { ICommandService, Injector, isInternalEditorID, IUniverInstanceService, UniverInstanceType } from '@univerjs/core'; import { DocSelectionManagerService, RichTextEditingMutation } from '@univerjs/docs'; import { ThreadCommentPanel } from '@univerjs/thread-comment-ui'; import { useDependency, useObservable } from '@univerjs/ui'; import { useEffect, useMemo, useState } from 'react'; import { debounceTime, filter, Observable } from 'rxjs'; -import { AddDocCommentComment } from '../../commands/commands/add-doc-comment.command'; -import { DeleteDocCommentComment } from '../../commands/commands/delete-doc-comment.command'; -import { StartAddCommentOperation } from '../../commands/operations/show-comment-panel.operation'; -import { DEFAULT_DOC_SUBUNIT_ID } from '../../common/const'; -import { shouldDisableAddComment } from '../../menu/menu'; -import { DocThreadCommentService } from '../../services/doc-thread-comment.service'; +import { AddDocCommentComment } from '../commands/commands/add-doc-comment.command'; +import { DeleteDocCommentComment } from '../commands/commands/delete-doc-comment.command'; +import { StartAddCommentOperation } from '../commands/operations/show-comment-panel.operation'; +import { DEFAULT_DOC_SUBUNIT_ID } from '../common/const'; +import { shouldDisableAddComment } from '../menu/menu'; +import { DocThreadCommentService } from '../services/doc-thread-comment.service'; export const DocThreadCommentPanel = () => { const univerInstanceService = useDependency(IUniverInstanceService); diff --git a/packages/docs-ui/src/commands/operations/open-page-setting.operation.ts b/packages/docs-ui/src/commands/operations/open-page-setting.operation.ts index 276bd8c0e5..107e6b8655 100644 --- a/packages/docs-ui/src/commands/operations/open-page-setting.operation.ts +++ b/packages/docs-ui/src/commands/operations/open-page-setting.operation.ts @@ -18,7 +18,7 @@ import type { ICommand, ModernDocumentWidthMode, PaperType } from '@univerjs/cor import type { IConfirmPartMethodOptions } from '@univerjs/ui'; import type { IDocPageSetupCommandParams } from '../commands/doc-page-setup.command'; import { CommandType, DocumentFlavor, ICommandService, IConfirmService, LocaleService, MODERN_DOCUMENT_WIDTH, PAGE_SIZE } from '@univerjs/core'; -import { PAGE_SETTING_COMPONENT_ID } from '../../views/page-settings'; +import { PAGE_SETTING_COMPONENT_ID } from '../../views/PageSettings'; import { DocPageSetupCommand } from '../commands/doc-page-setup.command'; export const DocOpenPageSettingCommand: ICommand = { diff --git a/packages/docs-ui/src/components/paragraph-menu/__tests__/paragraph-menu.spec.ts b/packages/docs-ui/src/components/paragraph-menu/__tests__/paragraph-menu.spec.ts deleted file mode 100644 index 3893b34144..0000000000 --- a/packages/docs-ui/src/components/paragraph-menu/__tests__/paragraph-menu.spec.ts +++ /dev/null @@ -1,532 +0,0 @@ -/** - * Copyright 2023-present DreamNum Co., Ltd. - * - * 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 { NamedStyleType } from '@univerjs/core'; -import { MenuItemType } from '@univerjs/ui'; - -import React from 'react'; -import { renderToStaticMarkup } from 'react-dom/server'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import * as paragraphMenu from '..'; -import { createParagraphMenuHoverOpenScheduler, finishParagraphMenuCommand, getParagraphFormattingRange, getParagraphMenuActiveHeadingCommandId, getParagraphMenuCommand, getParagraphMenuCommandTargetRange, getParagraphMenuHiddenHeadingCommandIds, getParagraphMenuHiddenItemIds, getParagraphMenuIconSizeClass, getParagraphMenuPopupDirection, getParagraphMenuResolvedCommand, getParagraphMenuTargetRange, isEmptyParagraphMenuTarget, PARAGRAPH_MENU_HOVER_OPEN_DELAY, setParagraphMenuInteractionActive, shouldShowParagraphSettingMenu, shouldUseInsertBelowRange } from '..'; -import { HorizontalLineCommand } from '../../../commands/commands/doc-horizontal-line.command'; -import { SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand } from '../../../commands/commands/inline-format.command'; -import { BulletListCommand, InsertBulletListBellowCommand, OrderListCommand } from '../../../commands/commands/list.command'; -import { H1HeadingCommand, H3HeadingCommand, H4HeadingCommand, H5HeadingCommand, NormalTextHeadingCommand, SetParagraphNamedStyleCommand, SubtitleHeadingCommand, TitleHeadingCommand } from '../../../commands/commands/set-heading.command'; -import { CreateDocTableCommand } from '../../../commands/commands/table/doc-table-create.command'; -import { - DOC_PARAGRAPH_T_EDIT_MENU_ID, - DOC_PARAGRAPH_T_INSERT_MENU_ID, - EmptyParagraphBulletListMenuItemFactory, - EmptyParagraphH1MenuItemFactory, - EmptyParagraphHorizontalLineMenuItemFactory, - HEADING_ICON_MAP, - INSERT_BELLOW_MENU_ID, - InsertBulletListBellowMenuItemFactory, - InsertHorizontalLineBellowMenuItemFactory, - InsertOrderListBellowMenuItemFactory, - ParagraphMenuBackgroundColorHeaderActionMenuItemFactory, - ParagraphMenuBackgroundColorSwatchMenuItemFactories, - ParagraphMenuDefaultTextColorMenuItemFactory, - ParagraphMenuIndentDecreaseMenuItemFactory, - ParagraphMenuIndentIncreaseMenuItemFactory, - ParagraphMenuNoBackgroundMenuItemFactory, - ParagraphMenuTextColorHeaderActionMenuItemFactory, - ParagraphMenuTextColorSwatchMenuItemFactories, - TableBlockCopyMenuItemFactory, - TableBlockDeleteMenuItemFactory, - TableBlockPasteMenuItemFactory, -} from '../../../menu/paragraph-menu'; - -describe('ParagraphMenu', () => { - afterEach(() => { - vi.useRealTimers(); - }); - - it('uses a smaller icon for normal text paragraph triggers', () => { - expect(getParagraphMenuIconSizeClass('TextTypeIcon')).toBe('univer-size-3'); - expect(getParagraphMenuIconSizeClass('TitleTypeIcon')).toBe('univer-size-4'); - expect(getParagraphMenuIconSizeClass('SubtitleTypeIcon')).toBe('univer-size-4'); - expect(getParagraphMenuIconSizeClass('H1Icon')).toBe('univer-size-4'); - expect(HEADING_ICON_MAP[NamedStyleType.TITLE].key).toBe('TitleTypeIcon'); - expect(HEADING_ICON_MAP[NamedStyleType.SUBTITLE].key).toBe('SubtitleTypeIcon'); - }); - - it('uses the enlarged context menu size variant for the docs T menu', () => { - expect((paragraphMenu as any).getParagraphMenuContextMenuSizeVariant?.()).toBe('paragraph-t'); - }); - - it('uses fully-qualified locale keys for paragraph context menu labels', () => { - const accessor = { - get: () => ({ - get: () => undefined, - register: () => undefined, - }), - } as never; - - expect(EmptyParagraphH1MenuItemFactory(accessor).title).toBe('ui.toolbar.heading.1'); - expect(EmptyParagraphBulletListMenuItemFactory(accessor).title).toBe('docs-ui.rightClick.bulletList'); - expect(EmptyParagraphHorizontalLineMenuItemFactory(accessor).title).toBe('docs-ui.toolbar.horizontalLine'); - expect(TableBlockCopyMenuItemFactory(accessor).title).toBe('docs-ui.rightClick.copy'); - expect(TableBlockPasteMenuItemFactory(accessor).title).toBe('docs-ui.rightClick.paste'); - expect(TableBlockDeleteMenuItemFactory(accessor).title).toBe('docs-ui.rightClick.delete'); - }); - - it('adds matching tooltips to T-menu icon actions', () => { - const accessor = { - get: () => ({ - get: () => undefined, - register: () => undefined, - }), - } as never; - - expect(EmptyParagraphH1MenuItemFactory(accessor).tooltip).toBe('ui.toolbar.heading.1'); - expect(EmptyParagraphBulletListMenuItemFactory(accessor).tooltip).toBe('docs-ui.rightClick.bulletList'); - expect(EmptyParagraphHorizontalLineMenuItemFactory(accessor).tooltip).toBe('docs-ui.toolbar.horizontalLine'); - expect(InsertOrderListBellowMenuItemFactory(accessor).tooltip).toBe('docs-ui.rightClick.orderList'); - expect(InsertBulletListBellowMenuItemFactory(accessor).tooltip).toBe('docs-ui.rightClick.bulletList'); - expect(InsertHorizontalLineBellowMenuItemFactory(accessor).tooltip).toBe('docs-ui.toolbar.horizontalLine'); - expect(ParagraphMenuIndentIncreaseMenuItemFactory(accessor).tooltip).toBe('docs-ui.paragraphMenu.increaseIndent'); - expect(ParagraphMenuIndentDecreaseMenuItemFactory(accessor).tooltip).toBe('docs-ui.paragraphMenu.decreaseIndent'); - expect(ParagraphMenuIndentIncreaseMenuItemFactory(accessor).title).toBe('docs-ui.paragraphMenu.increase'); - expect(ParagraphMenuIndentDecreaseMenuItemFactory(accessor).title).toBe('docs-ui.paragraphMenu.decrease'); - }); - - it('renders paragraph text color swatches with an A glyph inside an outlined color chip', () => { - const registeredIcons = new Map>(); - const componentManager = { - get: (key: string) => registeredIcons.get(key), - register: (key: string, component: React.ComponentType<{ className?: string }>) => { - registeredIcons.set(key, component); - }, - }; - const accessor = { - get: () => componentManager, - } as never; - - const factory = ParagraphMenuTextColorSwatchMenuItemFactories['doc.menu.paragraph-t.text-color.0'].menuItemFactory; - const menuItem = factory(accessor); - const Icon = registeredIcons.get(menuItem.icon as string); - - expect(Icon).toBeDefined(); - expect(menuItem.tooltip).toBeUndefined(); - - const markup = renderToStaticMarkup(React.createElement(Icon!, { className: 'swatch-icon' })); - - expect(markup).toContain('>A<'); - expect(markup.match(/ { - const registeredIcons = new Map>(); - const componentManager = { - get: (key: string) => registeredIcons.get(key), - register: (key: string, component: React.ComponentType<{ className?: string }>) => { - registeredIcons.set(key, component); - }, - }; - const accessor = { - get: () => componentManager, - } as never; - - const factory = ParagraphMenuBackgroundColorSwatchMenuItemFactories['doc.menu.paragraph-t.background-color.0'].menuItemFactory; - const menuItem = factory(accessor); - const Icon = registeredIcons.get(menuItem.icon as string); - - expect(Icon).toBeDefined(); - expect(menuItem.tooltip).toBeUndefined(); - - const markup = renderToStaticMarkup(React.createElement(Icon!, { className: 'swatch-icon' })); - - expect(markup).not.toContain('>A<'); - expect(markup.match(/ { - const accessor = { - get: () => ({ - get: () => undefined, - register: () => undefined, - }), - } as never; - - expect(ParagraphMenuDefaultTextColorMenuItemFactory(accessor).tooltip).toBeUndefined(); - expect(ParagraphMenuNoBackgroundMenuItemFactory(accessor).tooltip).toBeUndefined(); - }); - - it('reuses the existing text color selector logic for the colors header action with an A icon', () => { - const registeredIcons = new Map>(); - const componentManager = { - get: (key: string) => registeredIcons.get(key), - register: (key: string, component: React.ComponentType<{ className?: string }>) => { - registeredIcons.set(key, component); - }, - }; - const accessor = { - get: () => componentManager, - } as never; - - const menuItem = ParagraphMenuTextColorHeaderActionMenuItemFactory(accessor); - const Icon = registeredIcons.get(menuItem.icon as string); - - expect(menuItem.type).toBe(MenuItemType.BUTTON_SELECTOR); - expect(menuItem.id).toBe(SetInlineFormatTextColorCommand.id); - expect(menuItem.icon).toBe('HeaderTextColorIcon'); - expect(menuItem.tooltip).toBeUndefined(); - expect(Array.isArray((menuItem as any).selections)).toBe(true); - expect(Icon).toBeDefined(); - - const markup = renderToStaticMarkup(React.createElement(Icon!, { className: 'header-color-icon' })); - - expect(markup).toContain('>A<'); - expect(markup).toContain('width="1em"'); - expect(markup).toContain('height="1em"'); - }); - - it('reuses the existing background color selector logic for the colors header action with the bucket icon', () => { - const accessor = { - get: () => ({ - get: () => undefined, - register: () => undefined, - }), - } as never; - - const menuItem = ParagraphMenuBackgroundColorHeaderActionMenuItemFactory(accessor); - - expect(menuItem.type).toBe(MenuItemType.BUTTON_SELECTOR); - expect(menuItem.id).toBe(SetInlineFormatTextBackgroundColorCommand.id); - expect(menuItem.icon).toBe('PaintBucketDoubleIcon'); - expect(menuItem.tooltip).toBeUndefined(); - expect(Array.isArray((menuItem as any).selections)).toBe(true); - }); - - it('opens the popup away from the drag handle when there is not enough left space', () => { - expect(getParagraphMenuPopupDirection(170)).toBe('right'); - expect(getParagraphMenuPopupDirection(260)).toBe('left'); - }); - - it('creates a hover bridge overlapping the trigger edge for left-side paragraph popups', () => { - expect(paragraphMenu.getParagraphMenuHoverBridgeStyle?.({ - left: 320, - right: 348, - top: 120, - bottom: 152, - }, 'left')).toEqual({ - left: 308, - top: 112, - width: 24, - height: 48, - }); - }); - - it('creates a hover bridge overlapping the trigger edge for right-side paragraph popups', () => { - expect(paragraphMenu.getParagraphMenuHoverBridgeStyle?.({ - left: 24, - right: 52, - top: 40, - bottom: 72, - }, 'right')).toEqual({ - left: 40, - top: 32, - width: 24, - height: 48, - }); - }); - - it('delays opening the paragraph popup for hover and cancels before the delay elapses', () => { - vi.useFakeTimers(); - const openMenu = vi.fn(); - const scheduler = createParagraphMenuHoverOpenScheduler(openMenu); - - scheduler.schedule(); - vi.advanceTimersByTime(PARAGRAPH_MENU_HOVER_OPEN_DELAY - 1); - - expect(openMenu).not.toHaveBeenCalled(); - - vi.advanceTimersByTime(1); - - expect(openMenu).toHaveBeenCalledTimes(1); - - openMenu.mockClear(); - scheduler.schedule(); - scheduler.cancel(); - vi.advanceTimersByTime(PARAGRAPH_MENU_HOVER_OPEN_DELAY); - - expect(openMenu).not.toHaveBeenCalled(); - }); - - it('opens the paragraph popup immediately for click', () => { - vi.useFakeTimers(); - const openMenu = vi.fn(); - const scheduler = createParagraphMenuHoverOpenScheduler(openMenu); - - scheduler.schedule(); - scheduler.openNow(); - - expect(openMenu).toHaveBeenCalledTimes(1); - - vi.advanceTimersByTime(PARAGRAPH_MENU_HOVER_OPEN_DELAY); - - expect(openMenu).toHaveBeenCalledTimes(1); - }); - - it('marks the paragraph menu interaction as active while hovering trigger, bridge, or popup', () => { - const setParagraphMenuActive = vi.fn(); - - setParagraphMenuInteractionActive({ setParagraphMenuActive } as never, true); - setParagraphMenuInteractionActive({ setParagraphMenuActive } as never, false); - - expect(setParagraphMenuActive).toHaveBeenNthCalledWith(1, true); - expect(setParagraphMenuActive).toHaveBeenNthCalledWith(2, false); - }); - - it('maps paragraph named styles to the active heading menu item', () => { - expect(getParagraphMenuActiveHeadingCommandId(NamedStyleType.HEADING_1)).toBe(H1HeadingCommand.id); - expect(getParagraphMenuActiveHeadingCommandId(NamedStyleType.HEADING_3)).toBe(H3HeadingCommand.id); - expect(getParagraphMenuActiveHeadingCommandId(NamedStyleType.NORMAL_TEXT)).toBe(NormalTextHeadingCommand.id); - expect(getParagraphMenuActiveHeadingCommandId(undefined)).toBe(NormalTextHeadingCommand.id); - expect(getParagraphMenuActiveHeadingCommandId(NamedStyleType.TITLE)).toBe(TitleHeadingCommand.id); - expect(getParagraphMenuActiveHeadingCommandId(NamedStyleType.SUBTITLE)).toBe(SubtitleHeadingCommand.id); - }); - - it('hides the alternate title shortcuts for the hovered paragraph style', () => { - expect(getParagraphMenuHiddenHeadingCommandIds(NamedStyleType.TITLE)).toEqual([ - H4HeadingCommand.id, - H5HeadingCommand.id, - SubtitleHeadingCommand.id, - ]); - expect(getParagraphMenuHiddenHeadingCommandIds(NamedStyleType.SUBTITLE)).toEqual([ - H4HeadingCommand.id, - H5HeadingCommand.id, - TitleHeadingCommand.id, - ]); - expect(getParagraphMenuHiddenHeadingCommandIds(NamedStyleType.NORMAL_TEXT)).toEqual([ - H5HeadingCommand.id, - TitleHeadingCommand.id, - SubtitleHeadingCommand.id, - ]); - }); - - it('keeps all six insert-state header icons visible for empty paragraphs', () => { - expect(getParagraphMenuHiddenItemIds( - DOC_PARAGRAPH_T_INSERT_MENU_ID, - { kind: 'paragraph' } as never, - NamedStyleType.NORMAL_TEXT - )).toEqual([]); - - expect(getParagraphMenuHiddenItemIds( - DOC_PARAGRAPH_T_EDIT_MENU_ID, - { kind: 'paragraph' } as never, - NamedStyleType.NORMAL_TEXT - )).toEqual([ - H5HeadingCommand.id, - TitleHeadingCommand.id, - SubtitleHeadingCommand.id, - ]); - }); - - it('shows paragraph settings only for paragraph and list menu targets', () => { - expect(shouldShowParagraphSettingMenu(null)).toBe(true); - expect(shouldShowParagraphSettingMenu({ kind: 'paragraph' } as never)).toBe(true); - expect(shouldShowParagraphSettingMenu({ kind: 'paragraph', icon: 'OrderIcon' } as never)).toBe(true); - expect(shouldShowParagraphSettingMenu({ kind: 'blockRange' } as never)).toBe(false); - expect(shouldShowParagraphSettingMenu({ kind: 'table' } as never)).toBe(false); - expect(shouldShowParagraphSettingMenu({ kind: 'customBlock' } as never)).toBe(false); - }); - - it('detects empty paragraph menu targets', () => { - const paragraph = { - paragraphStart: 2, - paragraphEnd: 2, - }; - const nonEmptyParagraph = { - paragraphStart: 2, - paragraphEnd: 3, - }; - - expect(isEmptyParagraphMenuTarget('a\r\r', paragraph as never)).toBe(true); - expect(isEmptyParagraphMenuTarget('a\r\r', { paragraphStart: 1, paragraphEnd: 2 } as never)).toBe(true); - expect(isEmptyParagraphMenuTarget('a\n\n', { paragraphStart: 1, paragraphEnd: 2 } as never)).toBe(true); - expect(isEmptyParagraphMenuTarget('a\rb\r', nonEmptyParagraph as never)).toBe(false); - }); - - it('builds a collapsed selection range for the hovered paragraph', () => { - expect(getParagraphMenuTargetRange({ - paragraphStart: 3, - paragraphEnd: 8, - segmentId: 'header-1', - } as never)).toEqual({ - collapsed: true, - endOffset: 3, - segmentId: 'header-1', - startOffset: 3, - }); - }); - - it('builds a full formatting range for whole-paragraph color actions', () => { - expect(getParagraphFormattingRange({ - kind: 'paragraph', - menuRange: { - startOffset: 3, - endOffset: 3, - collapsed: true, - }, - } as never, { - paragraphStart: 3, - paragraphEnd: 8, - segmentId: 'header-1', - } as never)).toEqual({ - collapsed: false, - endOffset: 8, - segmentId: 'header-1', - startOffset: 3, - }); - - expect(getParagraphFormattingRange({ - kind: 'blockRange', - blockRange: { - startIndex: 6, - endIndex: 14, - }, - menuRange: { - startOffset: 6, - endOffset: 15, - collapsed: false, - }, - } as never, { - segmentId: 'body', - } as never)).toEqual({ - collapsed: false, - endOffset: 15, - segmentId: 'body', - startOffset: 6, - }); - }); - - it('uses the formatting range for whole-paragraph selection commands', () => { - const targetRange = { startOffset: 3, endOffset: 3, collapsed: true }; - const formattingRange = { startOffset: 3, endOffset: 8, collapsed: false }; - - expect(getParagraphMenuCommandTargetRange(SetInlineFormatTextColorCommand.id, targetRange as never, formattingRange as never)).toEqual(formattingRange); - expect(getParagraphMenuCommandTargetRange(H1HeadingCommand.id, targetRange as never, formattingRange as never)).toEqual(targetRange); - }); - - it('preserves context menu command params for paragraph menu actions', () => { - expect(getParagraphMenuCommand({ - commandId: CreateDocTableCommand.id, - id: 'doc.operation.create-table', - label: 'doc.operation.create-table', - params: { rowCount: 3, colCount: 5 }, - })).toEqual({ - commandId: CreateDocTableCommand.id, - params: { rowCount: 3, colCount: 5 }, - }); - - expect(getParagraphMenuCommand({ - label: 'doc.command.h1-heading', - }, { startOffset: 3, endOffset: 3, collapsed: true })).toEqual({ - commandId: SetParagraphNamedStyleCommand.id, - params: { - value: NamedStyleType.HEADING_1, - textRanges: [{ startOffset: 3, endOffset: 3, collapsed: true }], - }, - }); - }); - - it('preserves custom color values when resolving paragraph menu commands', () => { - expect(getParagraphMenuResolvedCommand({ - id: SetInlineFormatTextColorCommand.id, - value: '#ff5500', - }, null)).toEqual({ - commandId: SetInlineFormatTextColorCommand.id, - params: { value: '#ff5500' }, - }); - - expect(getParagraphMenuResolvedCommand({ - id: SetInlineFormatTextBackgroundColorCommand.id, - value: 'rgba(255, 140, 81, 0.3)', - }, null)).toEqual({ - commandId: SetInlineFormatTextBackgroundColorCommand.id, - params: { value: 'rgba(255, 140, 81, 0.3)' }, - }); - }); - - it('passes the hovered paragraph range to current-paragraph menu commands', () => { - const targetRange = { startOffset: 3, endOffset: 3, collapsed: true }; - - expect(getParagraphMenuCommand({ - label: BulletListCommand.id, - }, targetRange)).toEqual({ - commandId: BulletListCommand.id, - params: { docRange: [targetRange] }, - }); - expect(getParagraphMenuCommand({ - label: OrderListCommand.id, - }, targetRange)).toEqual({ - commandId: OrderListCommand.id, - params: { docRange: [targetRange] }, - }); - expect(getParagraphMenuCommand({ - label: HorizontalLineCommand.id, - }, targetRange)).toEqual({ - commandId: HorizontalLineCommand.id, - params: { insertRange: targetRange }, - }); - expect(getParagraphMenuCommand({ - label: H1HeadingCommand.id, - }, null)).toEqual({ - commandId: H1HeadingCommand.id, - params: undefined, - }); - }); - - it('detects menu commands that should use the hovered block insert-below anchor', () => { - expect(shouldUseInsertBelowRange(InsertBulletListBellowCommand.id, { - id: InsertBulletListBellowCommand.id, - })).toBe(true); - expect(shouldUseInsertBelowRange('docs-callout.command.insert-below', { - id: 'docs-callout.command.insert-below', - })).toBe(true); - expect(shouldUseInsertBelowRange('doc.command.insert-float-image', { - id: 'doc.command.insert-float-image', - })).toBe(true); - expect(shouldUseInsertBelowRange(CreateDocTableCommand.id, { - id: 'doc.operation.create-table', - })).toBe(true); - expect(shouldUseInsertBelowRange(H1HeadingCommand.id, { - id: H1HeadingCommand.id, - })).toBe(false); - expect(shouldUseInsertBelowRange(H1HeadingCommand.id, { - id: INSERT_BELLOW_MENU_ID, - })).toBe(true); - }); - - it('releases the paragraph menu service before returning focus after command execution', () => { - const calls: string[] = []; - - finishParagraphMenuCommand( - { - hideParagraphMenu: vi.fn(() => calls.push('service')), - } as never, - { - focus: vi.fn(() => calls.push('focus')), - } as never, - () => calls.push('ui') - ); - - expect(calls).toEqual(['service', 'ui', 'focus']); - }); -}); diff --git a/packages/docs-ui/src/controllers/doc-ui.controller.ts b/packages/docs-ui/src/controllers/doc-ui.controller.ts index d727401ee1..b45b72d041 100644 --- a/packages/docs-ui/src/controllers/doc-ui.controller.ts +++ b/packages/docs-ui/src/controllers/doc-ui.controller.ts @@ -28,8 +28,6 @@ import { DeleteIcon, DocSettingIcon, TodoListDoubleIcon } from '@univerjs/icons' import { BuiltInUIPart, ComponentManager, connectInjector, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui'; import { CoreHeaderFooterCommand, OpenHeaderFooterPanelCommand } from '../commands/commands/doc-header-footer.command'; import { SidebarDocHeaderFooterPanelOperation } from '../commands/operations/doc-header-footer-panel.operation'; -import { BULLET_LIST_TYPE_COMPONENT, BulletListTypePicker, ORDER_LIST_TYPE_COMPONENT, OrderListTypePicker } from '../components/list-type-picker'; -import { DOC_PARAGRAPH_MENU_COMPONENT_KEY, DOC_TABLE_BLOCK_MENU_COMPONENT_KEY, ParagraphMenu, TableBlockMenu } from '../components/paragraph-menu'; import { floatToolbarMenuSchema, menuSchema } from '../menu/schema'; import { DocSelectionRenderService } from '../services/selection/doc-selection-render.service'; import { TabShortCut } from '../shortcuts/format.shortcut'; @@ -48,8 +46,10 @@ import { UnderlineShortCut, } from '../shortcuts/toolbar.shortcut'; import { DocFooter } from '../views/doc-footer'; -import { PAGE_SETTING_COMPONENT_ID, PageSettings } from '../views/page-settings'; -import { DocSideMenu } from '../views/side-menu'; +import { DocSideMenu } from '../views/DocSideMenu'; +import { BULLET_LIST_TYPE_COMPONENT, BulletListTypePicker, ORDER_LIST_TYPE_COMPONENT, OrderListTypePicker } from '../views/list-type-picker/index'; +import { PAGE_SETTING_COMPONENT_ID, PageSettings } from '../views/PageSettings'; +import { DOC_PARAGRAPH_MENU_COMPONENT_KEY, DOC_TABLE_BLOCK_MENU_COMPONENT_KEY, ParagraphMenu, TableBlockMenu } from '../views/ParagraphMenu'; export class DocUIController extends Disposable { constructor( diff --git a/packages/docs-ui/src/index.ts b/packages/docs-ui/src/index.ts index 6de8afa3fd..91c2e0714e 100644 --- a/packages/docs-ui/src/index.ts +++ b/packages/docs-ui/src/index.ts @@ -167,5 +167,5 @@ export { getCanvasOffsetByEngine } from './services/selection/selection-utils'; export { getAnchorBounding, getLineBounding, TEXT_RANGE_LAYER_INDEX, TextRange } from './services/selection/text-range'; export { whenDocAndEditorFocused } from './shortcuts/utils'; export { DOC_VERTICAL_PADDING } from './types/const/padding'; -export { type IRichTextEditorProps, RichTextEditor } from './views/rich-text-editor'; export { type IKeyboardEventConfig, useEditor, useEditorClickOutside, useIsFocusing, useKeyboardEvent, useLeftAndRightArrow, useOnChange, useResize } from './views/rich-text-editor/hooks'; +export { type IRichTextEditorProps, RichTextEditor } from './views/RichTextEditor'; diff --git a/packages/docs-ui/src/menu/menu.ts b/packages/docs-ui/src/menu/menu.ts index 541a769966..391f15805a 100644 --- a/packages/docs-ui/src/menu/menu.ts +++ b/packages/docs-ui/src/menu/menu.ts @@ -68,8 +68,8 @@ import { CreateDocTableCommand } from '../commands/commands/table/doc-table-crea import { DocCreateTableOperation } from '../commands/operations/doc-create-table.operation'; import { DocOpenPageSettingCommand } from '../commands/operations/open-page-setting.operation'; import { getCommandSkeleton } from '../commands/util'; -import { BULLET_LIST_TYPE_COMPONENT, ORDER_LIST_TYPE_COMPONENT } from '../components/list-type-picker'; import { DocMenuStyleService } from '../services/doc-menu-style.service'; +import { BULLET_LIST_TYPE_COMPONENT, ORDER_LIST_TYPE_COMPONENT } from '../views/list-type-picker/index'; function getInsertTableHiddenObservable( accessor: IAccessor diff --git a/packages/docs-ui/src/services/__tests__/doc-paragraph-menu.service.spec.ts b/packages/docs-ui/src/services/__tests__/doc-paragraph-menu.service.spec.ts index 907896155b..3760c6b222 100644 --- a/packages/docs-ui/src/services/__tests__/doc-paragraph-menu.service.spec.ts +++ b/packages/docs-ui/src/services/__tests__/doc-paragraph-menu.service.spec.ts @@ -19,7 +19,7 @@ import { DataStreamTreeTokenType, DOC_RANGE_TYPE, DocumentBlockRangeType, Preset import { DocumentEditArea } from '@univerjs/engine-render'; import { BehaviorSubject, Subject } from 'rxjs'; import { describe, expect, it, vi } from 'vitest'; -import { DOC_PARAGRAPH_MENU_COMPONENT_KEY, DOC_TABLE_BLOCK_MENU_COMPONENT_KEY } from '../../components/paragraph-menu'; +import { DOC_PARAGRAPH_MENU_COMPONENT_KEY, DOC_TABLE_BLOCK_MENU_COMPONENT_KEY } from '../../views/ParagraphMenu'; import { getPreferredParagraphBoundsInRange, getTableBlockMenuHoverRect, getTableHorizontalViewportGeometry } from '../doc-event-manager.service'; import { DocParagraphMenuService } from '../doc-paragraph-menu.service'; diff --git a/packages/docs-ui/src/services/doc-paragraph-menu.service.ts b/packages/docs-ui/src/services/doc-paragraph-menu.service.ts index 5136a7534b..7a6bdce9b9 100644 --- a/packages/docs-ui/src/services/doc-paragraph-menu.service.ts +++ b/packages/docs-ui/src/services/doc-paragraph-menu.service.ts @@ -23,7 +23,7 @@ import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs import { DocumentEditArea } from '@univerjs/engine-render'; import { BehaviorSubject, combineLatest, first, throttleTime } from 'rxjs'; import { VIEWPORT_KEY } from '../basics/docs-view-key'; -import { DOC_PARAGRAPH_MENU_COMPONENT_KEY, DOC_TABLE_BLOCK_MENU_COMPONENT_KEY } from '../components/paragraph-menu/component-keys'; +import { DOC_PARAGRAPH_MENU_COMPONENT_KEY, DOC_TABLE_BLOCK_MENU_COMPONENT_KEY } from '../views/paragraph-menu/component-keys'; import { DocEventManagerService } from './doc-event-manager.service'; import { calcDocRangePositions, DocCanvasPopManagerService, transformBound2OffsetBound, transformOffset2Bound } from './doc-popup-manager.service'; import { DocFloatMenuService } from './float-menu.service'; diff --git a/packages/docs-ui/src/services/doc-zoom.ts b/packages/docs-ui/src/services/doc-zoom.ts index 3ee69e3e35..f43a750aac 100644 --- a/packages/docs-ui/src/services/doc-zoom.ts +++ b/packages/docs-ui/src/services/doc-zoom.ts @@ -18,7 +18,7 @@ import type { DocumentDataModel } from '@univerjs/core'; import { DocumentFlavor } from '@univerjs/core'; const DEFAULT_DOC_ZOOM_RATIO = 1; -export const DEFAULT_MODERN_DOC_ZOOM_RATIO = 1.2; +export const DEFAULT_MODERN_DOC_ZOOM_RATIO = 1; type DocZoomSource = Pick; diff --git a/packages/docs-ui/src/services/float-menu.service.ts b/packages/docs-ui/src/services/float-menu.service.ts index ef318c775d..373e4c3b3b 100644 --- a/packages/docs-ui/src/services/float-menu.service.ts +++ b/packages/docs-ui/src/services/float-menu.service.ts @@ -19,7 +19,7 @@ import type { INodePosition, IRenderContext, IRenderModule, ITextRangeWithStyle import { DataStreamTreeTokenType, deepCompare, Disposable, DocumentBlockRangeType, Inject, isInternalEditorID, IUniverInstanceService, toDisposable, UniverInstanceType } from '@univerjs/core'; import { DocSelectionManagerService } from '@univerjs/docs'; import { ComponentManager } from '@univerjs/ui'; -import { FloatToolbar } from '../components/float-toolbar/FloatToolbar'; +import { FloatToolbar } from '../views/float-toolbar/FloatToolbar'; import { DocCanvasPopManagerService } from './doc-popup-manager.service'; import { DocSelectionRenderService } from './selection/doc-selection-render.service'; diff --git a/packages/docs-ui/src/views/side-menu/index.tsx b/packages/docs-ui/src/views/DocSideMenu.tsx similarity index 94% rename from packages/docs-ui/src/views/side-menu/index.tsx rename to packages/docs-ui/src/views/DocSideMenu.tsx index d7e431992b..acb03a7e36 100644 --- a/packages/docs-ui/src/views/side-menu/index.tsx +++ b/packages/docs-ui/src/views/DocSideMenu.tsx @@ -16,19 +16,19 @@ import type { DocumentDataModel, IParagraph } from '@univerjs/core'; import type { IRichTextEditingMutationParams } from '@univerjs/docs'; -import type { ISideMenuItem } from '../../components/side-menu'; -import type { IUniverDocsUIConfig } from '../../config/config'; -import type { IMutiPageParagraphBound } from '../../services/doc-event-manager.service'; +import type { IUniverDocsUIConfig } from '../config/config'; +import type { IMutiPageParagraphBound } from '../services/doc-event-manager.service'; +import type { ISideMenuItem } from './SideMenu'; import { debounce, fromEventSubject, getPlainText, ICommandService, isInternalEditorID, IUniverInstanceService, NamedStyleType, UniverInstanceType } from '@univerjs/core'; import { RichTextEditingMutation } from '@univerjs/docs'; import { IRenderManagerService } from '@univerjs/engine-render'; import { useConfigValue, useDependency, useEvent, useObservable } from '@univerjs/ui'; import { useEffect, useMemo, useState } from 'react'; import { of, throttleTime } from 'rxjs'; -import { VIEWPORT_KEY } from '../../basics/docs-view-key'; -import { SideMenu } from '../../components/side-menu'; -import { DOCS_UI_PLUGIN_CONFIG_KEY } from '../../config/config'; -import { DocEventManagerService } from '../../services/doc-event-manager.service'; +import { VIEWPORT_KEY } from '../basics/docs-view-key'; +import { DOCS_UI_PLUGIN_CONFIG_KEY } from '../config/config'; +import { DocEventManagerService } from '../services/doc-event-manager.service'; +import { SideMenu } from './SideMenu'; const transformNamedStyleTypeToLevel = (type: NamedStyleType) => { switch (type) { diff --git a/packages/docs-ui/src/views/page-settings/index.tsx b/packages/docs-ui/src/views/PageSettings.tsx similarity index 100% rename from packages/docs-ui/src/views/page-settings/index.tsx rename to packages/docs-ui/src/views/PageSettings.tsx diff --git a/packages/docs-ui/src/components/paragraph-menu/index.tsx b/packages/docs-ui/src/views/ParagraphMenu.tsx similarity index 96% rename from packages/docs-ui/src/components/paragraph-menu/index.tsx rename to packages/docs-ui/src/views/ParagraphMenu.tsx index 8b262a610b..e26d846db3 100644 --- a/packages/docs-ui/src/components/paragraph-menu/index.tsx +++ b/packages/docs-ui/src/views/ParagraphMenu.tsx @@ -18,8 +18,8 @@ import type { DocumentDataModel, IDocumentBlockRange, IDocumentBody, IParagraph, import type { ITextRangeWithStyle } from '@univerjs/engine-render'; import type { IPopup, IValueOption, RectPopupDirection } from '@univerjs/ui'; import type { CSSProperties } from 'react'; -import type { IMutiPageParagraphBound } from '../../services/doc-event-manager.service'; -import type { IDocBlockMenuTarget } from '../../services/doc-paragraph-menu.service'; +import type { IMutiPageParagraphBound } from '../services/doc-event-manager.service'; +import type { IDocBlockMenuTarget } from '../services/doc-paragraph-menu.service'; import { DataStreamTreeTokenType, DocumentBlockRangeType, ICommandService, IUniverInstanceService, JSONX, NamedStyleType, SliceBodyType, Tools, UniverInstanceType } from '@univerjs/core'; import { clsx } from '@univerjs/design'; import { DocContentInsertService, DocSelectionManagerService, RichTextEditingMutation } from '@univerjs/docs'; @@ -27,17 +27,17 @@ import { IRenderManagerService } from '@univerjs/engine-render'; import { ComponentManager, ContextMenuPanel, IClipboardInterfaceService, ILayoutService, RectPopup, useDependency, useObservable } from '@univerjs/ui'; import { useEffect, useMemo, useRef, useState } from 'react'; import { BehaviorSubject } from 'rxjs'; -import { BreakLineCommand } from '../../commands/commands/break-line.command'; -import { DocCopyCommand, DocCopyCurrentParagraphCommand, DocCutCurrentParagraphCommand, DocPasteCommand } from '../../commands/commands/clipboard.command'; -import { MoveDocBlockCommand } from '../../commands/commands/doc-block-move.command'; -import { DeleteCurrentParagraphCommand } from '../../commands/commands/doc-delete.command'; -import { HorizontalLineCommand } from '../../commands/commands/doc-horizontal-line.command'; -import { DocParagraphSettingCommand } from '../../commands/commands/doc-paragraph-setting.command'; -import { ResetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand } from '../../commands/commands/inline-format.command'; -import { BulletListCommand, CheckListCommand, OrderListCommand } from '../../commands/commands/list.command'; -import { AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignRightCommand } from '../../commands/commands/paragraph-align.command'; -import { H1HeadingCommand, H2HeadingCommand, H3HeadingCommand, H4HeadingCommand, H5HeadingCommand, NormalTextHeadingCommand, SetParagraphNamedStyleCommand, SubtitleHeadingCommand, TitleHeadingCommand } from '../../commands/commands/set-heading.command'; -import { DocTableDeleteTableCommand } from '../../commands/commands/table/doc-table-delete.command'; +import { BreakLineCommand } from '../commands/commands/break-line.command'; +import { DocCopyCommand, DocCopyCurrentParagraphCommand, DocCutCurrentParagraphCommand, DocPasteCommand } from '../commands/commands/clipboard.command'; +import { MoveDocBlockCommand } from '../commands/commands/doc-block-move.command'; +import { DeleteCurrentParagraphCommand } from '../commands/commands/doc-delete.command'; +import { HorizontalLineCommand } from '../commands/commands/doc-horizontal-line.command'; +import { DocParagraphSettingCommand } from '../commands/commands/doc-paragraph-setting.command'; +import { ResetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand } from '../commands/commands/inline-format.command'; +import { BulletListCommand, CheckListCommand, OrderListCommand } from '../commands/commands/list.command'; +import { AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignRightCommand } from '../commands/commands/paragraph-align.command'; +import { H1HeadingCommand, H2HeadingCommand, H3HeadingCommand, H4HeadingCommand, H5HeadingCommand, NormalTextHeadingCommand, SetParagraphNamedStyleCommand, SubtitleHeadingCommand, TitleHeadingCommand } from '../commands/commands/set-heading.command'; +import { DocTableDeleteTableCommand } from '../commands/commands/table/doc-table-delete.command'; import { DOC_PARAGRAPH_T_DIVIDER_MENU_ID, DOC_PARAGRAPH_T_EDIT_MENU_ID, @@ -49,20 +49,12 @@ import { DOC_TABLE_BLOCK_MENU_ID, HEADING_ICON_MAP, INSERT_BELLOW_MENU_ID, -} from '../../menu/paragraph-menu'; -import { IDocClipboardService } from '../../services/clipboard/clipboard.service'; -import { DocEventManagerService } from '../../services/doc-event-manager.service'; -import { DocParagraphMenuService } from '../../services/doc-paragraph-menu.service'; +} from '../menu/paragraph-menu'; +import { IDocClipboardService } from '../services/clipboard/clipboard.service'; +import { DocEventManagerService } from '../services/doc-event-manager.service'; +import { DocParagraphMenuService } from '../services/doc-paragraph-menu.service'; -export { DOC_PARAGRAPH_MENU_COMPONENT_KEY, DOC_TABLE_BLOCK_MENU_COMPONENT_KEY } from './component-keys'; - -export function getParagraphMenuIconSizeClass(iconKey: string): string { - return iconKey === 'TextTypeIcon' ? 'univer-size-3' : 'univer-size-4'; -} - -export function getParagraphMenuContextMenuSizeVariant(): 'paragraph-t' { - return 'paragraph-t'; -} +export { DOC_PARAGRAPH_MENU_COMPONENT_KEY, DOC_TABLE_BLOCK_MENU_COMPONENT_KEY } from './paragraph-menu/component-keys'; export function getParagraphMenuPopupDirection(anchorLeft: number, menuWidth = 212, viewportPadding = 8): 'left' | 'right' { return anchorLeft - menuWidth < viewportPadding ? 'right' : 'left'; @@ -981,15 +973,7 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }: { popup: IPopup; t hoverOpenSchedulerRef.current.openNow(); }} > - + {currentActiveTarget?.draggable && ( + + {item.icon} + + + ); })} @@ -205,7 +199,7 @@ export function ParagraphSetting() {