Skip to content

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

feat: doc support quick-insert menu (#4826)

siam976c0d19ea37
diff --git a/common/shared/package.json b/common/shared/package.json
index 4bcf927e96..923bbc106a 100644
--- a/common/shared/package.json
+++ b/common/shared/package.json
@@ -44,8 +44,8 @@
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
- "@univerjs/icons": "^0.2.21",
- "@univerjs/icons-svg": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
+ "@univerjs/icons-svg": "^0.2.22",
"@univerjs/protocol": "0.1.44"
}
}
diff --git a/examples/package.json b/examples/package.json
index 406d381c43..34209d79f0 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -27,6 +27,7 @@
"@univerjs/docs-drawing-ui": "workspace:*",
"@univerjs/docs-hyper-link-ui": "workspace:*",
"@univerjs/docs-mention-ui": "workspace:*",
+ "@univerjs/docs-quick-insert-ui": "workspace:*",
"@univerjs/docs-thread-comment-ui": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/drawing": "workspace:*",
diff --git a/examples/src/docs/main.ts b/examples/src/docs/main.ts
index 00335931e4..dae7907ae7 100644
--- a/examples/src/docs/main.ts
+++ b/examples/src/docs/main.ts
@@ -22,6 +22,7 @@ import { UniverDocsPlugin } from '@univerjs/docs';
import { UniverDocsDrawingUIPlugin } from '@univerjs/docs-drawing-ui';
import { UniverDocsHyperLinkUIPlugin } from '@univerjs/docs-hyper-link-ui';
import { UniverDocsMentionUIPlugin } from '@univerjs/docs-mention-ui';
+import { UniverDocsQuickInsertUIPlugin } from '@univerjs/docs-quick-insert-ui';
import { UniverDocsThreadCommentUIPlugin } from '@univerjs/docs-thread-comment-ui';
import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
@@ -70,6 +71,7 @@ univer.registerPlugin(UniverDocsDrawingUIPlugin);
univer.registerPlugin(UniverDocsThreadCommentUIPlugin);
univer.registerPlugin(UniverDocsHyperLinkUIPlugin);
univer.registerPlugin(UniverDocsMentionUIPlugin);
+univer.registerPlugin(UniverDocsQuickInsertUIPlugin);
if (!IS_E2E) {
univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_CN);
diff --git a/packages-experimental/action-recorder/package.json b/packages-experimental/action-recorder/package.json
index aca935a3a5..0f354ed85b 100644
--- a/packages-experimental/action-recorder/package.json
+++ b/packages-experimental/action-recorder/package.json
@@ -68,7 +68,7 @@
"dependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-filter": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
diff --git a/packages-experimental/debugger/package.json b/packages-experimental/debugger/package.json
index de99e6c4a3..bb36f26192 100644
--- a/packages-experimental/debugger/package.json
+++ b/packages-experimental/debugger/package.json
@@ -69,7 +69,7 @@
"@univerjs/docs-drawing-ui": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/mockdata": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-drawing-ui": "workspace:*",
diff --git a/packages-experimental/uni-formula-ui/package.json b/packages-experimental/uni-formula-ui/package.json
index 02aa8650b9..ae3b9b91ad 100644
--- a/packages-experimental/uni-formula-ui/package.json
+++ b/packages-experimental/uni-formula-ui/package.json
@@ -71,7 +71,7 @@
"@univerjs/docs": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/rpc": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
"@univerjs/sheets-formula-ui": "workspace:*",
diff --git a/packages-experimental/uni-sheets-ui/package.json b/packages-experimental/uni-sheets-ui/package.json
index e6ed3bfab7..31f85ceca6 100644
--- a/packages-experimental/uni-sheets-ui/package.json
+++ b/packages-experimental/uni-sheets-ui/package.json
@@ -64,7 +64,7 @@
"@univerjs/design": "workspace:*",
"@univerjs/docs": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-drawing-ui": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
diff --git a/packages-experimental/uni-slides-ui/package.json b/packages-experimental/uni-slides-ui/package.json
index 11bc0475fd..e4ccbaa912 100644
--- a/packages-experimental/uni-slides-ui/package.json
+++ b/packages-experimental/uni-slides-ui/package.json
@@ -62,7 +62,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/slides-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
"@univerjs/uniui": "workspace:*"
diff --git a/packages-experimental/uniui/package.json b/packages-experimental/uniui/package.json
index 38ade4c1d0..51f13f5df3 100644
--- a/packages-experimental/uniui/package.json
+++ b/packages-experimental/uniui/package.json
@@ -65,7 +65,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
diff --git a/packages/design/package.json b/packages/design/package.json
index 435e867191..80f6568fd4 100644
--- a/packages/design/package.json
+++ b/packages/design/package.json
@@ -73,7 +73,7 @@
"@radix-ui/react-separator": "^1.1.2",
"@radix-ui/react-tooltip": "^1.1.8",
"@rc-component/trigger": "^2.2.6",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"clsx": "^2.1.1",
"dayjs": "^1.11.13",
"rc-dialog": "^9.6.0",
diff --git a/packages/docs-drawing-ui/package.json b/packages/docs-drawing-ui/package.json
index 195900c8e4..a187b7bf59 100644
--- a/packages/docs-drawing-ui/package.json
+++ b/packages/docs-drawing-ui/package.json
@@ -74,7 +74,7 @@
"@univerjs/drawing": "workspace:*",
"@univerjs/drawing-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/ui": "workspace:*"
},
"devDependencies": {
diff --git a/packages/docs-hyper-link-ui/package.json b/packages/docs-hyper-link-ui/package.json
index c48acd2ec2..39de9874c9 100644
--- a/packages/docs-hyper-link-ui/package.json
+++ b/packages/docs-hyper-link-ui/package.json
@@ -72,7 +72,7 @@
"@univerjs/docs-hyper-link": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/ui": "workspace:*"
},
"devDependencies": {
diff --git a/packages/docs-quick-insert-ui/README.md b/packages/docs-quick-insert-ui/README.md
new file mode 100644
index 0000000000..797c8280d5
--- /dev/null
+++ b/packages/docs-quick-insert-ui/README.md
@@ -0,0 +1,27 @@
+# @univerjs/docs-quick-insert-ui
+
+## Package Overview
+
+| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
+| --- | --- | --- | --- | --- | :---: | :---: |
+| `@univerjs/docs-quick-insert-ui` | `UniverDocsDrawingUi` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ⭕️ | ⭕️ |
+
+## Introduction
+
+## Usage
+
+### Installation
+
+```shell
+# Using npm
+npm install @univerjs/docs-quick-insert-ui
+
+# Using pnpm
+pnpm add @univerjs/docs-quick-insert-ui
+```
+
+<!-- Links -->
+[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/docs-quick-insert-ui?style=flat-square
+[npm-version-link]: https://npmjs.com/package/@univerjs/docs-quick-insert-ui
+[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/docs-quick-insert-ui?style=flat-square
+[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/docs-quick-insert-ui?style=flat-square
diff --git a/packages/docs-quick-insert-ui/package.json b/packages/docs-quick-insert-ui/package.json
new file mode 100644
index 0000000000..6e7b1b6e48
--- /dev/null
+++ b/packages/docs-quick-insert-ui/package.json
@@ -0,0 +1,91 @@
+{
+ "name": "@univerjs/docs-quick-insert-ui",
+ "version": "0.6.4",
+ "private": false,
+ "description": "",
+ "author": "DreamNum <[email protected]>",
+ "license": "Apache-2.0",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/univer"
+ },
+ "homepage": "https://univer.ai",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dream-num/univer"
+ },
+ "bugs": {
+ "url": "https://github.com/dream-num/univer/issues"
+ },
+ "keywords": [],
+ "exports": {
+ ".": "./src/index.ts",
+ "./*": "./src/*",
+ "./locale/*": "./src/locale/*.ts"
+ },
+ "main": "./src/index.ts",
+ "types": "./lib/types/index.d.ts",
+ "publishConfig": {
+ "access": "public",
+ "main": "./lib/es/index.js",
+ "module": "./lib/es/index.js",
+ "exports": {
+ ".": {
+ "import": "./lib/es/index.js",
+ "require": "./lib/cjs/index.js",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./*": {
+ "import": "./lib/es/*",
+ "require": "./lib/cjs/*",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./locale/*": {
+ "import": "./lib/es/locale/*.js",
+ "require": "./lib/cjs/locale/*.js",
+ "types": "./lib/types/locale/*.d.ts"
+ },
+ "./lib/*": "./lib/*"
+ }
+ },
+ "directories": {
+ "lib": "lib"
+ },
+ "files": [
+ "lib"
+ ],
+ "scripts": {
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "coverage": "vitest run --coverage",
+ "lint:types": "tsc --noEmit",
+ "build": "univer-cli build"
+ },
+ "peerDependencies": {
+ "react": ">=16.9.0 || >=17 || >=18 || >=19",
+ "rxjs": ">=7.0.0"
+ },
+ "dependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/design": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/docs-drawing": "workspace:*",
+ "@univerjs/docs-ui": "workspace:*",
+ "@univerjs/drawing": "workspace:*",
+ "@univerjs/drawing-ui": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/icons": "^0.2.22",
+ "@univerjs/ui": "workspace:*"
+ },
+ "devDependencies": {
+ "@univerjs-infra/shared": "workspace:*",
+ "less": "^4.2.2",
+ "postcss": "^8.5.3",
+ "react": "18.3.1",
+ "rxjs": "^7.8.1",
+ "tailwindcss": "^3.4.17",
+ "typescript": "^5.8.2",
+ "vite": "^6.2.1",
+ "vitest": "^3.0.8"
+ }
+}
diff --git a/packages/docs-quick-insert-ui/postcss.config.mjs b/packages/docs-quick-insert-ui/postcss.config.mjs
new file mode 100644
index 0000000000..7d59f53133
--- /dev/null
+++ b/packages/docs-quick-insert-ui/postcss.config.mjs
@@ -0,0 +1 @@
+export { default } from '@univerjs-infra/shared/postcss';
diff --git a/packages/docs-quick-insert-ui/src/commands/commands/doc-quick-insert.command.ts b/packages/docs-quick-insert-ui/src/commands/commands/doc-quick-insert.command.ts
new file mode 100644
index 0000000000..c4c2d7322b
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/commands/commands/doc-quick-insert.command.ts
@@ -0,0 +1,50 @@
+/**
+ * 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 type { ICommand } from '@univerjs/core';
+import type { IInnerCutCommandParams } from '@univerjs/docs-ui';
+import { CommandType, ICommandService, RANGE_DIRECTION } from '@univerjs/core';
+import { CutContentCommand } from '@univerjs/docs-ui';
+
+interface IDeleteSearchKeyCommandParams {
+ start: number;
+ end: number;
+}
+
+export const DeleteSearchKeyCommand: ICommand<IDeleteSearchKeyCommandParams> = {
+ id: 'doc.command.delete-search-key',
+
+ type: CommandType.COMMAND,
+
+ handler: (accessor, params: IDeleteSearchKeyCommandParams) => {
+ const commandService = accessor.get(ICommandService);
+ const { start, end } = params;
+ return commandService.syncExecuteCommand(CutContentCommand.id, {
+ segmentId: '',
+ textRanges: [{
+ startOffset: start,
+ endOffset: start,
+ collapsed: true,
+ }],
+ selections: [{
+ startOffset: start,
+ endOffset: end,
+ collapsed: false,
+ direction: RANGE_DIRECTION.FORWARD,
+ }],
+ } as IInnerCutCommandParams);
+ },
+};
diff --git a/packages/docs-quick-insert-ui/src/commands/operations/quick-insert-popup.operation.ts b/packages/docs-quick-insert-ui/src/commands/operations/quick-insert-popup.operation.ts
new file mode 100644
index 0000000000..4b2cd4e474
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/commands/operations/quick-insert-popup.operation.ts
@@ -0,0 +1,54 @@
+/**
+ * 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 type { ICommand } from '@univerjs/core';
+import type { IDocPopup } from '../../services/doc-quick-insert-popup.service';
+import { CommandType } from '@univerjs/core';
+import { DocQuickInsertPopupService } from '../../services/doc-quick-insert-popup.service';
+
+export interface IShowQuickInsertPopupOperationParams {
+ unitId: string;
+ index: number;
+ popup: IDocPopup;
+}
+
+export const ShowQuickInsertPopupOperation: ICommand<IShowQuickInsertPopupOperationParams> = {
+ type: CommandType.OPERATION,
+ id: 'doc.operation.show-quick-insert-popup',
+ handler(accessor, params) {
+ const docQuickInsertPopupService = accessor.get(DocQuickInsertPopupService);
+
+ if (!params) {
+ return false;
+ }
+
+ docQuickInsertPopupService.showPopup(params);
+
+ return true;
+ },
+};
+
+export const CloseQuickInsertPopupOperation: ICommand = {
+ type: CommandType.OPERATION,
+ id: 'doc.operation.close-quick-insert-popup',
+ handler(accessor) {
+ const docQuickInsertPopupService = accessor.get(DocQuickInsertPopupService);
+
+ docQuickInsertPopupService.closePopup();
+
+ return true;
+ },
+};
diff --git a/packages/docs-quick-insert-ui/src/controllers/built-in-menus.ts b/packages/docs-quick-insert-ui/src/controllers/built-in-menus.ts
new file mode 100644
index 0000000000..64f5b67129
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/controllers/built-in-menus.ts
@@ -0,0 +1,70 @@
+/**
+ * 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 type { DocPopupMenu, IDocPopupMenuItem } from '../services/doc-quick-insert-popup.service';
+import { BulletListCommand, HorizontalLineCommand, OrderListCommand } from '@univerjs/docs-ui';
+
+export enum QuickInsertMenuGroup {
+ Basic = 'quick.insert.group.basic',
+ Media = 'quick.insert.group.media',
+}
+
+export const textMenu: IDocPopupMenuItem = {
+ id: 'quick-insert.text.menu',
+ title: 'docQuickInsert.menu.text',
+ icon: 'TextSingle',
+ keywords: ['text'],
+};
+
+export const numberedListMenu: IDocPopupMenuItem = {
+ id: OrderListCommand.id,
+ title: 'docQuickInsert.menu.numberedList',
+ icon: 'OrderSingle',
+ keywords: ['numbered', 'list', 'ordered'],
+};
+
+export const bulletedListMenu: IDocPopupMenuItem = {
+ id: BulletListCommand.id,
+ title: 'docQuickInsert.menu.bulletedList',
+ icon: 'UnorderSingle',
+ keywords: ['bulleted', 'list', 'unordered'],
+};
+
+export const dividerMenu: IDocPopupMenuItem = {
+ id: HorizontalLineCommand.id,
+ title: 'docQuickInsert.menu.divider',
+ icon: 'DividerSingle',
+ keywords: ['divider', 'line', 'separate'],
+};
+
+export const builtInMenus: DocPopupMenu[] = [
+ {
+ title: 'docQuickInsert.group.basics',
+ id: QuickInsertMenuGroup.Basic,
+ children: [
+ textMenu,
+ numberedListMenu,
+ bulletedListMenu,
+ dividerMenu,
+ ],
+ },
+];
+
+export const builtInMenuCommandIds = new Set([
+ numberedListMenu.id,
+ bulletedListMenu.id,
+ dividerMenu.id,
+]);
diff --git a/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-trigger.controller.ts b/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-trigger.controller.ts
new file mode 100644
index 0000000000..40b25202c9
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-trigger.controller.ts
@@ -0,0 +1,139 @@
+/**
+ * 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 type { IRichTextEditingMutationParams } from '@univerjs/docs';
+import type { IDeleteCommandParams, IInsertCommandParams, IMoveCursorOperationParams } from '@univerjs/docs-ui';
+import { DeleteDirection, Direction, Disposable, ICommandService, Inject } from '@univerjs/core';
+import { DocSelectionManagerService, RichTextEditingMutation } from '@univerjs/docs';
+import { DeleteCommand, DeleteLeftCommand, InsertCommand, MoveCursorOperation } from '@univerjs/docs-ui';
+import { IShortcutService, KeyCode } from '@univerjs/ui';
+import { CloseQuickInsertPopupOperation, ShowQuickInsertPopupOperation } from '../commands/operations/quick-insert-popup.operation';
+import { DocQuickInsertPopupService } from '../services/doc-quick-insert-popup.service';
+import { builtInMenuCommandIds, textMenu } from './built-in-menus';
+
+export class DocQuickInsertTriggerController extends Disposable {
+ constructor(
+ @ICommandService private readonly _commandService: ICommandService,
+ @Inject(DocSelectionManagerService) private readonly _textSelectionManagerService: DocSelectionManagerService,
+ @Inject(DocQuickInsertPopupService) private readonly _docQuickInsertPopupService: DocQuickInsertPopupService,
+ @Inject(IShortcutService) private readonly _shortcutService: IShortcutService
+ ) {
+ super();
+
+ this.disposeWithMe(this._shortcutService.registerShortcut({
+ id: CloseQuickInsertPopupOperation.id,
+ binding: KeyCode.ESC,
+ preconditions: () => Boolean(this._docQuickInsertPopupService.editPopup),
+ priority: 1000,
+ }));
+
+ this._initTrigger();
+ this._initMenuHandler();
+ }
+
+ private _initTrigger() {
+ this.disposeWithMe(
+ // eslint-disable-next-line complexity
+ this._commandService.onCommandExecuted((commandInfo) => {
+ const { _docQuickInsertPopupService, _textSelectionManagerService, _commandService } = this;
+ if (commandInfo.id === InsertCommand.id) {
+ const params = commandInfo.params as IInsertCommandParams;
+ if (_docQuickInsertPopupService.editPopup) {
+ _docQuickInsertPopupService.setInputOffset({
+ start: _docQuickInsertPopupService.inputOffset.start,
+ end: params.range.endOffset + 1,
+ });
+ return;
+ }
+
+ const activeRange = _textSelectionManagerService.getActiveTextRange();
+ if (!activeRange) {
+ return;
+ }
+
+ const popup = _docQuickInsertPopupService.resolvePopup(params.body.dataStream);
+ if (!popup) {
+ return;
+ }
+
+ const available = popup.preconditions ? popup.preconditions(params) : true;
+ if (!available) {
+ return;
+ }
+
+ _docQuickInsertPopupService.setInputOffset({ start: activeRange.startOffset - 1, end: activeRange.startOffset });
+
+ setTimeout(() => {
+ _commandService.executeCommand(ShowQuickInsertPopupOperation.id, {
+ index: activeRange.startOffset - 1,
+ unitId: params.unitId,
+ popup,
+ });
+ }, 100);
+ }
+
+ if (commandInfo.id === RichTextEditingMutation.id) {
+ const params = commandInfo.params as IRichTextEditingMutationParams;
+ if (params.isCompositionEnd) {
+ const endOffset = params.textRanges?.[0]?.endOffset;
+ if (endOffset) {
+ _docQuickInsertPopupService.setInputOffset({ start: _docQuickInsertPopupService.inputOffset.start, end: endOffset });
+ }
+ }
+ }
+
+ if (commandInfo.id === DeleteCommand.id) {
+ const params = commandInfo.params as IDeleteCommandParams;
+ if (_docQuickInsertPopupService.editPopup && params.direction === DeleteDirection.LEFT) {
+ const len = params.len ?? 0;
+ _docQuickInsertPopupService.setInputOffset({ start: _docQuickInsertPopupService.inputOffset.start, end: params.range.endOffset - len });
+ }
+ }
+
+ if (commandInfo.id === MoveCursorOperation.id) {
+ const params = commandInfo.params as IMoveCursorOperationParams;
+
+ if (params.direction === Direction.LEFT || params.direction === Direction.RIGHT) {
+ _docQuickInsertPopupService.editPopup && _commandService.executeCommand(CloseQuickInsertPopupOperation.id);
+ }
+ }
+
+ if (commandInfo.id === DeleteLeftCommand.id) {
+ const activeRange = _textSelectionManagerService.getActiveTextRange();
+ if (!_docQuickInsertPopupService.editPopup || !activeRange) {
+ return;
+ }
+
+ if (activeRange.endOffset <= _docQuickInsertPopupService.editPopup.anchor) {
+ _commandService.executeCommand(CloseQuickInsertPopupOperation.id);
+ }
+ }
+ })
+ );
+ }
+
+ private _initMenuHandler() {
+ this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected((menu) => {
+ if (menu.id === textMenu.id) {
+ return;
+ }
+
+ if (builtInMenuCommandIds.has(menu.id)) {
+ this._commandService.executeCommand(menu.id);
+ }
+ }));
+ }
+}
diff --git a/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-ui.controller.ts b/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-ui.controller.ts
new file mode 100644
index 0000000000..822826a05f
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-ui.controller.ts
@@ -0,0 +1,75 @@
+/**
+ * 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 type { ITextRangeWithStyle } from '@univerjs/engine-render';
+import type { IDocPopup } from '../services/doc-quick-insert-popup.service';
+import { Disposable, ICommandService, Inject } from '@univerjs/core';
+import { DividerSingle, TextSingle } from '@univerjs/icons';
+import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
+import { of } from 'rxjs';
+import { DeleteSearchKeyCommand } from '../commands/commands/doc-quick-insert.command';
+import { CloseQuickInsertPopupOperation, ShowQuickInsertPopupOperation } from '../commands/operations/quick-insert-popup.operation';
+import { DocQuickInsertPopupService } from '../services/doc-quick-insert-popup.service';
+import { QuickInsertPopup } from '../views/QuickInsertPopup';
+import { builtInMenus } from './built-in-menus';
+
+export class DocQuickInsertUIController extends Disposable {
+ constructor(
+ @ICommandService private readonly _commandService: ICommandService,
+ @Inject(DocQuickInsertPopupService) private readonly _docQuickInsertPopupService: DocQuickInsertPopupService,
+ @Inject(ComponentManager) private readonly _componentManager: ComponentManager,
+ @Inject(IMenuManagerService) private readonly _menuManagerService: IMenuManagerService
+ ) {
+ super();
+
+ this._initCommands();
+ this._initComponents();
+ this._initMenus();
+ }
+
+ private _initCommands() {
+ [
+ DeleteSearchKeyCommand,
+ ShowQuickInsertPopupOperation,
+ CloseQuickInsertPopupOperation,
+ ].forEach((operation) => {
+ this.disposeWithMe(this._commandService.registerCommand(operation));
+ });
+ }
+
+ private _initComponents() {
+ this.disposeWithMe(this._componentManager.register(QuickInsertPopup.componentKey, QuickInsertPopup));
+ this.disposeWithMe(this._componentManager.register('DividerSingle', DividerSingle));
+ this.disposeWithMe(this._componentManager.register('TextSingle', TextSingle));
+
+ const popups: IDocPopup[] = [
+ {
+ keyword: '/',
+ menus$: of(builtInMenus),
+ // only show when the cursor is at the beginning of a line
+ preconditions: (params) => (params.range as ITextRangeWithStyle).startNodePosition?.glyph === 0,
+ },
+ ];
+
+ popups.forEach((popup) => {
+ this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(popup));
+ });
+ }
+
+ private _initMenus() {
+
+ }
+}
diff --git a/packages/docs-quick-insert-ui/src/global.css b/packages/docs-quick-insert-ui/src/global.css
new file mode 100644
index 0000000000..7c05d4ddc4
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/global.css
@@ -0,0 +1,2 @@
+@tailwind components;
+@tailwind utilities;
diff --git a/packages/docs-quick-insert-ui/src/index.ts b/packages/docs-quick-insert-ui/src/index.ts
new file mode 100644
index 0000000000..49e0117bf8
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/index.ts
@@ -0,0 +1,34 @@
+/**
+ * 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 './global.css';
+
+export { UniverDocsQuickInsertUIPlugin } from './plugin';
+
+export type {
+ DocPopupMenu,
+ IDocPopup,
+ IDocPopupGroupItem,
+ IDocPopupMenuItem,
+} from './services/doc-quick-insert-popup.service';
+
+export { DocQuickInsertPopupService } from './services/doc-quick-insert-popup.service';
+export { DocQuickInsertTriggerController } from './controllers/doc-quick-insert-trigger.controller';
+export { DocQuickInsertUIController } from './controllers/doc-quick-insert-ui.controller';
+
+// #region - all commands
+
+// #endregion
diff --git a/packages/docs-quick-insert-ui/src/locale/en-US.ts b/packages/docs-quick-insert-ui/src/locale/en-US.ts
new file mode 100644
index 0000000000..feb5482f95
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/locale/en-US.ts
@@ -0,0 +1,33 @@
+/**
+ * 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 type zhCN from './zh-CN';
+
+const locale: typeof zhCN = {
+ docQuickInsert: {
+ menu: {
+ numberedList: 'Numbered List',
+ bulletedList: 'Bulleted List',
+ divider: 'Divider',
+ text: 'Text',
+ },
+ group: {
+ basics: 'Basics',
+ },
+ },
+};
+
+export default locale;
diff --git a/packages/docs-quick-insert-ui/src/locale/fa-IR.ts b/packages/docs-quick-insert-ui/src/locale/fa-IR.ts
new file mode 100644
index 0000000000..4d2b824471
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/locale/fa-IR.ts
@@ -0,0 +1,33 @@
+/**
+ * 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 type zhCN from './zh-CN';
+
+const locale: typeof zhCN = {
+ docQuickInsert: {
+ menu: {
+ numberedList: 'لیست شمارهدار',
+ bulletedList: 'لیست نقطهدار',
+ divider: 'خط تقسیم',
+ text: 'متن',
+ },
+ group: {
+ basics: 'بنیادی',
+ },
+ },
+};
+
+export default locale;
diff --git a/packages/docs-quick-insert-ui/src/locale/fr-FR.ts b/packages/docs-quick-insert-ui/src/locale/fr-FR.ts
new file mode 100644
index 0000000000..31c154ee48
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/locale/fr-FR.ts
@@ -0,0 +1,33 @@
+/**
+ * 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 type enUS from './en-US';
+
+const locale: typeof enUS = {
+ docQuickInsert: {
+ menu: {
+ numberedList: 'Liste numérotée',
+ bulletedList: 'Liste à puces',
+ divider: 'Ligne de séparation',
+ text: 'Texte',
+ },
+ group: {
+ basics: 'Basiques',
+ },
+ },
+};
+
+export default locale;
diff --git a/packages/docs-quick-insert-ui/src/locale/ru-RU.ts b/packages/docs-quick-insert-ui/src/locale/ru-RU.ts
new file mode 100644
index 0000000000..b88399b29c
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/locale/ru-RU.ts
@@ -0,0 +1,33 @@
+/**
+ * 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 type zhCN from './zh-CN';
+
+const locale: typeof zhCN = {
+ docQuickInsert: {
+ menu: {
+ numberedList: 'Список с нумерацией',
+ bulletedList: 'Маркированный список',
+ divider: 'Разделительная линия',
+ text: 'Текст',
+ },
+ group: {
+ basics: 'Основные',
+ },
+ },
+};
+
+export default locale;
diff --git a/packages/docs-quick-insert-ui/src/locale/vi-VN.ts b/packages/docs-quick-insert-ui/src/locale/vi-VN.ts
new file mode 100644
index 0000000000..e9e4d220d8
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/locale/vi-VN.ts
@@ -0,0 +1,33 @@
+/**
+ * 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 type zhCN from './zh-CN';
+
+const locale: typeof zhCN = {
+ docQuickInsert: {
+ menu: {
+ numberedList: 'Danh sách được đánh số',
+ bulletedList: 'Danh sách không được đánh số',
+ divider: 'Đường phân cách',
+ text: 'Văn bản',
+ },
+ group: {
+ basics: 'Cơ bản',
+ },
+ },
+};
+
+export default locale;
diff --git a/packages/docs-quick-insert-ui/src/locale/zh-CN.ts b/packages/docs-quick-insert-ui/src/locale/zh-CN.ts
new file mode 100644
index 0000000000..2c0692e773
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/locale/zh-CN.ts
@@ -0,0 +1,31 @@
+/**
+ * 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.
+ */
+
+const locale = {
+ docQuickInsert: {
+ menu: {
+ numberedList: '有序列表',
+ bulletedList: '无序列表',
+ divider: '分隔线',
+ text: '文本',
+ },
+ group: {
+ basics: '基础',
+ },
+ },
+};
+
+export default locale;
diff --git a/packages/docs-quick-insert-ui/src/locale/zh-TW.ts b/packages/docs-quick-insert-ui/src/locale/zh-TW.ts
new file mode 100644
index 0000000000..7f6dab3f51
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/locale/zh-TW.ts
@@ -0,0 +1,33 @@
+/**
+ * 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 type zhCN from './zh-CN';
+
+const locale: typeof zhCN = {
+ docQuickInsert: {
+ menu: {
+ numberedList: '有序列表',
+ bulletedList: '無序列表',
+ divider: '分隔線',
+ text: '文本',
+ },
+ group: {
+ basics: '基礎',
+ },
+ },
+};
+
+export default locale;
diff --git a/packages/docs-quick-insert-ui/src/plugin.ts b/packages/docs-quick-insert-ui/src/plugin.ts
new file mode 100644
index 0000000000..56617b1f20
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/plugin.ts
@@ -0,0 +1,56 @@
+/**
+ * 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 type { Dependency } from '@univerjs/core';
+import { DependentOn, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
+import { UniverDocsDrawingPlugin } from '@univerjs/docs-drawing';
+import { UniverDrawingPlugin } from '@univerjs/drawing';
+import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui';
+import { UniverUIPlugin } from '@univerjs/ui';
+import { DocQuickInsertTriggerController } from './controllers/doc-quick-insert-trigger.controller';
+import { DocQuickInsertUIController } from './controllers/doc-quick-insert-ui.controller';
+import { DocQuickInsertPopupService } from './services/doc-quick-insert-popup.service';
+
+const PLUGIN_NAME = 'DOC_QUICK_INSERT_UI_PLUGIN';
+
+@DependentOn(UniverDrawingUIPlugin, UniverDrawingPlugin, UniverDocsDrawingPlugin, UniverUIPlugin)
+export class UniverDocsQuickInsertUIPlugin extends Plugin {
+ static override type = UniverInstanceType.UNIVER_DOC;
+ static override pluginName = PLUGIN_NAME;
+
+ constructor(
+ @Inject(Injector) protected _injector: Injector
+ ) {
+ super();
+ }
+
+ override onStarting(): void {
+ const dependencies: Dependency[] = [
+ [DocQuickInsertUIController],
+ [DocQuickInsertTriggerController],
+ [DocQuickInsertPopupService],
+ ];
+
+ dependencies.forEach((dependency) => this._injector.add(dependency));
+
+ this._injector.get(DocQuickInsertUIController);
+ }
+
+ override onRendered(): void {
+ this._injector.get(DocQuickInsertTriggerController);
+ this._injector.get(DocQuickInsertPopupService);
+ }
+}
diff --git a/packages/docs-quick-insert-ui/src/services/doc-quick-insert-popup.service.ts b/packages/docs-quick-insert-ui/src/services/doc-quick-insert-popup.service.ts
new file mode 100644
index 0000000000..dac4fd77f0
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/services/doc-quick-insert-popup.service.ts
@@ -0,0 +1,156 @@
+/**
+ * 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 type { DocumentDataModel, IDisposable, Nullable } from '@univerjs/core';
+import type { IInsertCommandParams } from '@univerjs/docs-ui';
+import type { Observable } from 'rxjs';
+import { Disposable, ICommandService, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
+import { DocCanvasPopManagerService } from '@univerjs/docs-ui';
+import { BehaviorSubject, distinctUntilChanged, map } from 'rxjs';
+import { DeleteSearchKeyCommand } from '../commands/commands/doc-quick-insert.command';
+import { QuickInsertPopup } from '../views/QuickInsertPopup';
+
+export interface IDocPopupGroupItem {
+ id: string;
+ icon?: string;
+ title: string;
+ children?: IDocPopupMenuItem[];
+}
+
+export interface IDocPopupMenuItem {
+ id: string;
+ icon?: string;
+ title: string;
+ keywords?: string[];
+}
+
+export type DocPopupMenu = IDocPopupGroupItem | IDocPopupMenuItem;
+
+export interface IDocPopup {
+ keyword: string;
+ menus$: Observable<DocPopupMenu[]>;
+ placeholder?: React.ReactNode;
+ preconditions?: (params: IInsertCommandParams) => boolean;
+}
+
+export class DocQuickInsertPopupService extends Disposable {
+ private readonly _popups: Set<IDocPopup> = new Set();
+
+ private readonly _editPopup$ = new BehaviorSubject<Nullable<{
+ popup: IDocPopup;
+ anchor: number;
+ disposable: IDisposable;
+ unitId: string;
+ }>>(undefined);
+
+ readonly editPopup$ = this._editPopup$.asObservable();
+ get editPopup() {
+ return this._editPopup$.value;
+ }
+
+ private readonly _inputOffset$ = new BehaviorSubject<{ start: number; end: number }>({ start: 0, end: 0 });
+ readonly inputOffset$ = this._inputOffset$.asObservable();
+ get inputOffset() {
+ return this._inputOffset$.value;
+ }
+
+ setInputOffset(offset: { start: number; end: number }) {
+ this._inputOffset$.next(offset);
+ }
+
+ readonly filterKeyword$: Observable<string>;
+
+ private _menuSelectedCallbacks: Set<(menu: IDocPopupMenuItem) => void> = new Set();
+
+ constructor(
+ @Inject(DocCanvasPopManagerService) private readonly _docCanvasPopupManagerService: DocCanvasPopManagerService,
+ @Inject(IUniverInstanceService) private readonly _univerInstanceService: IUniverInstanceService,
+ @Inject(ICommandService) private readonly _commandService: ICommandService
+ ) {
+ super();
+
+ this.disposeWithMe(this._editPopup$);
+
+ const getBodySlice = (start: number, end: number) => this._univerInstanceService.getCurrentUnitOfType<DocumentDataModel>(UniverInstanceType.UNIVER_DOC)?.getBody()?.dataStream.slice(start, end);
+
+ this.filterKeyword$ = this._inputOffset$.pipe(
+ map((offset) => {
+ const slice = getBodySlice(offset.start, offset.end);
+
+ return slice?.slice(1) ?? '';
+ }),
+ distinctUntilChanged()
+ );
+ }
+
+ resolvePopup(keyword: string) {
+ return Array.from(this._popups).find((popup) => popup.keyword === keyword);
+ }
+
+ registerPopup(popup: IDocPopup) {
+ this._popups.add(popup);
+
+ return () => {
+ this._popups.delete(popup);
+ };
+ }
+
+ showPopup(options: { popup: IDocPopup; index: number; unitId: string }) {
+ const { popup, index, unitId } = options;
+
+ this.closePopup();
+
+ const disposable = this._docCanvasPopupManagerService.attachPopupToRange(
+ { startOffset: index, endOffset: index, collapsed: true },
+ {
+ componentKey: QuickInsertPopup.componentKey,
+ onClickOutside: () => {
+ this.closePopup();
+ },
+ direction: 'bottom',
+ },
+ unitId
+ );
+
+ this._editPopup$.next({ disposable, popup, anchor: index, unitId });
+ }
+
+ closePopup() {
+ if (this.editPopup) {
+ this.editPopup.disposable.dispose();
+ this._editPopup$.next(null);
+ }
+ }
+
+ onMenuSelected(callback: (menu: IDocPopupMenuItem) => void) {
+ this._menuSelectedCallbacks.add(callback);
+
+ return () => {
+ this._menuSelectedCallbacks.delete(callback);
+ };
+ }
+
+ emitMenuSelected(menu: IDocPopupMenuItem) {
+ const { start, end } = this.inputOffset;
+ this._commandService.syncExecuteCommand(DeleteSearchKeyCommand.id, {
+ start,
+ end,
+ });
+ setTimeout(() => {
+ this._menuSelectedCallbacks.forEach((callback) => callback(menu));
+ }, 0);
+ }
+}
diff --git a/packages/docs-quick-insert-ui/src/views/QuickInsertPopup.tsx b/packages/docs-quick-insert-ui/src/views/QuickInsertPopup.tsx
new file mode 100644
index 0000000000..a8665c160b
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/views/QuickInsertPopup.tsx
@@ -0,0 +1,277 @@
+/**
+ * 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 type { DocPopupMenu, IDocPopupMenuItem } from '../services/doc-quick-insert-popup.service';
+import { CommandType, Direction, DisposableCollection, generateRandomId, ICommandService, LocaleService, toDisposable } from '@univerjs/core';
+import { clsx, Menu, MenuItem, MenuItemGroup } from '@univerjs/design';
+import { ComponentManager, IShortcutService, KeyCode, useDependency, useObservable } from '@univerjs/ui';
+import { useEffect, useMemo, useRef, useState } from 'react';
+import { CloseQuickInsertPopupOperation } from '../commands/operations/quick-insert-popup.operation';
+import { DocQuickInsertPopupService } from '../services/doc-quick-insert-popup.service';
+
+function filterMenusByKeyword(menus: DocPopupMenu[], keyword: string) {
+ return menus
+ .map((menu) => ({ ...menu }))
+ .filter((menu) => {
+ if ('children' in menu) {
+ menu.children = filterMenusByKeyword(menu.children!, keyword) as IDocPopupMenuItem[];
+
+ return menu.children.length > 0;
+ }
+
+ const keywords = (menu as IDocPopupMenuItem).keywords;
+
+ if (keywords) {
+ return keywords.some((word) => word.includes(keyword));
+ }
+
+ return menu.title.toLowerCase().includes(keyword);
+ });
+}
+
+function translateMenus(menus: DocPopupMenu[], localeService: LocaleService) {
+ return menus.map((_menu) => {
+ const menu = { ..._menu } as DocPopupMenu;
+ if ('children' in menu) {
+ menu.children = translateMenus(menu.children!, localeService) as IDocPopupMenuItem[];
+ }
+
+ menu.title = localeService.t(menu.title);
+
+ if ('keywords' in menu) {
+ menu.keywords = menu.keywords!
+ .concat(menu.title)
+ .map((word) => word.toLowerCase());
+ }
+
+ return menu;
+ });
+}
+
+const interceptKeys = [KeyCode.ARROW_UP, KeyCode.ARROW_DOWN, KeyCode.ENTER];
+
+const QuickInsertPopup = () => {
+ const localeService = useDependency(LocaleService);
+ const docQuickInsertPopupService = useDependency(DocQuickInsertPopupService);
+ const componentManager = useDependency(ComponentManager);
+ const shortcutService = useDependency(IShortcutService);
+ const commandService = useDependency(ICommandService);
+
+ const id = useMemo(() => generateRandomId(), []);
+
+ const [focusedMenuIndex, setFocusedMenuIndex] = useState(0);
+ const focusedMenuRef = useRef<IDocPopupMenuItem | null>(null);
+
+ const menuIndexAccumulator = useRef(0);
+ menuIndexAccumulator.current = 0;
+
+ const filterKeyword = useObservable(docQuickInsertPopupService.filterKeyword$, '');
+ const currentPopup = useObservable(docQuickInsertPopupService.editPopup$);
+ const menus = useObservable<DocPopupMenu[]>(currentPopup?.popup.menus$, []);
+ const [filteredMenus, setFilteredMenus] = useState<DocPopupMenu[]>([]);
+
+ const translatedMenus = useMemo(() => {
+ return translateMenus(menus, localeService);
+ }, [menus]);
+
+ useEffect(() => {
+ const id = requestIdleCallback(() => {
+ setFilteredMenus(filterMenusByKeyword(translatedMenus, filterKeyword.toLowerCase()));
+ });
+
+ return () => {
+ cancelIdleCallback(id);
+ };
+ }, [translatedMenus, filterKeyword]);
+
+ const handleMenuSelect = (menu: IDocPopupMenuItem) => {
+ docQuickInsertPopupService.emitMenuSelected(menu);
+ commandService.executeCommand(CloseQuickInsertPopupOperation.id);
+ };
+
+ useEffect(() => {
+ /** Use up or down to navigate the focused menu instead of moving the cursor in documents. */
+ const disposableCollection = new DisposableCollection();
+
+ const shortcutItems = shortcutService.getAllShortcuts();
+
+ const interceptedShortcutItems = shortcutItems.filter((item) => item.binding && interceptKeys.includes(item.binding));
+ // disable the shortcut items of moving the cursor in documents
+ interceptedShortcutItems.forEach((item) => {
+ const rawPreconditions = item.preconditions;
+
+ item.preconditions = () => false;
+
+ disposableCollection.add(toDisposable(() => {
+ item.preconditions = rawPreconditions;
+ }));
+ });
+
+ const enterCommand = {
+ id: `quick.insert.popup.enter.${id}`,
+ type: CommandType.OPERATION,
+ handler: () => {
+ const menu = focusedMenuRef.current;
+ if (menu) {
+ handleMenuSelect(menu);
+ }
+ },
+ };
+
+ const moveCursorUpCommand = {
+ id: `quick.insert.popup.move.cursor.up.${id}`,
+ type: CommandType.OPERATION,
+ handler: () => {
+ setFocusedMenuIndex((index) => {
+ const nextIndex = (index - 1);
+
+ return nextIndex >= 0 ? nextIndex : menuIndexAccumulator.current - 1;
+ });
+ },
+ };
+ const moveCursorDownCommand = {
+ id: `quick.insert.popup.move.cursor.down.${id}`,
+ type: CommandType.OPERATION,
+ handler: () => {
+ setFocusedMenuIndex((index) => {
+ const nextIndex = (index + 1);
+
+ return nextIndex <= (menuIndexAccumulator.current - 1) ? nextIndex : 0;
+ });
+ },
+ };
+
+ // register the commands of moving the focused menu up and down
+ disposableCollection.add(commandService.registerCommand(moveCursorUpCommand));
+ disposableCollection.add(commandService.registerCommand(moveCursorDownCommand));
+ disposableCollection.add(commandService.registerCommand(enterCommand));
+ disposableCollection.add(shortcutService.registerShortcut({
+ priority: 1000,
+ id: moveCursorUpCommand.id,
+ binding: KeyCode.ARROW_UP,
+ preconditions: () => true,
+ staticParameters: {
+ direction: Direction.UP,
+ },
+ }));
+
+ disposableCollection.add(shortcutService.registerShortcut({
+ priority: 1000,
+ id: moveCursorDownCommand.id,
+ binding: KeyCode.ARROW_DOWN,
+ preconditions: () => true,
+ staticParameters: {
+ direction: Direction.DOWN,
+ },
+ }));
+
+ disposableCollection.add(shortcutService.registerShortcut({
+ priority: 1000,
+ id: enterCommand.id,
+ binding: KeyCode.ENTER,
+ preconditions: () => true,
+ }));
+
+ return () => {
+ disposableCollection.dispose();
+ };
+ }, []);
+
+ useEffect(() => {
+ setFocusedMenuIndex(0);
+ }, [filteredMenus]);
+
+ function renderMenus(menus: DocPopupMenu[]) {
+ return menus.map((menu) => {
+ const iconKey = (menu as IDocPopupMenuItem).icon;
+ const Icon = iconKey ? componentManager.get(iconKey) : null;
+
+ if ('children' in menu) {
+ return (
+ <MenuItemGroup
+ key={menu.id}
+ title={(
+ <div
+ className={`
+ univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400
+ `}
+ >
+ {Icon && <span className="univer-mr-2 univer-inline-flex univer-text-base"><Icon /></span>}
+ <span>{menu.title}</span>
+ </div>
+ )}
+ >
+ {renderMenus(menu.children!)}
+ </MenuItemGroup>
+ );
+ }
+
+ const currentMenuIndex = menuIndexAccumulator.current;
+ const isFocused = focusedMenuIndex === currentMenuIndex;
+ if (isFocused) {
+ focusedMenuRef.current = menu as IDocPopupMenuItem;
+ }
+
+ menuIndexAccumulator.current++;
+
+ return (
+ <MenuItem
+ onMouseEnter={() => setFocusedMenuIndex(currentMenuIndex)}
+ onMouseLeave={() => setFocusedMenuIndex(Number.NaN)}
+ key={menu.id}
+ className={clsx('univer-text-sm', {
+ 'hover:univer-bg-transparent': !isFocused,
+ 'univer-bg-gray-100': isFocused,
+ })}
+ onClick={() => {
+ handleMenuSelect(menu as IDocPopupMenuItem);
+ }}
+ >
+ <div className="univer-flex univer-items-center univer-px-1">
+ {Icon && <span className="univer-mr-2 univer-inline-flex univer-text-base"><Icon /></span>}
+ <span>{menu.title}</span>
+ </div>
+ </MenuItem>
+ );
+ });
+ }
+
+ const hasMenus = filteredMenus.length > 0;
+
+ return (
+ <div
+ className={clsx(`
+ univer-rounded-lg univer-border univer-border-solid univer-border-gray-100
+ univer-shadow-[0_0_10px_0_rgba(0,0,0,0.1)]
+ `)}
+ >
+ {hasMenus
+ ? (
+ <div className="univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto">
+ <Menu>
+ {renderMenus(filteredMenus)}
+ </Menu>
+ </div>
+ )
+ : currentPopup?.popup.placeholder}
+ </div>
+
+ );
+};
+
+QuickInsertPopup.componentKey = 'doc.quick-insert-popup';
+
+export { QuickInsertPopup };
diff --git a/packages/docs-quick-insert-ui/src/vite-env.d.ts b/packages/docs-quick-insert-ui/src/vite-env.d.ts
new file mode 100644
index 0000000000..11f02fe2a0
--- /dev/null
+++ b/packages/docs-quick-insert-ui/src/vite-env.d.ts
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/packages/docs-quick-insert-ui/tailwind.config.ts b/packages/docs-quick-insert-ui/tailwind.config.ts
new file mode 100644
index 0000000000..75967f186f
--- /dev/null
+++ b/packages/docs-quick-insert-ui/tailwind.config.ts
@@ -0,0 +1,27 @@
+/**
+ * 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 type { Config } from 'tailwindcss';
+import preset from '@univerjs-infra/shared/tailwind';
+
+const config: Config = {
+ presets: [preset],
+ content: [
+ './src/**/*.{js,ts,jsx,tsx}',
+ ],
+};
+
+export default config;
diff --git a/packages/docs-quick-insert-ui/tsconfig.json b/packages/docs-quick-insert-ui/tsconfig.json
new file mode 100644
index 0000000000..c62210cbad
--- /dev/null
+++ b/packages/docs-quick-insert-ui/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "@univerjs-infra/shared/tsconfigs/base",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "lib/types"
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src"]
+}
diff --git a/packages/docs-quick-insert-ui/tsconfig.node.json b/packages/docs-quick-insert-ui/tsconfig.node.json
new file mode 100644
index 0000000000..4947a09903
--- /dev/null
+++ b/packages/docs-quick-insert-ui/tsconfig.node.json
@@ -0,0 +1,4 @@
+{
+ "extends": "@univerjs-infra/shared/tsconfigs/node",
+ "include": ["vitest.config.ts"]
+}
diff --git a/packages/docs-quick-insert-ui/vitest.config.ts b/packages/docs-quick-insert-ui/vitest.config.ts
new file mode 100644
index 0000000000..af97c6d7a2
--- /dev/null
+++ b/packages/docs-quick-insert-ui/vitest.config.ts
@@ -0,0 +1,3 @@
+import createConfig from '@univerjs-infra/shared/vitest';
+
+export default createConfig();
diff --git a/packages/docs-thread-comment-ui/package.json b/packages/docs-thread-comment-ui/package.json
index fdf8d524f4..4d74d7ee2a 100644
--- a/packages/docs-thread-comment-ui/package.json
+++ b/packages/docs-thread-comment-ui/package.json
@@ -64,7 +64,7 @@
"@univerjs/docs": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/thread-comment": "workspace:*",
"@univerjs/thread-comment-ui": "workspace:*",
"@univerjs/ui": "workspace:*"
diff --git a/packages/docs-ui/package.json b/packages/docs-ui/package.json
index 5eb09ee449..40e11f9936 100644
--- a/packages/docs-ui/package.json
+++ b/packages/docs-ui/package.json
@@ -79,7 +79,7 @@
"@univerjs/docs": "workspace:*",
"@univerjs/drawing": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/ui": "workspace:*"
},
"devDependencies": {
diff --git a/packages/docs-ui/src/commands/commands/clipboard.inner.command.ts b/packages/docs-ui/src/commands/commands/clipboard.inner.command.ts
index 9462fc139c..2751daa850 100644
--- a/packages/docs-ui/src/commands/commands/clipboard.inner.command.ts
+++ b/packages/docs-ui/src/commands/commands/clipboard.inner.command.ts
@@ -481,13 +481,12 @@ export const CutContentCommand: ICommand<IInnerCutCommandParams> = {
type: CommandType.COMMAND,
- handler: async (accessor, params: IInnerCutCommandParams) => {
- const { segmentId, textRanges } = params;
- const commandService = accessor.get(ICommandService);
+ handler: (accessor, params: IInnerCutCommandParams) => {
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
+ const commandService = accessor.get(ICommandService);
const univerInstanceService = accessor.get(IUniverInstanceService);
- const selections = params.selections ?? docSelectionManagerService.getTextRanges();
+ const { segmentId, textRanges, selections = docSelectionManagerService.getTextRanges() } = params;
const rectRanges = docSelectionManagerService.getRectRanges();
if (
diff --git a/packages/docs-ui/src/commands/operations/doc-cursor.operation.ts b/packages/docs-ui/src/commands/operations/doc-cursor.operation.ts
index 6a99e56b88..d127eb34ab 100644
--- a/packages/docs-ui/src/commands/operations/doc-cursor.operation.ts
+++ b/packages/docs-ui/src/commands/operations/doc-cursor.operation.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { CommandType } from '@univerjs/core';
import type { Direction, IOperation } from '@univerjs/core';
+import { CommandType } from '@univerjs/core';
export interface IMoveCursorOperationParams {
direction: Direction;
diff --git a/packages/docs-ui/src/index.ts b/packages/docs-ui/src/index.ts
index cd3cf3e317..1222b25d8e 100644
--- a/packages/docs-ui/src/index.ts
+++ b/packages/docs-ui/src/index.ts
@@ -59,7 +59,7 @@ export { whenDocAndEditorFocused } from './shortcuts/utils';
export { DOC_VERTICAL_PADDING } from './types/const/padding';
// #region - all commands
-
+export { HorizontalLineCommand } from './commands/commands/doc-horizontal-line.command';
export { AfterSpaceCommand, EnterCommand, type ITabCommandParams, TabCommand } from './commands/commands/auto-format.command';
export { BreakLineCommand } from './commands/commands/break-line.command';
export { generateParagraphs } from './commands/commands/break-line.command';
@@ -146,7 +146,7 @@ export type { IDocTableTabCommandParams } from './commands/commands/table/doc-ta
export { DocTableTabCommand } from './commands/commands/table/doc-table-tab.command';
export { genTableSource, getEmptyTableCell, getEmptyTableRow, getTableColumn } from './commands/commands/table/table';
export { DocCreateTableOperation } from './commands/operations/doc-create-table.operation';
-export { MoveSelectionOperation } from './commands/operations/doc-cursor.operation';
+export { type IMoveCursorOperationParams, MoveSelectionOperation } from './commands/operations/doc-cursor.operation';
export { MoveCursorOperation } from './commands/operations/doc-cursor.operation';
export { DocSelectAllCommand } from './commands/commands/doc-select-all.command';
export { type ISetDocZoomRatioOperationParams, SetDocZoomRatioOperation } from './commands/operations/set-doc-zoom-ratio.operation';
diff --git a/packages/drawing-ui/package.json b/packages/drawing-ui/package.json
index 326dcb73ae..3b2eb17f0b 100644
--- a/packages/drawing-ui/package.json
+++ b/packages/drawing-ui/package.json
@@ -70,7 +70,7 @@
"@univerjs/design": "workspace:*",
"@univerjs/drawing": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/ui": "workspace:*"
},
"devDependencies": {
diff --git a/packages/find-replace/package.json b/packages/find-replace/package.json
index 802f8a6cc2..d7ad02c149 100644
--- a/packages/find-replace/package.json
+++ b/packages/find-replace/package.json
@@ -71,7 +71,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/ui": "workspace:*"
},
"devDependencies": {
diff --git a/packages/sheets-conditional-formatting-ui/package.json b/packages/sheets-conditional-formatting-ui/package.json
index 9a7ac95702..2c462f9f23 100644
--- a/packages/sheets-conditional-formatting-ui/package.json
+++ b/packages/sheets-conditional-formatting-ui/package.json
@@ -73,7 +73,7 @@
"@univerjs/design": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-conditional-formatting": "workspace:*",
"@univerjs/sheets-formula-ui": "workspace:*",
diff --git a/packages/sheets-conditional-formatting/package.json b/packages/sheets-conditional-formatting/package.json
index 5d7ae3e795..1f09b844fc 100644
--- a/packages/sheets-conditional-formatting/package.json
+++ b/packages/sheets-conditional-formatting/package.json
@@ -75,7 +75,7 @@
},
"devDependencies": {
"@univerjs-infra/shared": "workspace:*",
- "@univerjs/icons-svg": "^0.2.21",
+ "@univerjs/icons-svg": "^0.2.22",
"rxjs": "^7.8.1",
"typescript": "^5.8.2",
"vite": "^6.2.1",
diff --git a/packages/sheets-crosshair-highlight/package.json b/packages/sheets-crosshair-highlight/package.json
index 06bace8509..de30696fae 100644
--- a/packages/sheets-crosshair-highlight/package.json
+++ b/packages/sheets-crosshair-highlight/package.json
@@ -75,7 +75,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*"
diff --git a/packages/sheets-data-validation-ui/package.json b/packages/sheets-data-validation-ui/package.json
index 88456b0f7e..e26b695791 100644
--- a/packages/sheets-data-validation-ui/package.json
+++ b/packages/sheets-data-validation-ui/package.json
@@ -76,7 +76,7 @@
"@univerjs/docs": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-data-validation": "workspace:*",
"@univerjs/sheets-formula-ui": "workspace:*",
diff --git a/packages/sheets-drawing-ui/package.json b/packages/sheets-drawing-ui/package.json
index f8cfe9f5e6..2be74598c3 100644
--- a/packages/sheets-drawing-ui/package.json
+++ b/packages/sheets-drawing-ui/package.json
@@ -79,7 +79,7 @@
"@univerjs/drawing": "workspace:*",
"@univerjs/drawing-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-drawing": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
diff --git a/packages/sheets-filter-ui/package.json b/packages/sheets-filter-ui/package.json
index 2816ee5c43..870464e0d4 100644
--- a/packages/sheets-filter-ui/package.json
+++ b/packages/sheets-filter-ui/package.json
@@ -69,7 +69,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/rpc": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-filter": "workspace:*",
diff --git a/packages/sheets-formula-ui/package.json b/packages/sheets-formula-ui/package.json
index 9fdc0689be..ca7bc48a6b 100644
--- a/packages/sheets-formula-ui/package.json
+++ b/packages/sheets-formula-ui/package.json
@@ -79,7 +79,7 @@
"@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
diff --git a/packages/sheets-hyper-link-ui/package.json b/packages/sheets-hyper-link-ui/package.json
index 4c0007b7dd..a13d331b1e 100644
--- a/packages/sheets-hyper-link-ui/package.json
+++ b/packages/sheets-hyper-link-ui/package.json
@@ -80,7 +80,7 @@
"@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-data-validation": "workspace:*",
"@univerjs/sheets-formula-ui": "workspace:*",
diff --git a/packages/sheets-numfmt-ui/package.json b/packages/sheets-numfmt-ui/package.json
index 1e27bc9dd5..de32be9855 100644
--- a/packages/sheets-numfmt-ui/package.json
+++ b/packages/sheets-numfmt-ui/package.json
@@ -73,7 +73,7 @@
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-numfmt": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-numfmt": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
diff --git a/packages/sheets-sort-ui/package.json b/packages/sheets-sort-ui/package.json
index 426e1ba383..9e6e2792f1 100644
--- a/packages/sheets-sort-ui/package.json
+++ b/packages/sheets-sort-ui/package.json
@@ -69,7 +69,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-sort": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
diff --git a/packages/sheets-thread-comment-ui/package.json b/packages/sheets-thread-comment-ui/package.json
index c214ff7d9d..4a698e0284 100644
--- a/packages/sheets-thread-comment-ui/package.json
+++ b/packages/sheets-thread-comment-ui/package.json
@@ -69,7 +69,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-thread-comment": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
diff --git a/packages/sheets-ui/package.json b/packages/sheets-ui/package.json
index ac4b3f79f9..f860433da6 100644
--- a/packages/sheets-ui/package.json
+++ b/packages/sheets-ui/package.json
@@ -81,7 +81,7 @@
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-numfmt": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/protocol": "0.1.44",
"@univerjs/sheets": "workspace:*",
"@univerjs/telemetry": "workspace:*",
diff --git a/packages/sheets-zen-editor/package.json b/packages/sheets-zen-editor/package.json
index df57dc3cea..cffacb6fea 100644
--- a/packages/sheets-zen-editor/package.json
+++ b/packages/sheets-zen-editor/package.json
@@ -79,7 +79,7 @@
"@univerjs/docs": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*"
diff --git a/packages/slides-ui/package.json b/packages/slides-ui/package.json
index f5dbd9291a..3295067387 100644
--- a/packages/slides-ui/package.json
+++ b/packages/slides-ui/package.json
@@ -74,7 +74,7 @@
"@univerjs/docs-ui": "workspace:*",
"@univerjs/drawing": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/slides": "workspace:*",
"@univerjs/ui": "workspace:*"
},
diff --git a/packages/thread-comment-ui/package.json b/packages/thread-comment-ui/package.json
index 1d02bed7fe..82178ee8a7 100644
--- a/packages/thread-comment-ui/package.json
+++ b/packages/thread-comment-ui/package.json
@@ -69,7 +69,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@univerjs/thread-comment": "workspace:*",
"@univerjs/ui": "workspace:*"
},
diff --git a/packages/ui/package.json b/packages/ui/package.json
index b234fbde94..0eebc828ad 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -78,7 +78,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@univerjs/icons": "^0.2.21",
+ "@univerjs/icons": "^0.2.22",
"@wendellhu/redi": "0.17.1",
"localforage": "^1.10.0",
"rc-notification": "^5.6.2"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e74a0077e4..bad76ee34e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -181,14 +181,14 @@ importers:
specifier: ^11.0.4
version: 11.0.4
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/icons-svg':
- specifier: ^0.2.21
- version: 0.2.21
+ specifier: ^0.2.22
+ version: 0.2.22
'@univerjs/protocol':
specifier: 0.1.44
- version: 0.1.44(@grpc/[email protected])([email protected])
+ version: 0.1.44(@grpc/[email protected])([email protected])
common/storybook:
dependencies:
@@ -310,6 +310,9 @@ importers:
'@univerjs/docs-mention-ui':
specifier: workspace:*
version: link:../packages/docs-mention-ui
+ '@univerjs/docs-quick-insert-ui':
+ specifier: workspace:*
+ version: link:../packages/docs-quick-insert-ui
'@univerjs/docs-thread-comment-ui':
specifier: workspace:*
version: link:../packages/docs-thread-comment-ui
@@ -592,8 +595,8 @@ importers:
specifier: workspace:*
version: link:../../packages/design
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../../packages/sheets
@@ -653,8 +656,8 @@ importers:
specifier: workspace:*
version: link:../../packages/engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/mockdata':
specifier: workspace:*
version: link:../../mockdata
@@ -808,8 +811,8 @@ importers:
specifier: workspace:*
version: link:../../packages/engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/rpc':
specifier: workspace:*
version: link:../../packages/rpc
@@ -869,8 +872,8 @@ importers:
specifier: workspace:*
version: link:../../packages/docs-ui
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../../packages/sheets
@@ -924,8 +927,8 @@ importers:
specifier: workspace:*
version: link:../../packages/engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/slides-ui':
specifier: workspace:*
version: link:../../packages/slides-ui
@@ -979,8 +982,8 @@ importers:
specifier: workspace:*
version: link:../../packages/engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../../packages/sheets
@@ -1132,8 +1135,8 @@ importers:
specifier: ^2.2.6
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
clsx:
specifier: ^2.1.1
version: 2.1.1
@@ -1291,8 +1294,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/ui':
specifier: workspace:*
version: link:../ui
@@ -1365,8 +1368,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/ui':
specifier: workspace:*
version: link:../ui
@@ -1442,6 +1445,67 @@ importers:
specifier: ^3.0.8
+ packages/docs-quick-insert-ui:
+ dependencies:
+ '@univerjs/core':
+ specifier: workspace:*
+ version: link:../core
+ '@univerjs/design':
+ specifier: workspace:*
+ version: link:../design
+ '@univerjs/docs':
+ specifier: workspace:*
+ version: link:../docs
+ '@univerjs/docs-drawing':
+ specifier: workspace:*
+ version: link:../docs-drawing
+ '@univerjs/docs-ui':
+ specifier: workspace:*
+ version: link:../docs-ui
+ '@univerjs/drawing':
+ specifier: workspace:*
+ version: link:../drawing
+ '@univerjs/drawing-ui':
+ specifier: workspace:*
+ version: link:../drawing-ui
+ '@univerjs/engine-render':
+ specifier: workspace:*
+ version: link:../engine-render
+ '@univerjs/icons':
+ specifier: ^0.2.22
+ '@univerjs/ui':
+ specifier: workspace:*
+ version: link:../ui
+ devDependencies:
+ '@univerjs-infra/shared':
+ specifier: workspace:*
+ version: link:../../common/shared
+ less:
+ specifier: ^4.2.2
+ version: 4.2.2
+ postcss:
+ specifier: ^8.5.3
+ version: 8.5.3
+ react:
+ specifier: '19'
+ version: 19.0.0
+ rxjs:
+ specifier: ^7.8.1
+ version: 7.8.1
+ tailwindcss:
+ specifier: ^3.4.17
+ version: 3.4.17
+ typescript:
+ specifier: ^5.8.2
+ version: 5.8.2
+ vite:
+ specifier: ^6.2.1
+ vitest:
+ specifier: ^3.0.8
+
packages/docs-thread-comment-ui:
dependencies:
'@univerjs/core':
@@ -1457,8 +1521,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/thread-comment':
specifier: workspace:*
version: link:../thread-comment
@@ -1512,8 +1576,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/ui':
specifier: workspace:*
version: link:../ui
@@ -1595,8 +1659,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/ui':
specifier: workspace:*
version: link:../ui
@@ -1733,8 +1797,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/ui':
specifier: workspace:*
version: link:../ui
@@ -1895,8 +1959,8 @@ importers:
specifier: workspace:*
version: link:../../common/shared
'@univerjs/icons-svg':
- specifier: ^0.2.21
- version: 0.2.21
+ specifier: ^0.2.22
+ version: 0.2.22
rxjs:
specifier: ^7.8.1
version: 7.8.1
@@ -1925,8 +1989,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -1995,8 +2059,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -2096,8 +2160,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -2194,8 +2258,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -2277,8 +2341,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/rpc':
specifier: workspace:*
version: link:../rpc
@@ -2415,8 +2479,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -2535,8 +2599,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -2630,8 +2694,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -2710,8 +2774,8 @@ importers:
specifier: workspace:*
version: link:../engine-formula
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -2796,8 +2860,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -2866,8 +2930,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/protocol':
specifier: 0.1.44
version: 0.1.44(@grpc/[email protected])([email protected])
@@ -2927,8 +2991,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -3010,8 +3074,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/slides':
specifier: workspace:*
version: link:../slides
@@ -3103,8 +3167,8 @@ importers:
specifier: workspace:*
version: link:../docs-ui
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@univerjs/thread-comment':
specifier: workspace:*
version: link:../thread-comment
@@ -3152,8 +3216,8 @@ importers:
specifier: workspace:*
version: link:../engine-render
'@univerjs/icons':
- specifier: ^0.2.21
+ specifier: ^0.2.22
'@wendellhu/redi':
specifier: 0.17.1
version: 0.17.1
@@ -5432,8 +5496,8 @@ packages:
resolution: {integrity: sha512-AjOC3zfnxd6S4Eiy3jwktJPclqhFHNyd8L6Gycf9WUPoKZpgM5PjkxY1X7uSy61xVpiJDhhk7XT2NVsN3ALTWg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
- '@univerjs/[email protected]':
- resolution: {integrity: sha512-uv+ZHxkfcNJ6sHjtnZv4aIA+Z5Vt7FWA2PKonDwdoblSFs4/512RMLzLXUlQMpBFbv0BnPOAKSerCQz/+Jm2Sw==}
+ '@univerjs/[email protected]':
+ resolution: {integrity: sha512-UHMGgLA5QWQn0CDiDt5XD3XLsw8SQoPemPOEvhdPUYLv4+Od3LZoH5Mph/BY4pOa+m6eohg7yEH5hLVX2Nocdg==}
'@univerjs/[email protected]':
resolution: {integrity: sha512-KwQXI+6e+Qbuqv7+xYSVmK448L/Vj519f4xd5lPI8v6T+BsiB2gixPi3CQYKh6dQY3s5jdBpkTyYaAJfG3qgog==}
@@ -5441,8 +5505,8 @@ packages:
react: '19'
react-dom: '19'
- '@univerjs/[email protected]':
- resolution: {integrity: sha512-CvaAgLF885IGG0C5Jo0LB6pXAMPn4ZICvyhe94Ic2BOUBM8MjDaYC0u4tfsEHT9k1TtRAIMH6i9rXjBGtKesLA==}
+ '@univerjs/[email protected]':
+ resolution: {integrity: sha512-PgngxaQjcHaFHkQKJNfu53+1Lz77V4f/Rar5orVkEuATqoKuo0uW7zArfV044oK7UINfnhnGTEE22gXTmEOy9w==}
peerDependencies:
react: '19'
react-dom: '19'
@@ -9931,9 +9995,6 @@ packages:
resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==}
- resolution: {integrity: sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==}
-
resolution: {integrity: sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==}
engines: {node: '>=0.4'}
@@ -13397,14 +13458,14 @@ snapshots:
'@typescript-eslint/types': 8.26.1
eslint-visitor-keys: 4.2.0
- '@univerjs/[email protected]': {}
+ '@univerjs/[email protected]': {}
dependencies:
react: 19.0.0
react-dom: 19.0.0([email protected])
dependencies:
react: 19.0.0
react-dom: 19.0.0([email protected])
@@ -13414,11 +13475,6 @@ snapshots:
'@grpc/grpc-js': 1.10.9
rxjs: 7.8.1
- dependencies:
- '@grpc/grpc-js': 1.10.9
- rxjs: 7.8.2
-
dependencies:
'@babel/core': 7.26.0
@@ -16192,7 +16248,7 @@ snapshots:
mute-stream: 1.0.0
ora: 5.4.1
run-async: 3.0.0
- rxjs: 7.8.2
+ rxjs: 7.8.1
string-width: 4.2.3
strip-ansi: 6.0.1
wrap-ansi: 6.2.0
@@ -18627,10 +18683,6 @@ snapshots:
dependencies:
tslib: 2.8.1
- dependencies:
- tslib: 2.8.1
-
dependencies:
call-bind: 1.0.8