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(docs-mention-ui): support docs-mention (#2785)

zhangw57232a50b7e1
diff --git a/common/storybook/package.json b/common/storybook/package.json
index e120d712e3..3bf0f4ed81 100644
--- a/common/storybook/package.json
+++ b/common/storybook/package.json
@@ -30,7 +30,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"css-loader": "^6.10.0",
"less-loader": "^12.2.0",
"storybook": "8.1.11",
diff --git a/examples/package.json b/examples/package.json
index d52c41c0ef..81b1c63e4c 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -21,6 +21,7 @@
"@univerjs/docs-drawing-ui": "workspace:*",
"@univerjs/docs-hyper-link": "workspace:*",
"@univerjs/docs-hyper-link-ui": "workspace:*",
+ "@univerjs/docs-mention-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 ec6cdab05f..59cfe79d28 100644
--- a/examples/src/docs/main.ts
+++ b/examples/src/docs/main.ts
@@ -26,6 +26,7 @@ import { UniverDebuggerPlugin } from '@univerjs/debugger';
import { UniverDocsDrawingUIPlugin } from '@univerjs/docs-drawing-ui';
import { UniverDocsThreadCommentUIPlugin } from '@univerjs/docs-thread-comment-ui';
import { UniverDocsHyperLinkUIPlugin } from '@univerjs/docs-hyper-link-ui';
+import { UniverDocsMentionUIPlugin } from '@univerjs/docs-mention-ui';
import { DEFAULT_DOCUMENT_DATA_CN } from '../data';
import { enUS, ruRU, zhCN } from '../locales';
@@ -72,7 +73,7 @@ univer.registerPlugin(UniverDocsUIPlugin, {
univer.registerPlugin(UniverDocsDrawingUIPlugin);
univer.registerPlugin(UniverDocsThreadCommentUIPlugin);
univer.registerPlugin(UniverDocsHyperLinkUIPlugin);
-
+univer.registerPlugin(UniverDocsMentionUIPlugin);
univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_CN);
// use for console test
diff --git a/packages/core/package.json b/packages/core/package.json
index 154ed01dd6..ed66b03dad 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -60,7 +60,7 @@
"sync:cnpm": "cnpm sync"
},
"peerDependencies": {
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"dependencies": {
diff --git a/packages/core/src/services/user-manager/user-manager.service.ts b/packages/core/src/services/user-manager/user-manager.service.ts
index 6403a8b22f..de54ec20dc 100644
--- a/packages/core/src/services/user-manager/user-manager.service.ts
+++ b/packages/core/src/services/user-manager/user-manager.service.ts
@@ -64,4 +64,8 @@ export class UserManagerService {
this._model.clear();
this._userChange$.next({ type: 'clear' });
}
+
+ list() {
+ return Array.from(this._model.values());
+ }
}
diff --git a/packages/core/src/types/interfaces/i-document-data.ts b/packages/core/src/types/interfaces/i-document-data.ts
index 6adaa53367..23493c3993 100644
--- a/packages/core/src/types/interfaces/i-document-data.ts
+++ b/packages/core/src/types/interfaces/i-document-data.ts
@@ -277,6 +277,10 @@ export interface ICustomRange {
endIndex: number;
rangeId: string;
rangeType: CustomRangeType;
+ /**
+ * display as a whole-entity
+ */
+ wholeEntity?: boolean;
}
export enum CustomRangeType {
diff --git a/packages/data-validation/package.json b/packages/data-validation/package.json
index 423dd70303..0f4ecbdc4b 100644
--- a/packages/data-validation/package.json
+++ b/packages/data-validation/package.json
@@ -65,7 +65,7 @@
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/sheets": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"dependencies": {
diff --git a/packages/debugger/package.json b/packages/debugger/package.json
index 72221acdf4..a4e74bf336 100644
--- a/packages/debugger/package.json
+++ b/packages/debugger/package.json
@@ -61,7 +61,7 @@
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-drawing-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
},
diff --git a/packages/docs-drawing-ui/package.json b/packages/docs-drawing-ui/package.json
index a354e6d74e..71fbcee918 100644
--- a/packages/docs-drawing-ui/package.json
+++ b/packages/docs-drawing-ui/package.json
@@ -72,7 +72,7 @@
"@univerjs/drawing-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/docs-drawing/package.json b/packages/docs-drawing/package.json
index 20022e43c8..1bfdd74413 100644
--- a/packages/docs-drawing/package.json
+++ b/packages/docs-drawing/package.json
@@ -60,7 +60,7 @@
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/drawing": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/docs-hyper-link-ui/README.md b/packages/docs-hyper-link-ui/README.md
index 8af6d90335..b861ac375e 100644
--- a/packages/docs-hyper-link-ui/README.md
+++ b/packages/docs-hyper-link-ui/README.md
@@ -1,11 +1,5 @@
# @univerjs/docs-hyper-link-ui
-## Package Overview
-
-| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
-| --- | --- | --- | --- | --- | :---: | :---: |
-| `@univerjs/docs-hyper-link-ui` | `UniverDocsHyperLinkUi` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ⭕️ | ⭕️ |
-
## Introduction
`@univerjs/docs-hyper-link-ui` provides the link function of Univer Docs.
diff --git a/packages/docs-hyper-link-ui/package.json b/packages/docs-hyper-link-ui/package.json
index 968222e91d..88a287212c 100644
--- a/packages/docs-hyper-link-ui/package.json
+++ b/packages/docs-hyper-link-ui/package.json
@@ -66,7 +66,7 @@
"@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/docs-hyper-link/README.md b/packages/docs-hyper-link/README.md
index 5894154975..dc5a3ccd16 100644
--- a/packages/docs-hyper-link/README.md
+++ b/packages/docs-hyper-link/README.md
@@ -1,11 +1,5 @@
# @univerjs/docs-hyper-link
-## Package Overview
-
-| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
-| --- | --- | --- | --- | --- | :---: | :---: |
-| `@univerjs/docs-hyper-link` | `UniverDocsHyperLink` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
-
## Introduction
`@univerjs/docs-hyper-link` provides the base link function of Univer Docs.
diff --git a/packages/docs-hyper-link/package.json b/packages/docs-hyper-link/package.json
index 1a2006005c..55216d7a61 100644
--- a/packages/docs-hyper-link/package.json
+++ b/packages/docs-hyper-link/package.json
@@ -59,7 +59,7 @@
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/docs": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/docs-hyper-link/src/controllers/doc-hyper-link-custom-range.controller.ts b/packages/docs-hyper-link/src/controllers/doc-hyper-link-custom-range.controller.ts
index 9e20185c17..d8249334c0 100644
--- a/packages/docs-hyper-link/src/controllers/doc-hyper-link-custom-range.controller.ts
+++ b/packages/docs-hyper-link/src/controllers/doc-hyper-link-custom-range.controller.ts
@@ -35,7 +35,6 @@ export class DocHyperLinkCustomRangeController extends Disposable {
this._docCustomRangeService.addClipboardHook({
onCopyCustomRange: (unitId, range) => {
const { rangeId, rangeType, data, ...ext } = range;
-
if (rangeType === CustomRangeType.HYPERLINK) {
if (data) {
const id = Tools.generateRandomId();
diff --git a/packages/docs-hyper-link/src/plugin.ts b/packages/docs-hyper-link/src/plugin.ts
index 59a6760fbf..364a77416b 100644
--- a/packages/docs-hyper-link/src/plugin.ts
+++ b/packages/docs-hyper-link/src/plugin.ts
@@ -30,6 +30,7 @@ export class UniverDocsHyperLinkPlugin extends Plugin {
static override type = UniverInstanceType.UNIVER_DOC;
constructor(
+ private _config: unknown,
@Inject(Injector) protected override _injector: Injector
) {
super();
diff --git a/packages/docs-mention-ui/README.md b/packages/docs-mention-ui/README.md
new file mode 100644
index 0000000000..f8a9a88b69
--- /dev/null
+++ b/packages/docs-mention-ui/README.md
@@ -0,0 +1,23 @@
+# @univerjs/docs-mention-ui
+
+## Introduction
+
+`@univerjs/docs-mention-ui` package provides the Mention function for Docs.
+
+## Usage
+
+### Installation
+
+```shell
+# Using npm
+npm install @univerjs/docs-mention-ui
+
+# Using pnpm
+pnpm add @univerjs/docs-mention-ui
+```
+
+<!-- Links -->
+[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/docs-mention-ui?style=flat-square
+[npm-version-link]: https://npmjs.com/package/@univerjs/docs-mention-ui
+[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/docs-mention-ui?style=flat-square
+[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/docs-mention-ui?style=flat-square
diff --git a/packages/docs-mention-ui/package.json b/packages/docs-mention-ui/package.json
new file mode 100644
index 0000000000..dbc1f343ca
--- /dev/null
+++ b/packages/docs-mention-ui/package.json
@@ -0,0 +1,113 @@
+{
+ "name": "@univerjs/docs-mention-ui",
+ "version": "0.2.3",
+ "private": true,
+ "description": "Univer normal ui-plugin-docs",
+ "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": [
+ "univer"
+ ],
+ "sideEffects": [
+ "**/*.css"
+ ],
+ "exports": {
+ ".": "./src/index.ts",
+ "./*": "./src/*",
+ "./locale/*": "./src/locale/*.ts"
+ },
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "types": "./lib/types/index.d.ts",
+ "publishConfig": {
+ "access": "public",
+ "main": "./lib/cjs/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"
+ },
+ "./lib/*": "./lib/*",
+ "./locale/*": "./lib/locale/*.json"
+ }
+ },
+ "directories": {
+ "lib": "lib"
+ },
+ "files": [
+ "lib"
+ ],
+ "scripts": {
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "coverage": "vitest run --coverage",
+ "lint:types": "tsc --noEmit",
+ "build": "tsc && vite build",
+ "sync:cnpm": "cnpm sync"
+ },
+ "peerDependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/design": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/docs-mention": "workspace:*",
+ "@univerjs/docs-ui": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/ui": "workspace:*",
+ "@wendellhu/redi": "0.16.0",
+ "clsx": ">=2.0.0",
+ "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
+ "rxjs": ">=7.0.0"
+ },
+ "devDependencies": {
+ "@types/react": "^18.3.3",
+ "@univerjs/core": "workspace:*",
+ "@univerjs/design": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/docs-mention": "workspace:*",
+ "@univerjs/docs-ui": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/shared": "workspace:*",
+ "@univerjs/ui": "workspace:*",
+ "@wendellhu/redi": "0.16.0",
+ "clsx": "^2.1.1",
+ "less": "^4.2.0",
+ "react": "18.3.1",
+ "rxjs": "^7.8.1",
+ "typescript": "^5.5.3",
+ "vite": "^5.3.3",
+ "vitest": "^1.6.0"
+ },
+ "univerSpace": {
+ ".": {
+ "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"
+ },
+ "./lib/*": "./lib/*",
+ "./locale/*": "./lib/locale/*.json"
+ }
+}
diff --git a/packages/docs-mention-ui/src/commands/operations/mention-popup.operation.ts b/packages/docs-mention-ui/src/commands/operations/mention-popup.operation.ts
new file mode 100644
index 0000000000..5c6d618ba8
--- /dev/null
+++ b/packages/docs-mention-ui/src/commands/operations/mention-popup.operation.ts
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { CommandType, type ICommand } from '@univerjs/core';
+import { DocMentionService } from '@univerjs/docs-mention';
+
+export interface IShowMentionInfoPopupOperationParams {
+ unitId: string;
+ mentionId: string;
+}
+
+export const ShowMentionInfoPopupOperation: ICommand<IShowMentionInfoPopupOperationParams> = {
+ type: CommandType.OPERATION,
+ id: 'docs.operation.show-mention-info-popup',
+ handler(accessor, params) {
+ return false;
+ },
+};
+
+export const CloseMentionInfoPopupOperation: ICommand = {
+ type: CommandType.OPERATION,
+ id: 'docs.operation.close-mention-info-popup',
+ handler(accessor) {
+ return false;
+ },
+};
+
+export interface IShowMentionEditPopupOperationParams {
+ startIndex: number;
+}
+
+export const ShowMentionEditPopupOperation: ICommand<IShowMentionEditPopupOperationParams> = {
+ type: CommandType.OPERATION,
+ id: 'docs.operation.show-mention-edit-popup',
+ handler(accessor, params) {
+ if (!params) {
+ return false;
+ }
+ const docMentionService = accessor.get(DocMentionService);
+ docMentionService.startEditing(params.startIndex);
+ return true;
+ },
+};
+
+export const CloseMentionEditPopupOperation: ICommand = {
+ type: CommandType.OPERATION,
+ id: 'docs.operation.close-mention-edit-popup',
+ handler(accessor) {
+ const docMentionService = accessor.get(DocMentionService);
+ docMentionService.endEditing();
+ return true;
+ },
+};
diff --git a/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts b/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts
new file mode 100644
index 0000000000..4ddd366e37
--- /dev/null
+++ b/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts
@@ -0,0 +1,67 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Disposable, ICommandService, LifecycleStages, OnLifecycle, Tools } from '@univerjs/core';
+import type { IInsertCommandParams } from '@univerjs/docs';
+import { DeleteLeftCommand, InsertCommand, MoveCursorOperation, TextSelectionManagerService } from '@univerjs/docs';
+import { DocMentionService } from '@univerjs/docs-mention';
+import { Inject } from '@wendellhu/redi';
+import { DocMentionPopupService } from '../services/doc-mention-popup.service';
+import { CloseMentionEditPopupOperation, ShowMentionEditPopupOperation } from '../commands/operations/mention-popup.operation';
+
+@OnLifecycle(LifecycleStages.Rendered, DocMentionTriggerController)
+export class DocMentionTriggerController extends Disposable {
+ constructor(
+ @ICommandService private readonly _commandService: ICommandService,
+ @Inject(DocMentionService) private readonly _docMentionService: DocMentionService,
+ @Inject(TextSelectionManagerService) private readonly _textSelectionManagerService: TextSelectionManagerService,
+ @Inject(DocMentionPopupService) private readonly _docMentionPopupService: DocMentionPopupService
+ ) {
+ super();
+
+ this._initTrigger();
+ }
+
+ private _initTrigger() {
+ this.disposeWithMe(
+ this._commandService.onCommandExecuted((commandInfo) => {
+ if (commandInfo.id === InsertCommand.id) {
+ const params = commandInfo.params as IInsertCommandParams;
+ const activeRange = this._textSelectionManagerService.getActiveRange();
+ if (params.body.dataStream === '@' && activeRange && !Tools.isDefine(this._docMentionService.editing)) {
+ this._commandService.executeCommand(ShowMentionEditPopupOperation.id, {
+ startIndex: activeRange.startOffset - 1,
+ });
+ }
+ }
+
+ if (commandInfo.id === MoveCursorOperation.id) {
+ this._commandService.executeCommand(CloseMentionEditPopupOperation.id);
+ }
+
+ if (commandInfo.id === DeleteLeftCommand.id) {
+ if (this._docMentionPopupService.editPopup == null) {
+ return;
+ }
+ const activeRange = this._textSelectionManagerService.getActiveRange();
+ if (activeRange && activeRange.endOffset <= this._docMentionPopupService.editPopup.anchor) {
+ this._commandService.executeCommand(CloseMentionEditPopupOperation.id);
+ }
+ }
+ })
+ );
+ }
+}
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
new file mode 100644
index 0000000000..1dbfd2a60d
--- /dev/null
+++ b/packages/docs-mention-ui/src/controllers/doc-mention-ui.controller.ts
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';
+import { Inject } from '@wendellhu/redi';
+import { ComponentManager } from '@univerjs/ui';
+import { CloseMentionEditPopupOperation, CloseMentionInfoPopupOperation, ShowMentionEditPopupOperation, ShowMentionInfoPopupOperation } from '../commands/operations/mention-popup.operation';
+import { MentionEditPopup } from '../views/mention-edit-popup';
+
+@OnLifecycle(LifecycleStages.Starting, DocMentionUIController)
+export class DocMentionUIController extends Disposable {
+ constructor(
+ @ICommandService private readonly _commandService: ICommandService,
+ @Inject(ComponentManager) private readonly _componentManager: ComponentManager
+ ) {
+ super();
+
+ this._initCommands();
+ this._initComponents();
+ }
+
+ private _initCommands() {
+ [
+ ShowMentionInfoPopupOperation,
+ CloseMentionInfoPopupOperation,
+ ShowMentionEditPopupOperation,
+ CloseMentionEditPopupOperation,
+ ].forEach((operation) => {
+ this.disposeWithMe(this._commandService.registerCommand(operation));
+ });
+ }
+
+ private _initComponents() {
+ const components = [[MentionEditPopup.componentKey, MentionEditPopup]] as const;
+
+ components.forEach(([key, comp]) => {
+ this.disposeWithMe(this._componentManager.register(key, comp));
+ });
+ }
+}
diff --git a/packages/docs-mention-ui/src/controllers/menu.ts b/packages/docs-mention-ui/src/controllers/menu.ts
new file mode 100644
index 0000000000..cf732b1e13
--- /dev/null
+++ b/packages/docs-mention-ui/src/controllers/menu.ts
@@ -0,0 +1,16 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/packages/docs-mention-ui/src/index.ts b/packages/docs-mention-ui/src/index.ts
new file mode 100644
index 0000000000..70a9722314
--- /dev/null
+++ b/packages/docs-mention-ui/src/index.ts
@@ -0,0 +1,18 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export { DocMentionPopupService } from './services/doc-mention-popup.service';
+export { UniverDocsMentionUIPlugin } from './plugin';
diff --git a/packages/docs-mention-ui/src/plugin.ts b/packages/docs-mention-ui/src/plugin.ts
new file mode 100644
index 0000000000..7e86676c70
--- /dev/null
+++ b/packages/docs-mention-ui/src/plugin.ts
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DependentOn, Plugin, UniverInstanceType } from '@univerjs/core';
+import type { Dependency } from '@wendellhu/redi';
+import { Inject, Injector } from '@wendellhu/redi';
+import { UniverDocsMentionPlugin } from '@univerjs/docs-mention';
+import { DOC_MENTION_UI_PLUGIN } from './types/const/const';
+import { DocMentionPopupService } from './services/doc-mention-popup.service';
+import { DocMentionUIController } from './controllers/doc-mention-ui.controller';
+import { DocMentionTriggerController } from './controllers/doc-mention-trigger.controller';
+
+@DependentOn(UniverDocsMentionPlugin)
+export class UniverDocsMentionUIPlugin extends Plugin {
+ static override pluginName = DOC_MENTION_UI_PLUGIN;
+ static override type = UniverInstanceType.UNIVER_DOC;
+
+ constructor(
+ private _config: unknown,
+ @Inject(Injector) protected override _injector: Injector
+ ) {
+ super();
+ }
+
+ override onStarting(injector: Injector): void {
+ const deps: Dependency[] = [
+ [DocMentionPopupService],
+ [DocMentionUIController],
+ [DocMentionTriggerController],
+ ];
+
+ deps.forEach((dep) => {
+ injector.add(dep);
+ });
+ }
+}
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
new file mode 100644
index 0000000000..9378c67620
--- /dev/null
+++ b/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts
@@ -0,0 +1,84 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Nullable } from '@univerjs/core';
+import { Disposable, LifecycleStages, OnLifecycle } from '@univerjs/core';
+import { DocCanvasPopManagerService } from '@univerjs/docs-ui';
+import type { IDisposable } from '@wendellhu/redi';
+import { Inject } from '@wendellhu/redi';
+import { BehaviorSubject } from 'rxjs';
+import { DocMentionService } from '@univerjs/docs-mention';
+import { MentionEditPopup } from '../views/mention-edit-popup';
+
+@OnLifecycle(LifecycleStages.Rendered, DocMentionPopupService)
+export class DocMentionPopupService extends Disposable {
+ private readonly _infoPopup$ = new BehaviorSubject(undefined);
+ readonly infoPopup$ = this._infoPopup$.asObservable();
+ get infoPopup() {
+ return this._infoPopup$.value;
+ }
+
+ private readonly _editPopup$ = new BehaviorSubject<Nullable<{ anchor: number; popup: IDisposable }>>(undefined);
+ readonly editPopup$ = this._editPopup$.asObservable();
+ get editPopup() {
+ return this._editPopup$.value;
+ }
+
+ constructor(
+ @Inject(DocCanvasPopManagerService) private readonly _docCanvasPopupManagerService: DocCanvasPopManagerService,
+ @Inject(DocMentionService) private readonly _docMentionService: DocMentionService
+ ) {
+ super();
+
+ this.disposeWithMe(this._docMentionService.editing$.subscribe((editing) => {
+ if (editing !== undefined && editing !== null) {
+ this.showEditPopup(editing);
+ } else {
+ this.closeEditPopup();
+ }
+ }));
+ }
+
+ showInfoPopup() {}
+
+ closeInfoPopup() {}
+
+ showEditPopup(index: number) {
+ this.closeEditPopup();
+ const dispose = this._docCanvasPopupManagerService.attachPopupToRange(
+ { startOffset: index, endOffset: index, collapsed: true },
+ {
+ componentKey: MentionEditPopup.componentKey,
+ onClickOutside: () => {
+ this.closeEditPopup();
+ },
+ direction: 'bottom',
+ }
+ );
+ this._editPopup$.next({ popup: dispose, anchor: index });
+ }
+
+ closeEditPopup() {
+ if (!(this._docMentionService.editing == null)) {
+ this._docMentionService.endEditing();
+ }
+
+ if (this.editPopup) {
+ this.editPopup.popup.dispose();
+ this._editPopup$.next(null);
+ }
+ }
+}
diff --git a/packages/docs-mention-ui/src/types/const/const.ts b/packages/docs-mention-ui/src/types/const/const.ts
new file mode 100644
index 0000000000..6b2b29b6ad
--- /dev/null
+++ b/packages/docs-mention-ui/src/types/const/const.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export const DOC_MENTION_UI_PLUGIN = 'DOC_MENTION_UI_PLUGIN';
diff --git a/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx b/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx
new file mode 100644
index 0000000000..d2297903f5
--- /dev/null
+++ b/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { useDependency, useObservable } from '@wendellhu/redi/react-bindings';
+import { AddDocMentionCommand, type IMention, MentionType } from '@univerjs/docs-mention';
+import React, { useEffect } from 'react';
+import { ICommandService, IUniverInstanceService, Tools, UniverInstanceType, UserManagerService } from '@univerjs/core';
+import { ITextSelectionRenderManager } from '@univerjs/engine-render';
+import { DocMentionPopupService } from '../../services/doc-mention-popup.service';
+import { MentionList } from '../mention-list';
+
+export const MentionEditPopup = () => {
+ const popupService = useDependency(DocMentionPopupService);
+ const commandService = useDependency(ICommandService);
+ const univerInstanceService = useDependency(IUniverInstanceService);
+ const textSelectionRenderService = useDependency(ITextSelectionRenderManager);
+ const editPopup = useObservable(popupService.editPopup$);
+ const userService = useDependency(UserManagerService);
+
+ const mentions: IMention[] = userService.list().map((user) => ({
+ objectId: user.userID,
+ label: user.name,
+ objectType: MentionType.PERSON,
+ extra: {
+ icon: user.avatar,
+ },
+ }));
+
+ useEffect(() => {
+ textSelectionRenderService.blur();
+ return () => {
+ textSelectionRenderService.focus();
+ };
+ }, [textSelectionRenderService]);
+
+ if (!editPopup) {
+ return null;
+ }
+
+ return (
+ <MentionList
+ onClick={() => popupService.closeEditPopup()}
+ mentions={mentions}
+ onSelect={(mention) => {
+ commandService.executeCommand(AddDocMentionCommand.id, {
+ unitId: univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)!.getUnitId(),
+ mention: {
+ ...mention,
+ id: Tools.generateRandomId(),
+ },
+ startIndex: editPopup.anchor,
+ });
+ }}
+ />
+ );
+};
+
+MentionEditPopup.componentKey = 'univer.popup.doc-mention-edit';
diff --git a/packages/docs-mention-ui/src/views/mention-list/index.module.less b/packages/docs-mention-ui/src/views/mention-list/index.module.less
new file mode 100644
index 0000000000..fb57468153
--- /dev/null
+++ b/packages/docs-mention-ui/src/views/mention-list/index.module.less
@@ -0,0 +1,43 @@
+.doc-mention-panel {
+ width: 280px;
+ padding: 8px;
+ max-height: 276px;
+ overflow-x: hidden;
+ overflow-y: hidden;
+ background-color: rgb(var(--color-white));
+ border-radius: 8px;
+ border: 1px solid rgb(var(--grey-200));
+ box-shadow: 0px 4px 16px 0px rgba(30, 34, 43, 0.08);
+}
+
+.doc-mention {
+ display: flex;
+ padding: 8px;
+ align-items: center;
+ flex-direction: row;
+ cursor: pointer;
+
+ &-icon {
+ width: 24px;
+ height: 24px;
+ border-radius: 12px;
+ margin-right: 6px;
+ flex: 0 0 auto;
+ border-radius: 6px;
+
+ &-active {
+ background: rgb(var(--grey-50));
+ }
+ }
+
+ &-icon:hover {
+ background: rgb(var(--grey-50));
+ }
+
+ &-label {
+ overflow: hidden;
+ flex: 1 1 0;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ }
+}
diff --git a/packages/docs-mention-ui/src/views/mention-list/index.tsx b/packages/docs-mention-ui/src/views/mention-list/index.tsx
new file mode 100644
index 0000000000..4b0f264e68
--- /dev/null
+++ b/packages/docs-mention-ui/src/views/mention-list/index.tsx
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { IMention } from '@univerjs/docs-mention';
+import React, { useEffect, useRef, useState } from 'react';
+import cs from 'clsx';
+import { KeyCode } from '@univerjs/ui';
+import styles from './index.module.less';
+
+export interface IMentionListProps {
+ mentions: IMention[];
+ active?: string;
+ onSelect?: (item: IMention) => void;
+ onClick?: () => void;
+}
+
+export const MentionList = (props: IMentionListProps) => {
+ const { mentions, active, onSelect, onClick } = props;
+ const ref = useRef<HTMLDivElement>(null);
+ const [activeId, setActiveId] = useState(active ?? mentions[0]?.objectId);
+ const handleSelect = (item: IMention) => {
+ onSelect?.(item);
+ };
+
+ useEffect(() => {
+ ref.current?.focus();
+ }, []);
+
+ const handleKeyDown = (evt: React.KeyboardEvent<HTMLDivElement>) => {
+ const index = mentions.findIndex((i) => i.objectId === activeId);
+ if (evt.keyCode === KeyCode.ARROW_UP) {
+ setActiveId(mentions[index - 1]?.objectId);
+ }
+
+ if (evt.keyCode === KeyCode.ARROW_DOWN) {
+ setActiveId(mentions[index + 1]?.objectId);
+ }
+
+ if (evt.keyCode === KeyCode.ENTER && mentions[index]) {
+ handleSelect(mentions[index]);
+ }
+ };
+
+ return (
+ <div ref={ref} tabIndex={0} className={styles.docMentionPanel} onKeyDown={handleKeyDown} onClick={onClick}>
+ {mentions.map((mention) => (
+ <div
+ key={mention.objectId}
+ className={cs(styles.docMention, { [styles.docMentionActive]: activeId === mention.objectId })}
+ onClick={() => handleSelect(mention)}
+ >
+ <img className={styles.docMentionIcon} src={mention.extra?.icon} />
+ <div className={styles.docMentionLabel}>{mention.label}</div>
+ </div>
+ ))}
+ </div>
+ );
+};
diff --git a/packages/docs-mention-ui/src/vite-env.d.ts b/packages/docs-mention-ui/src/vite-env.d.ts
new file mode 100644
index 0000000000..11f02fe2a0
--- /dev/null
+++ b/packages/docs-mention-ui/src/vite-env.d.ts
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/packages/docs-mention-ui/tsconfig.json b/packages/docs-mention-ui/tsconfig.json
new file mode 100644
index 0000000000..d676ad2a20
--- /dev/null
+++ b/packages/docs-mention-ui/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "@univerjs/shared/tsconfigs/base",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "lib/types"
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src"]
+}
diff --git a/packages/docs-mention-ui/tsconfig.node.json b/packages/docs-mention-ui/tsconfig.node.json
new file mode 100644
index 0000000000..e53dac8868
--- /dev/null
+++ b/packages/docs-mention-ui/tsconfig.node.json
@@ -0,0 +1,4 @@
+{
+ "extends": "@univerjs/shared/tsconfigs/node",
+ "include": ["vite.config.ts"]
+}
diff --git a/packages/docs-mention-ui/vite.config.ts b/packages/docs-mention-ui/vite.config.ts
new file mode 100644
index 0000000000..d6d74d882a
--- /dev/null
+++ b/packages/docs-mention-ui/vite.config.ts
@@ -0,0 +1,13 @@
+import createViteConfig from '@univerjs/shared/vite';
+import pkg from './package.json';
+
+export default ({ mode }) => createViteConfig({
+}, {
+ mode,
+ pkg,
+ features: {
+ react: true,
+ css: true,
+ dom: true,
+ },
+});
diff --git a/packages/docs-mention/README.md b/packages/docs-mention/README.md
new file mode 100644
index 0000000000..3a6dc1050f
--- /dev/null
+++ b/packages/docs-mention/README.md
@@ -0,0 +1,23 @@
+# @univerjs/docs-mention
+
+## Introduction
+
+`@univerjs/docs-mention` package provides the Mention for Docs.
+
+## Usage
+
+### Installation
+
+```shell
+# Using npm
+npm install @univerjs/docs-mention
+
+# Using pnpm
+pnpm add @univerjs/docs-mention
+```
+
+<!-- Links -->
+[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/docs-mention?style=flat-square
+[npm-version-link]: https://npmjs.com/package/@univerjs/docs-mention
+[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/docs-mention?style=flat-square
+[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/docs-mention?style=flat-square
diff --git a/packages/docs-mention/package.json b/packages/docs-mention/package.json
new file mode 100644
index 0000000000..3d76b61fb9
--- /dev/null
+++ b/packages/docs-mention/package.json
@@ -0,0 +1,101 @@
+{
+ "name": "@univerjs/docs-mention",
+ "version": "0.2.3",
+ "private": true,
+ "description": "Univer normal ui-plugin-docs",
+ "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": [
+ "univer"
+ ],
+ "sideEffects": [
+ "**/*.css"
+ ],
+ "exports": {
+ ".": "./src/index.ts",
+ "./*": "./src/*",
+ "./locale/*": "./src/locale/*.ts"
+ },
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "types": "./lib/types/index.d.ts",
+ "publishConfig": {
+ "access": "public",
+ "main": "./lib/cjs/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"
+ },
+ "./lib/*": "./lib/*",
+ "./locale/*": "./lib/locale/*.json"
+ }
+ },
+ "directories": {
+ "lib": "lib"
+ },
+ "files": [
+ "lib"
+ ],
+ "scripts": {
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "coverage": "vitest run --coverage",
+ "lint:types": "tsc --noEmit",
+ "build": "tsc && vite build",
+ "sync:cnpm": "cnpm sync"
+ },
+ "peerDependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/ui": "workspace:*",
+ "@wendellhu/redi": "0.16.0",
+ "rxjs": ">=7.0.0"
+ },
+ "devDependencies": {
+ "@types/react": "^18.3.3",
+ "@univerjs/core": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/shared": "workspace:*",
+ "@wendellhu/redi": "0.16.0",
+ "rxjs": "^7.8.1",
+ "typescript": "^5.5.3",
+ "vite": "^5.3.3",
+ "vitest": "^1.6.0"
+ },
+ "univerSpace": {
+ ".": {
+ "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"
+ },
+ "./lib/*": "./lib/*",
+ "./locale/*": "./lib/locale/*.json"
+ }
+}
diff --git a/packages/docs-mention/src/commands/commands/doc-mention.command.ts b/packages/docs-mention/src/commands/commands/doc-mention.command.ts
new file mode 100644
index 0000000000..270bfb8c2f
--- /dev/null
+++ b/packages/docs-mention/src/commands/commands/doc-mention.command.ts
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { ICommand, IDocumentBody } from '@univerjs/core';
+import { CommandType, CustomRangeType, DataStreamTreeTokenType, ICommandService, sequenceExecute } from '@univerjs/core';
+import { deleteCustomRangeFactory, replaceSelectionFactory, TextSelectionManagerService } from '@univerjs/docs';
+import type { IDocMention } from '../../types/interfaces/i-mention';
+import { AddDocMentionMutation } from '../mutations/doc-mention.mutation';
+import { DocMentionModel } from '../../models/doc-mention.model';
+
+export interface IAddDocMentionCommandParams {
+ mention: IDocMention;
+ unitId: string;
+ startIndex: number;
+}
+
+export const AddDocMentionCommand: ICommand<IAddDocMentionCommandParams> = {
+ type: CommandType.COMMAND,
+ id: 'docs.command.add-doc-mention',
+ handler: async (accessor, params) => {
+ if (!params) {
+ return false;
+ }
+
+ const { mention, unitId, startIndex } = params;
+ const commandService = accessor.get(ICommandService);
+ const textSelectionManagerService = accessor.get(TextSelectionManagerService);
+ const activeRange = textSelectionManagerService.getActiveRange();
+ if (!activeRange) {
+ return false;
+ }
+ const dataStream = `${DataStreamTreeTokenType.CUSTOM_RANGE_START} @${mention.label} ${DataStreamTreeTokenType.CUSTOM_RANGE_END}`;
+ const body: IDocumentBody = {
+ dataStream,
+ customRanges: [{
+ startIndex: 0,
+ endIndex: dataStream.length - 1,
+ rangeId: mention.id,
+ rangeType: CustomRangeType.MENTION,
+ wholeEntity: true,
+ }],
+ };
+
+ const doMutation = replaceSelectionFactory(
+ accessor,
+ {
+ unitId,
+ body,
+ selection: {
+ startOffset: startIndex,
+ endOffset: activeRange.endOffset,
+ collapsed: startIndex === activeRange.endOffset,
+ },
+ }
+ );
+
+ if (doMutation) {
+ const commentMutation = {
+ id: AddDocMentionMutation.id,
+ params: {
+ unitId,
+ mention,
+ },
+ };
+
+ return (await sequenceExecute([commentMutation, doMutation], commandService)).result;
+ }
+
+ return true;
+ },
+};
+
+export interface IDeleteDocMentionCommandParams {
+ unitId: string;
+ mentionId: string;
+}
+
+export const DeleteDocMentionCommand: ICommand<IDeleteDocMentionCommandParams> = {
+ type: CommandType.COMMAND,
+ id: 'docs.command.delete-doc-mention',
+ async handler(accessor, params) {
+ if (!params) {
+ return false;
+ }
+ const { unitId, mentionId } = params;
+ const commandService = accessor.get(ICommandService);
+ const docMentionModel = accessor.get(DocMentionModel);
+ const mention = docMentionModel.getMention(unitId, mentionId);
+ if (!mention) {
+ return false;
+ }
+
+ const doMutation = deleteCustomRangeFactory(accessor, { unitId, rangeId: mention.id });
+ if (!doMutation) {
+ return false;
+ }
+
+ return await commandService.syncExecuteCommand(doMutation.id, doMutation.params);
+ },
+};
diff --git a/packages/docs-mention/src/commands/mutations/doc-mention.mutation.ts b/packages/docs-mention/src/commands/mutations/doc-mention.mutation.ts
new file mode 100644
index 0000000000..16c2c5eb51
--- /dev/null
+++ b/packages/docs-mention/src/commands/mutations/doc-mention.mutation.ts
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { CommandType, type ICommand } from '@univerjs/core';
+import { DocMentionModel } from '../../models/doc-mention.model';
+import type { IDocMention } from '../../types/interfaces/i-mention';
+
+export interface IAddDocMentionMutationParams {
+ unitId: string;
+ mention: IDocMention;
+}
+
+export const AddDocMentionMutation: ICommand<IAddDocMentionMutationParams> = {
+ id: 'docs.mutation.add-doc-mention',
+ type: CommandType.MUTATION,
+ handler(accessor, params) {
+ if (!params) {
+ return false;
+ }
+ const { unitId, mention } = params;
+ const docMentionModel = accessor.get(DocMentionModel);
+ docMentionModel.addMention(unitId, mention);
+ return true;
+ },
+};
+
+export interface IDeleteDocMentionMutationParams {
+ unitId: string;
+ id: string;
+}
+
+export const DeleteDocMentionMutation: ICommand<IDeleteDocMentionMutationParams> = {
+ id: 'docs.mutation.delete-doc-mention',
+ type: CommandType.MUTATION,
+ handler(accessor, params) {
+ if (!params) {
+ return false;
+ }
+ const { unitId, id } = params;
+ const docMentionModel = accessor.get(DocMentionModel);
+ docMentionModel.deleteMention(unitId, id);
+ return true;
+ },
+};
diff --git a/packages/docs-mention/src/controllers/doc-mention-custom-range.controller.ts b/packages/docs-mention/src/controllers/doc-mention-custom-range.controller.ts
new file mode 100644
index 0000000000..2d1088e3cf
--- /dev/null
+++ b/packages/docs-mention/src/controllers/doc-mention-custom-range.controller.ts
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { CustomRangeType, Disposable, LifecycleStages, OnLifecycle, Tools } from '@univerjs/core';
+import { DocCustomRangeService } from '@univerjs/docs';
+import { Inject } from '@wendellhu/redi';
+import { DocMentionModel } from '../models/doc-mention.model';
+
+@OnLifecycle(LifecycleStages.Ready, DocMentionCustomRangeController)
+export class DocMentionCustomRangeController extends Disposable {
+ constructor(
+ @Inject(DocCustomRangeService) private readonly _docCustomRangeService: DocCustomRangeService,
+ @Inject(DocMentionModel) private readonly _docMentionModel: DocMentionModel
+ ) {
+ super();
+
+ this._initCustomRangeHooks();
+ }
+
+ private _initCustomRangeHooks() {
+ this.disposeWithMe(
+ this._docCustomRangeService.addClipboardHook({
+ onCopyCustomRange: (unitId, range) => {
+ const { rangeId, rangeType, data, ...ext } = range;
+ if (rangeType === CustomRangeType.MENTION) {
+ if (data) {
+ const id = Tools.generateRandomId();
+ this._docMentionModel.addMention(unitId, {
+ id,
+ ...JSON.parse(data),
+ });
+ return {
+ ...range,
+ rangeId: id,
+ };
+ }
+ const link = this._docMentionModel.copyMention(unitId, rangeId);
+ if (!link) {
+ return range;
+ }
+
+ return {
+ ...ext,
+ rangeId: link.id,
+ rangeType,
+ };
+ }
+ return range;
+ },
+ })
+ );
+ }
+}
diff --git a/packages/docs-mention/src/controllers/doc-mention.controller.ts b/packages/docs-mention/src/controllers/doc-mention.controller.ts
new file mode 100644
index 0000000000..c61256861f
--- /dev/null
+++ b/packages/docs-mention/src/controllers/doc-mention.controller.ts
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';
+import { AddDocMentionMutation, DeleteDocMentionMutation } from '../commands/mutations/doc-mention.mutation';
+import { AddDocMentionCommand, DeleteDocMentionCommand } from '../commands/commands/doc-mention.command';
+
+@OnLifecycle(LifecycleStages.Starting, DocMentionController)
+export class DocMentionController extends Disposable {
+ constructor(
+ @ICommandService private readonly _commandService: ICommandService
+ ) {
+ super();
+
+ this._initCommands();
+ }
+
+ private _initCommands() {
+ [
+ AddDocMentionMutation,
+ DeleteDocMentionMutation,
+ AddDocMentionCommand,
+ DeleteDocMentionCommand,
+ ].forEach((command) => {
+ this.disposeWithMe(this._commandService.registerCommand(command));
+ });
+ }
+}
diff --git a/packages/docs-mention/src/index.ts b/packages/docs-mention/src/index.ts
new file mode 100644
index 0000000000..ef782b45ec
--- /dev/null
+++ b/packages/docs-mention/src/index.ts
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export { DocMentionModel } from './models/doc-mention.model';
+export { DocMentionService } from './services/doc-mention.service';
+export { DOC_MENTION_PLUGIN } from './types/const/const';
+export type { IMention, IDocMention } from './types/interfaces/i-mention';
+export { MentionType } from './types/enums/mention-type';
+export { UniverDocsMentionPlugin } from './plugin';
+
+// #region - all commands
+export { AddDocMentionMutation, DeleteDocMentionMutation } from './commands/mutations/doc-mention.mutation';
+export type { IAddDocMentionMutationParams, IDeleteDocMentionMutationParams } from './commands/mutations/doc-mention.mutation';
+export { AddDocMentionCommand, DeleteDocMentionCommand } from './commands/commands/doc-mention.command';
+export type { IAddDocMentionCommandParams, IDeleteDocMentionCommandParams } from './commands/commands/doc-mention.command';
+// #endregion
diff --git a/packages/docs-mention/src/models/doc-mention.model.ts b/packages/docs-mention/src/models/doc-mention.model.ts
new file mode 100644
index 0000000000..bc2b34e329
--- /dev/null
+++ b/packages/docs-mention/src/models/doc-mention.model.ts
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Disposable, Tools } from '@univerjs/core';
+import type { IDocMention } from '../types/interfaces/i-mention';
+
+export class DocMentionModel extends Disposable {
+ private _mentionMaps = new Map<string, Map<string, IDocMention>>();
+
+ private _ensureMap(unitId: string) {
+ let unitMap = this._mentionMaps.get(unitId);
+
+ if (!unitMap) {
+ unitMap = new Map();
+ this._mentionMaps.set(unitId, unitMap);
+ }
+
+ return unitMap;
+ }
+
+ addMention(unitId: string, mention: IDocMention) {
+ const map = this._ensureMap(unitId);
+ map.set(mention.id, mention);
+ }
+
+ getMention(unitId: string, id: string) {
+ const map = this._ensureMap(unitId);
+ return map.get(id);
+ }
+
+ copyMention(unitId: string, id: string) {
+ const mention = this.getMention(unitId, id);
+
+ if (!mention) {
+ return undefined;
+ }
+
+ const newId = Tools.generateRandomId();
+ const newMention = { ...mention, id: newId };
+ this.addMention(unitId, newMention);
+ return newMention;
+ }
+
+ deleteMention(unitId: string, id: string) {
+ const map = this._ensureMap(unitId);
+ return map.delete(id);
+ }
+}
diff --git a/packages/docs-mention/src/plugin.ts b/packages/docs-mention/src/plugin.ts
new file mode 100644
index 0000000000..65e773dd6a
--- /dev/null
+++ b/packages/docs-mention/src/plugin.ts
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DependentOn, Plugin, UniverInstanceType } from '@univerjs/core';
+import type { Dependency } from '@wendellhu/redi';
+import { Inject, Injector } from '@wendellhu/redi';
+import { UniverDocsPlugin } from '@univerjs/docs';
+import { DOC_MENTION_PLUGIN } from './types/const/const';
+import { DocMentionModel } from './models/doc-mention.model';
+import { DocMentionController } from './controllers/doc-mention.controller';
+import { DocMentionCustomRangeController } from './controllers/doc-mention-custom-range.controller';
+import { DocMentionService } from './services/doc-mention.service';
+
+@DependentOn(UniverDocsPlugin)
+export class UniverDocsMentionPlugin extends Plugin {
+ static override pluginName = DOC_MENTION_PLUGIN;
+ static override type = UniverInstanceType.UNIVER_DOC;
+
+ constructor(
+ private _config: unknown,
+ @Inject(Injector) protected override _injector: Injector
+ ) {
+ super();
+ }
+
+ override onStarting(injector: Injector): void {
+ const deps: Dependency[] = [
+ [DocMentionModel],
+ [DocMentionService],
+
+ [DocMentionController],
+ [DocMentionCustomRangeController],
+ ];
+
+ deps.forEach((dep) => {
+ injector.add(dep);
+ });
+ }
+}
diff --git a/packages/docs-mention/src/services/doc-mention.service.ts b/packages/docs-mention/src/services/doc-mention.service.ts
new file mode 100644
index 0000000000..8915880bb0
--- /dev/null
+++ b/packages/docs-mention/src/services/doc-mention.service.ts
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Nullable } from '@univerjs/core';
+import { Disposable } from '@univerjs/core';
+import { BehaviorSubject } from 'rxjs';
+
+export class DocMentionService extends Disposable {
+ private readonly _editing$ = new BehaviorSubject<Nullable<number>>(undefined);
+ readonly editing$ = this._editing$.asObservable();
+
+ get editing() {
+ return this._editing$.value;
+ }
+
+ constructor() {
+ super();
+
+ this.disposeWithMe(() => {
+ this._editing$.complete();
+ });
+ }
+
+ startEditing(index: number) {
+ this._editing$.next(index);
+ }
+
+ endEditing() {
+ this._editing$.next(undefined);
+ }
+}
diff --git a/packages/docs-mention/src/types/const/const.ts b/packages/docs-mention/src/types/const/const.ts
new file mode 100644
index 0000000000..f413ca8adc
--- /dev/null
+++ b/packages/docs-mention/src/types/const/const.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export const DOC_MENTION_PLUGIN = 'DOC_MENTION_PLUGIN';
diff --git a/packages/docs-mention/src/types/enums/mention-type.ts b/packages/docs-mention/src/types/enums/mention-type.ts
new file mode 100644
index 0000000000..c2d74c09bd
--- /dev/null
+++ b/packages/docs-mention/src/types/enums/mention-type.ts
@@ -0,0 +1,19 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export enum MentionType {
+ PERSON,
+}
diff --git a/packages/docs-mention/src/types/interfaces/i-mention.ts b/packages/docs-mention/src/types/interfaces/i-mention.ts
new file mode 100644
index 0000000000..7099a5eea1
--- /dev/null
+++ b/packages/docs-mention/src/types/interfaces/i-mention.ts
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { MentionType } from '../enums/mention-type';
+
+export interface IDocMention extends IMention {
+ id: string;
+}
+
+export interface IMention {
+ // mention payload
+ objectType: MentionType;
+ objectId: string;
+ label: string;
+ extra?: Record<string, any>;
+}
diff --git a/packages/docs-mention/src/vite-env.d.ts b/packages/docs-mention/src/vite-env.d.ts
new file mode 100644
index 0000000000..11f02fe2a0
--- /dev/null
+++ b/packages/docs-mention/src/vite-env.d.ts
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/packages/docs-mention/tsconfig.json b/packages/docs-mention/tsconfig.json
new file mode 100644
index 0000000000..d676ad2a20
--- /dev/null
+++ b/packages/docs-mention/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "@univerjs/shared/tsconfigs/base",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "lib/types"
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src"]
+}
diff --git a/packages/docs-mention/tsconfig.node.json b/packages/docs-mention/tsconfig.node.json
new file mode 100644
index 0000000000..e53dac8868
--- /dev/null
+++ b/packages/docs-mention/tsconfig.node.json
@@ -0,0 +1,4 @@
+{
+ "extends": "@univerjs/shared/tsconfigs/node",
+ "include": ["vite.config.ts"]
+}
diff --git a/packages/docs-mention/vite.config.ts b/packages/docs-mention/vite.config.ts
new file mode 100644
index 0000000000..d6d74d882a
--- /dev/null
+++ b/packages/docs-mention/vite.config.ts
@@ -0,0 +1,13 @@
+import createViteConfig from '@univerjs/shared/vite';
+import pkg from './package.json';
+
+export default ({ mode }) => createViteConfig({
+}, {
+ mode,
+ pkg,
+ features: {
+ react: true,
+ css: true,
+ dom: true,
+ },
+});
diff --git a/packages/docs-thread-comment-ui/package.json b/packages/docs-thread-comment-ui/package.json
index 1f8a67d6e6..445190e44a 100644
--- a/packages/docs-thread-comment-ui/package.json
+++ b/packages/docs-thread-comment-ui/package.json
@@ -64,7 +64,7 @@
"@univerjs/thread-comment": "workspace:*",
"@univerjs/thread-comment-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
},
diff --git a/packages/docs-ui/package.json b/packages/docs-ui/package.json
index 7f3fd5fb5b..18c2de6687 100644
--- a/packages/docs-ui/package.json
+++ b/packages/docs-ui/package.json
@@ -70,7 +70,7 @@
"@univerjs/docs": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/docs-ui/src/services/clipboard/clipboard.service.ts b/packages/docs-ui/src/services/clipboard/clipboard.service.ts
index 5f8d2242b5..c8310f2952 100644
--- a/packages/docs-ui/src/services/clipboard/clipboard.service.ts
+++ b/packages/docs-ui/src/services/clipboard/clipboard.service.ts
@@ -153,11 +153,18 @@ export class DocClipboardService extends Disposable implements IDocClipboardServ
private async _paste(_body: IDocumentBody): Promise<boolean> {
let body = normalizeBody(_body);
+ const unitId = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)?.getUnitId();
+ if (!unitId) {
+ return false;
+ }
+
this._clipboardHooks.forEach((hook) => {
if (hook.onBeforePaste) {
body = hook.onBeforePaste(body);
}
});
+ body.customRanges = body.customRanges?.map((range) => this._docCustomRangeService.copyCustomRange(unitId, range));
+
const activeRange = this._textSelectionManagerService.getActiveRange();
const { segmentId, endOffset: activeEndOffset, style } = activeRange || {};
const ranges = this._textSelectionManagerService.getCurrentSelections();
diff --git a/packages/docs/package.json b/packages/docs/package.json
index 44118beb6d..dc315426e8 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -62,7 +62,7 @@
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/docs/src/basics/custom-range-factory.ts b/packages/docs/src/basics/custom-range-factory.ts
index f4974faa9d..44472e363b 100644
--- a/packages/docs/src/basics/custom-range-factory.ts
+++ b/packages/docs/src/basics/custom-range-factory.ts
@@ -109,11 +109,12 @@ interface IAddCustomRangeFactoryParam {
segmentId?: string;
rangeId: string;
rangeType: CustomRangeType;
+ wholeEntity?: boolean;
}
// eslint-disable-next-line max-lines-per-function
export function addCustomRangeBySelectionFactory(accessor: IAccessor, param: IAddCustomRangeFactoryParam) {
- const { segmentId, rangeId, rangeType } = param;
+ const { segmentId, rangeId, rangeType, wholeEntity } = param;
const textSelectionManagerService = accessor.get(TextSelectionManagerService);
const univerInstanceService = accessor.get(IUniverInstanceService);
@@ -215,6 +216,7 @@ export function addCustomRangeBySelectionFactory(accessor: IAccessor, param: IAd
rangeType,
startIndex: -(range.endOffset - range.startOffset - deletes.length + 1),
endIndex: 0,
+ wholeEntity,
},
],
},
diff --git a/packages/docs/src/basics/replace.ts b/packages/docs/src/basics/replace.ts
new file mode 100644
index 0000000000..f735bd9278
--- /dev/null
+++ b/packages/docs/src/basics/replace.ts
@@ -0,0 +1,165 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { DocumentDataModel, IDeleteAction, IDocumentBody, IMutationInfo, IRetainAction, ITextRange } from '@univerjs/core';
+import { IUniverInstanceService, JSONX, TextX, TextXActionType } from '@univerjs/core';
+import type { ITextRangeWithStyle } from '@univerjs/engine-render';
+import type { IAccessor } from '@wendellhu/redi';
+import type { IRichTextEditingMutationParams } from '../commands/mutations/core-editing.mutation';
+import { RichTextEditingMutation } from '../commands/mutations/core-editing.mutation';
+import { TextSelectionManagerService } from '../services/text-selection-manager.service';
+import { isIntersecting, shouldDeleteCustomRange } from './custom-range';
+import { getDeleteSelection } from './selection';
+
+// If the selection contains line breaks,
+// paragraph information needs to be preserved when performing the CUT operation
+// eslint-disable-next-line max-lines-per-function
+export function getRetainAndDeleteAndExcludeLineBreak(
+ selection: ITextRange,
+ body: IDocumentBody,
+ segmentId: string = '',
+ memoryCursor: number = 0
+): Array<IRetainAction | IDeleteAction> {
+ const { startOffset, endOffset } = getDeleteSelection(selection, body);
+ const dos: Array<IRetainAction | IDeleteAction> = [];
+
+ const { paragraphs = [], dataStream } = body;
+
+ const textStart = startOffset - memoryCursor;
+ const textEnd = endOffset - memoryCursor;
+
+ const paragraphInRange = paragraphs?.find(
+ (p) => p.startIndex - memoryCursor >= textStart && p.startIndex - memoryCursor < textEnd
+ );
+
+ const relativeCustomRanges = body.customRanges?.filter((customRange) => isIntersecting(customRange.startIndex, customRange.endIndex, startOffset, endOffset));
+ const toDeleteRanges = new Set(relativeCustomRanges?.filter((customRange) => shouldDeleteCustomRange(startOffset, endOffset - startOffset, customRange, dataStream)));
+ const retainPoints = new Set<number>();
+
+ relativeCustomRanges?.forEach((range) => {
+ if (toDeleteRanges.has(range)) {
+ return;
+ }
+
+ if (range.startIndex - memoryCursor >= textStart &&
+ range.startIndex - memoryCursor <= textEnd &&
+ range.endIndex - memoryCursor > textEnd) {
+ retainPoints.add(range.startIndex);
+ }
+ if (range.endIndex - memoryCursor >= textStart &&
+ range.endIndex - memoryCursor <= textEnd &&
+ range.startIndex < textStart) {
+ retainPoints.add(range.endIndex);
+ }
+ });
+
+ if (textStart > 0) {
+ dos.push({
+ t: TextXActionType.RETAIN,
+ len: textStart,
+ segmentId,
+ });
+ }
+
+ if (paragraphInRange && paragraphInRange.startIndex - memoryCursor > textStart) {
+ const paragraphIndex = paragraphInRange.startIndex - memoryCursor;
+ retainPoints.add(paragraphIndex);
+ }
+
+ const sortedRetains = [...retainPoints].sort((pre, aft) => pre - aft);
+
+ let cursor = textStart;
+ sortedRetains.forEach((pos) => {
+ const len = pos - cursor;
+ if (len > 0) {
+ dos.push({
+ t: TextXActionType.DELETE,
+ len,
+ line: 0,
+ segmentId,
+ });
+ }
+ dos.push({
+ t: TextXActionType.RETAIN,
+ len: 1,
+ segmentId,
+ });
+ cursor = pos + 1;
+ });
+
+ if (cursor < textEnd) {
+ dos.push({
+ t: TextXActionType.DELETE,
+ len: textEnd - cursor,
+ line: 0,
+ segmentId,
+ });
+ }
+ return dos;
+}
+
+export interface IReplaceSelectionFactoryParams {
+ unitId: string;
+ selection?: ITextRange;
+ body: IDocumentBody; // Do not contain `\r\n` at the end.
+ textRanges?: ITextRangeWithStyle[];
+}
+
+export function replaceSelectionFactory(accessor: IAccessor, params: IReplaceSelectionFactoryParams) {
+ const { unitId, body: insertBody } = params;
+ const univerInstanceService = accessor.get(IUniverInstanceService);
+ const docDataModel = univerInstanceService.getUnit<DocumentDataModel>(unitId);
+ const textSelectionManagerService = accessor.get(TextSelectionManagerService);
+ if (!docDataModel) {
+ return false;
+ }
+
+ const body = docDataModel.getBody();
+ const selection = params.selection ?? textSelectionManagerService.getActiveRange();
+ if (!selection || !body) {
+ return false;
+ }
+
+ const textRanges = params.textRanges ?? [{
+ startOffset: selection.startOffset + insertBody.dataStream.length,
+ endOffset: selection.startOffset + insertBody.dataStream.length,
+ collapsed: true,
+ }];
+
+ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {
+ id: RichTextEditingMutation.id,
+ params: {
+ unitId,
+ actions: [],
+ textRanges,
+ debounce: true,
+ },
+ };
+
+ const textX = new TextX();
+ const jsonX = JSONX.getInstance();
+ // delete
+ textX.push(...getRetainAndDeleteAndExcludeLineBreak(selection, body));
+ // insert
+ textX.push({
+ t: TextXActionType.INSERT,
+ body: insertBody,
+ len: insertBody.dataStream.length,
+ line: 0,
+ });
+ doMutation.params.actions = jsonX.editOp(textX.serialize());
+ return doMutation;
+}
diff --git a/packages/docs/src/basics/selection.ts b/packages/docs/src/basics/selection.ts
index 35e2ceb063..ce512f88fc 100644
--- a/packages/docs/src/basics/selection.ts
+++ b/packages/docs/src/basics/selection.ts
@@ -16,6 +16,7 @@
import type { IDocumentBody, ITextRange, Nullable } from '@univerjs/core';
import { DataStreamTreeTokenType } from '@univerjs/core';
+import { DeleteDirection } from '../types/enums/delete-direction';
import { isCustomRangeSplitSymbol } from './custom-range';
export function normalizeSelection(selection: ITextRange) {
@@ -62,26 +63,52 @@ export function getSelectionWithNoSymbolSide(selection: ITextRange, body: IDocum
};
}
-export function getDeleteSelection(selection: ITextRange, body: IDocumentBody) {
+export function getDeleteSelection<T extends ITextRange>(selection: T, body: IDocumentBody, direction = DeleteDirection.LEFT): T {
let { startOffset, endOffset, collapsed } = normalizeSelection(selection);
if (collapsed) {
- while (isCustomRangeSplitSymbol(body.dataStream[startOffset - 1])) {
- endOffset -= 1;
- startOffset -= 1;
+ if (direction === DeleteDirection.LEFT) {
+ while (body.dataStream[startOffset - 1] === DataStreamTreeTokenType.CUSTOM_RANGE_END) {
+ endOffset -= 1;
+ startOffset -= 1;
+ }
+ } else {
+ while (body.dataStream[startOffset] === DataStreamTreeTokenType.CUSTOM_RANGE_START) {
+ endOffset += 1;
+ startOffset += 1;
+ }
}
-
- return {
- startOffset,
- endOffset,
- collapsed,
- };
} else {
- return {
- ...getSelectionWithSymbolMax(selection, body),
- collapsed: false,
- };
+ const selectionWithSymbolMax = getSelectionWithSymbolMax(selection, body);
+ startOffset = selectionWithSymbolMax.startOffset;
+ endOffset = selectionWithSymbolMax.endOffset;
}
+
+ collapsed = (startOffset === endOffset);
+
+ const customRanges = body.customRanges?.filter((range) => {
+ if (!range.wholeEntity) {
+ return false;
+ }
+ if (startOffset <= range.startIndex && endOffset > range.endIndex) {
+ return false;
+ }
+ return isSegmentIntersects(startOffset, collapsed ? endOffset : endOffset - 1, range.startIndex, range.endIndex);
+ });
+
+ if (customRanges?.length) {
+ customRanges.forEach((range) => {
+ startOffset = Math.min(range.startIndex, startOffset);
+ endOffset = Math.max(range.endIndex + 1, endOffset);
+ });
+ }
+
+ return {
+ ...selection,
+ startOffset,
+ endOffset,
+ collapsed: startOffset === endOffset,
+ };
}
export function getInsertSelection(selection: ITextRange, body: IDocumentBody): ITextRange {
@@ -200,3 +227,8 @@ export function getSelectionText(dataStream: string, start: number, end: number)
const text = dataStream.slice(start, end);
return tags.reduce((res, curr) => res.replaceAll(curr, ''), text);
}
+
+export function isSegmentIntersects(start: number, end: number, start2: number, end2: number) {
+ return Math.max(start, start2) <= Math.min(end, end2);
+}
+
diff --git a/packages/docs/src/commands/commands/clipboard.inner.command.ts b/packages/docs/src/commands/commands/clipboard.inner.command.ts
index b10a9ebcb5..432aacec5e 100644
--- a/packages/docs/src/commands/commands/clipboard.inner.command.ts
+++ b/packages/docs/src/commands/commands/clipboard.inner.command.ts
@@ -16,10 +16,8 @@
import type {
ICommand,
- IDeleteAction,
IDocumentBody,
IMutationInfo,
- IRetainAction,
ITextRange,
JSONXActions,
} from '@univerjs/core';
@@ -33,15 +31,14 @@ import {
TextX,
TextXActionType,
} from '@univerjs/core';
-import type { ITextRangeWithStyle, TextRange } from '@univerjs/engine-render';
+import type { ITextRangeWithStyle } from '@univerjs/engine-render';
import { getRetainAndDeleteFromReplace } from '../../basics/retain-delete-params';
import { TextSelectionManagerService } from '../../services/text-selection-manager.service';
import type { IRichTextEditingMutationParams } from '../mutations/core-editing.mutation';
import { RichTextEditingMutation } from '../mutations/core-editing.mutation';
-import { isIntersecting, shouldDeleteCustomRange } from '../../basics/custom-range';
-import { getDeleteSelection } from '../../basics/selection';
import { getRichTextEditPath } from '../util';
+import { getRetainAndDeleteAndExcludeLineBreak } from '../../basics/replace';
export interface IInnerPasteCommandParams {
segmentId: string;
@@ -132,6 +129,7 @@ export const InnerPasteCommand: ICommand<IInnerPasteCommandParams> = {
export interface IInnerCutCommandParams {
segmentId: string;
textRanges: ITextRangeWithStyle[];
+ selections?: ITextRange[];
}
export const CutContentCommand: ICommand<IInnerCutCommandParams> = {
@@ -146,7 +144,7 @@ export const CutContentCommand: ICommand<IInnerCutCommandParams> = {
const textSelectionManagerService = accessor.get(TextSelectionManagerService);
const univerInstanceService = accessor.get(IUniverInstanceService);
- const selections = textSelectionManagerService.getCurrentSelections();
+ const selections = params.selections ?? textSelectionManagerService.getCurrentSelections();
if (!Array.isArray(selections) || selections.length === 0) {
return false;
@@ -248,7 +246,7 @@ export const CutContentCommand: ICommand<IInnerCutCommandParams> = {
},
};
-function getCustomBlockIdsInSelections(body: IDocumentBody, selections: TextRange[]): string[] {
+function getCustomBlockIdsInSelections(body: IDocumentBody, selections: ITextRange[]): string[] {
const customBlockIds: string[] = [];
const { customBlocks = [] } = body;
@@ -271,89 +269,3 @@ function getCustomBlockIdsInSelections(body: IDocumentBody, selections: TextRang
return customBlockIds;
}
-// If the selection contains line breaks,
-// paragraph information needs to be preserved when performing the CUT operation
-// eslint-disable-next-line max-lines-per-function
-function getRetainAndDeleteAndExcludeLineBreak(
- selection: ITextRange,
- body: IDocumentBody,
- segmentId: string = '',
- memoryCursor: number = 0
-): Array<IRetainAction | IDeleteAction> {
- const { startOffset, endOffset } = getDeleteSelection(selection, body);
- const dos: Array<IRetainAction | IDeleteAction> = [];
-
- const { paragraphs = [], dataStream } = body;
-
- const textStart = startOffset - memoryCursor;
- const textEnd = endOffset - memoryCursor;
-
- const paragraphInRange = paragraphs?.find(
- (p) => p.startIndex - memoryCursor >= textStart && p.startIndex - memoryCursor <= textEnd
- );
-
- const relativeCustomRanges = body.customRanges?.filter((customRange) => isIntersecting(customRange.startIndex, customRange.endIndex, startOffset, endOffset));
- const toDeleteRanges = new Set(relativeCustomRanges?.filter((customRange) => shouldDeleteCustomRange(startOffset, endOffset - startOffset, customRange, dataStream)));
- const retainPoints = new Set<number>();
-
- relativeCustomRanges?.forEach((range) => {
- if (toDeleteRanges.has(range)) {
- return;
- }
-
- if (range.startIndex - memoryCursor >= textStart &&
- range.startIndex - memoryCursor <= textEnd &&
- range.endIndex - memoryCursor > textEnd) {
- retainPoints.add(range.startIndex);
- }
- if (range.endIndex - memoryCursor >= textStart &&
- range.endIndex - memoryCursor <= textEnd &&
- range.startIndex < textStart) {
- retainPoints.add(range.endIndex);
- }
- });
-
- if (textStart > 0) {
- dos.push({
- t: TextXActionType.RETAIN,
- len: textStart,
- segmentId,
- });
- }
-
- if (paragraphInRange && paragraphInRange.startIndex - memoryCursor > textStart) {
- const paragraphIndex = paragraphInRange.startIndex - memoryCursor;
- retainPoints.add(paragraphIndex);
- }
-
- const sortedRetains = [...retainPoints].sort((pre, aft) => pre - aft);
-
- let cursor = textStart;
- sortedRetains.forEach((pos) => {
- const len = pos - cursor;
- if (len > 0) {
- dos.push({
- t: TextXActionType.DELETE,
- len,
- line: 0,
- segmentId,
- });
- }
- dos.push({
- t: TextXActionType.RETAIN,
- len: 1,
- segmentId,
- });
- cursor = pos + 1;
- });
-
- if (cursor < textEnd) {
- dos.push({
- t: TextXActionType.DELETE,
- len: textEnd - cursor,
- line: 0,
- segmentId,
- });
- }
- return dos;
-}
diff --git a/packages/docs/src/commands/commands/core-editing.command.ts b/packages/docs/src/commands/commands/core-editing.command.ts
index 2fdeeabbaf..99d9fc0d40 100644
--- a/packages/docs/src/commands/commands/core-editing.command.ts
+++ b/packages/docs/src/commands/commands/core-editing.command.ts
@@ -32,6 +32,7 @@ import { isIntersecting, shouldDeleteCustomRange } from '../../basics/custom-ran
import { TextSelectionManagerService } from '../../services/text-selection-manager.service';
import { getInsertSelection } from '../../basics/selection';
import { getRichTextEditPath } from '../util';
+import { DeleteDirection } from '../../types/enums/delete-direction';
export interface IInsertCommandParams {
unitId: string;
@@ -135,11 +136,6 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {
},
};
-export enum DeleteDirection {
- LEFT,
- RIGHT,
-}
-
export interface IDeleteCommandParams {
unitId: string;
range: ITextRange;
diff --git a/packages/docs/src/commands/commands/delete.command.ts b/packages/docs/src/commands/commands/delete.command.ts
index b9c9f94c6d..1f8a3ca3d1 100644
--- a/packages/docs/src/commands/commands/delete.command.ts
+++ b/packages/docs/src/commands/commands/delete.command.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { ICommand, ICustomBlock, IDocumentBody, IMutationInfo, IParagraph, ITextRun, JSONXActions } from '@univerjs/core';
+import type { ICommand, ICustomBlock, IDocumentBody, IMutationInfo, IParagraph, ITextRange, ITextRun, JSONXActions } from '@univerjs/core';
import {
CommandType,
getCustomDecorationSlice,
@@ -27,7 +27,7 @@ import {
TextXActionType,
UpdateDocsAttributeType,
} from '@univerjs/core';
-import type { IActiveTextRange, ITextRangeWithStyle, TextRange } from '@univerjs/engine-render';
+import type { IActiveTextRange, ITextRangeWithStyle } from '@univerjs/engine-render';
import { getParagraphByGlyph, hasListGlyph, isFirstGlyph, isIndentByGlyph } from '@univerjs/engine-render';
import type { IAccessor } from '@wendellhu/redi';
@@ -35,11 +35,12 @@ import type { ITextActiveRange } from '../../services/text-selection-manager.ser
import { TextSelectionManagerService } from '../../services/text-selection-manager.service';
import type { IRichTextEditingMutationParams } from '../mutations/core-editing.mutation';
import { RichTextEditingMutation } from '../mutations/core-editing.mutation';
-import { getDeleteSelection, getInsertSelection } from '../../basics/selection';
+import { getDeleteSelection } from '../../basics/selection';
import { getCommandSkeleton, getRichTextEditPath } from '../util';
import { DocCustomRangeService } from '../../services/doc-custom-range.service';
+import { DeleteDirection } from '../../types/enums/delete-direction';
import { CutContentCommand } from './clipboard.inner.command';
-import { DeleteCommand, DeleteDirection, UpdateCommand } from './core-editing.command';
+import { DeleteCommand, UpdateCommand } from './core-editing.command';
export interface IDeleteCustomBlockParams {
direction: DeleteDirection;
@@ -419,15 +420,13 @@ export const DeleteLeftCommand: ICommand = {
});
}
} else {
- const textRanges = getTextRangesWhenDelete({
- ...activeRange,
- ...actualRange,
- }, ranges);
+ const textRanges = getTextRangesWhenDelete(actualRange, [actualRange]);
// If the selection is not closed, the effect of Delete and
// BACKSPACE is the same as CUT, so the CUT command is executed.
result = await commandService.executeCommand(CutContentCommand.id, {
segmentId,
textRanges,
+ selections: [actualRange],
});
}
}
@@ -467,7 +466,7 @@ export const DeleteRightCommand: ICommand = {
return false;
}
- const actualRange = getInsertSelection(activeRange, body);
+ const actualRange = getDeleteSelection(activeRange, body, DeleteDirection.RIGHT);
const { startOffset, endOffset, collapsed } = actualRange;
// No need to delete when the cursor is at the last position of the last paragraph.
if (startOffset === body.dataStream.length - 2 && collapsed) {
@@ -546,13 +545,14 @@ export const DeleteRightCommand: ICommand = {
});
}
} else {
- const textRanges = getTextRangesWhenDelete(activeRange, ranges);
+ const textRanges = getTextRangesWhenDelete(actualRange, [actualRange]);
// If the selection is not closed, the effect of Delete and
// BACKSPACE is the same as CUT, so the CUT command is executed.
result = await commandService.executeCommand(CutContentCommand.id, {
segmentId,
textRanges,
+ selections: [actualRange],
});
}
@@ -623,7 +623,7 @@ function getParagraphBody(accessor: IAccessor, unitId: string, body: IDocumentBo
}
// get cursor position when BACKSPACE/DELETE excuse the CutContentCommand.
-function getTextRangesWhenDelete(activeRange: ITextActiveRange, ranges: readonly TextRange[]) {
+function getTextRangesWhenDelete(activeRange: ITextActiveRange, ranges: readonly ITextRange[]) {
let cursor = activeRange.endOffset;
for (const range of ranges) {
diff --git a/packages/docs/src/commands/commands/replace-content.command.ts b/packages/docs/src/commands/commands/replace-content.command.ts
index cdcdaaf248..95384ae813 100644
--- a/packages/docs/src/commands/commands/replace-content.command.ts
+++ b/packages/docs/src/commands/commands/replace-content.command.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { DocumentDataModel, ICommand, IDocumentBody, IMutationInfo } from '@univerjs/core';
+import type { DocumentDataModel, ICommand, IDocumentBody, IMutationInfo, ITextRange } from '@univerjs/core';
import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, JSONX, TextX, TextXActionType } from '@univerjs/core';
import type { ITextRangeWithStyle } from '@univerjs/engine-render';
@@ -22,6 +22,7 @@ import { TextSelectionManagerService } from '../../services/text-selection-manag
import type { IRichTextEditingMutationParams } from '../mutations/core-editing.mutation';
import { RichTextEditingMutation } from '../mutations/core-editing.mutation';
import { getRichTextEditPath } from '../util';
+import { getRetainAndDeleteAndExcludeLineBreak } from '../../basics/replace';
interface IReplaceContentCommandParams {
unitId: string;
@@ -150,3 +151,59 @@ function getMutationParams(unitId: string, segmentId: string, docDatModel: Docum
return doMutation;
}
+
+export interface IReplaceSelectionCommandParams {
+ unitId: string;
+ selection?: ITextRange;
+ body: IDocumentBody; // Do not contain `\r\n` at the end.
+ textRanges?: ITextRangeWithStyle[];
+}
+
+// TODO: implement
+export const ReplaceSelectionCommand: ICommand<IReplaceSelectionCommandParams> = {
+ id: 'doc.command.replace-selection',
+ type: CommandType.COMMAND,
+ handler(accessor, params) {
+ if (!params) {
+ return false;
+ }
+ const { unitId, body: insertBody, textRanges } = params;
+ const univerInstanceService = accessor.get(IUniverInstanceService);
+ const docDataModel = univerInstanceService.getUnit<DocumentDataModel>(unitId);
+ const textSelectionManagerService = accessor.get(TextSelectionManagerService);
+ if (!docDataModel) {
+ return false;
+ }
+
+ const body = docDataModel.getBody();
+ const selection = params.selection ?? textSelectionManagerService.getActiveRange();
+ if (!selection || !body) {
+ return false;
+ }
+
+ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {
+ id: RichTextEditingMutation.id,
+ params: {
+ unitId,
+ actions: [],
+ textRanges,
+ debounce: true,
+ },
+ };
+
+ const textX = new TextX();
+ const jsonX = JSONX.getInstance();
+ // delete
+ textX.push(...getRetainAndDeleteAndExcludeLineBreak(selection, body));
+ // insert
+ textX.push({
+ t: TextXActionType.INSERT,
+ body: insertBody,
+ len: insertBody.dataStream.length,
+ line: 0,
+ });
+ doMutation.params.actions = jsonX.editOp(textX.serialize());
+
+ return true;
+ },
+};
diff --git a/packages/docs/src/controllers/custom-range.controller.ts b/packages/docs/src/controllers/custom-range.controller.ts
new file mode 100644
index 0000000000..670a68f4a0
--- /dev/null
+++ b/packages/docs/src/controllers/custom-range.controller.ts
@@ -0,0 +1,90 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { DocumentDataModel } from '@univerjs/core';
+import { Disposable, ICommandService, IUniverInstanceService, LifecycleStages, OnLifecycle } from '@univerjs/core';
+import { Inject } from '@wendellhu/redi';
+import type { ITextRangeWithStyle } from '@univerjs/engine-render';
+import type { ISetTextSelectionsOperationParams } from '../commands/operations/text-selection.operation';
+import { SetTextSelectionsOperation } from '../commands/operations/text-selection.operation';
+import { TextSelectionManagerService } from '../services/text-selection-manager.service';
+import { isSegmentIntersects } from '../basics/selection';
+
+@OnLifecycle(LifecycleStages.Ready, DocCustomRangeController)
+export class DocCustomRangeController extends Disposable {
+ constructor(
+ @ICommandService private readonly _commandService: ICommandService,
+ @Inject(TextSelectionManagerService) private readonly _textSelectionManagerService: TextSelectionManagerService,
+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService
+ ) {
+ super();
+
+ this._initSelectionChange();
+ }
+
+ private _transformCustomRange(doc: DocumentDataModel, selection: ITextRangeWithStyle) {
+ const { startOffset, endOffset, collapsed } = selection;
+ // find ranges intersect but not contain with selection
+ const customRanges = doc.getCustomRanges()?.filter((range) => {
+ if (!range.wholeEntity) {
+ return false;
+ }
+ if (startOffset <= range.startIndex && endOffset > range.endIndex) {
+ return false;
+ }
+
+ if (collapsed) {
+ return range.startIndex < startOffset && range.endIndex >= endOffset;
+ }
+ return isSegmentIntersects(startOffset, endOffset - 1, range.startIndex, range.endIndex);
+ });
+
+ if (customRanges?.length) {
+ let start = startOffset;
+ let end = endOffset;
+ customRanges.forEach((range) => {
+ start = Math.min(range.startIndex, start);
+ end = Math.max(range.endIndex + 1, end);
+ });
+
+ return {
+ ...selection,
+ startOffset: start,
+ endOffset: end,
+ collapsed: start === end,
+ };
+ }
+
+ return selection;
+ }
+
+ private _initSelectionChange() {
+ this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
+ if (commandInfo.id === SetTextSelectionsOperation.id) {
+ const params = commandInfo.params as ISetTextSelectionsOperationParams;
+ const { unitId, ranges, isEditing } = params;
+ const doc = this._univerInstanceService.getUnit<DocumentDataModel>(unitId);
+ if (!doc) {
+ return;
+ }
+ const transformedRanges = ranges.map((range) => this._transformCustomRange(doc, range));
+ if (transformedRanges.some((range, i) => ranges[i] !== range)) {
+ this._textSelectionManagerService.replaceTextRanges(transformedRanges, isEditing);
+ }
+ }
+ }));
+ }
+}
diff --git a/packages/docs/src/controllers/move-cursor.controller.ts b/packages/docs/src/controllers/move-cursor.controller.ts
index 14cdacc43f..ccae8004dc 100644
--- a/packages/docs/src/controllers/move-cursor.controller.ts
+++ b/packages/docs/src/controllers/move-cursor.controller.ts
@@ -16,6 +16,7 @@
import type { ICommandInfo, Nullable } from '@univerjs/core';
import {
+ DataStreamTreeTokenType,
Direction,
Disposable,
ICommandService,
@@ -210,17 +211,18 @@ export class MoveCursorController extends Disposable {
const skeleton = this._renderManagerService.getRenderById(docDataModel.getUnitId())
?.with(DocSkeletonManagerService).getSkeleton();
const docObject = this._getDocObject();
-
- if (activeRange == null || skeleton == null || docObject == null || allRanges == null) {
+ const body = docDataModel.getBody();
+ if (activeRange == null || skeleton == null || docObject == null || allRanges == null || body == null) {
return;
}
const { startOffset, endOffset, style, collapsed, segmentId, startNodePosition, endNodePosition, segmentPage } = activeRange;
const dataStreamLength = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()!.dataStream.length ?? Number.POSITIVE_INFINITY;
+ const customRanges = docDataModel.getCustomRanges() ?? [];
if (direction === Direction.LEFT || direction === Direction.RIGHT) {
- let cursor;
+ let cursor: number;
if (!activeRange.collapsed || allRanges.length > 1) {
let min = Number.POSITIVE_INFINITY;
@@ -243,6 +245,25 @@ export class MoveCursorController extends Disposable {
cursor = Math.min(dataStreamLength - 2, endOffset + curSpan.count);
}
}
+ const skipTokens: string[] = [DataStreamTreeTokenType.CUSTOM_RANGE_START, DataStreamTreeTokenType.CUSTOM_RANGE_END];
+ if (direction === Direction.LEFT) {
+ while (skipTokens.includes(body.dataStream[cursor])) {
+ cursor--;
+ }
+ } else {
+ while (skipTokens.includes(body.dataStream[cursor - 1])) {
+ cursor++;
+ }
+ }
+
+ const relativeRanges = customRanges.filter((range) => range.wholeEntity && range.startIndex < cursor && range.endIndex >= cursor);
+ relativeRanges.forEach((range) => {
+ if (direction === Direction.LEFT) {
+ cursor = Math.min(range.startIndex, cursor);
+ } else {
+ cursor = Math.max(range.endIndex + 1, cursor);
+ }
+ });
this._textSelectionManagerService.replaceTextRanges([
{
diff --git a/packages/docs/src/doc-plugin.ts b/packages/docs/src/doc-plugin.ts
index ea9e9ffc95..82ab8c68fc 100644
--- a/packages/docs/src/doc-plugin.ts
+++ b/packages/docs/src/doc-plugin.ts
@@ -57,6 +57,7 @@ import { TextSelectionManagerService } from './services/text-selection-manager.s
import { DocStateChangeManagerService } from './services/doc-state-change-manager.service';
import { AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignOperationCommand, AlignRightCommand } from './commands/commands/paragraph-align.command';
import { DocCustomRangeService } from './services/doc-custom-range.service';
+import { DocCustomRangeController } from './controllers/custom-range.controller';
export interface IUniverDocsConfig {
hasScroll?: boolean;
@@ -144,6 +145,7 @@ export class UniverDocsPlugin extends Plugin {
[NormalInputController],
[IMEInputController],
[MoveCursorController],
+ [DocCustomRangeController],
] as Dependency[]
).forEach((d) => docInjector.add(d));
diff --git a/packages/docs/src/index.ts b/packages/docs/src/index.ts
index dff427637a..f12d46307b 100644
--- a/packages/docs/src/index.ts
+++ b/packages/docs/src/index.ts
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-export { getSelectionText, getDeleteSelection, getInsertSelection } from './basics/selection';
+export { replaceSelectionFactory } from './basics/replace';
+export { getSelectionText, getDeleteSelection, getInsertSelection, isSegmentIntersects } from './basics/selection';
export type { IDocObjectParam } from './basics/component-tools';
export { getDocObject, neoGetDocObject, getDocObjectById } from './basics/component-tools';
export * from './basics/docs-view-key';
diff --git a/packages/docs/src/types/enums/delete-direction.ts b/packages/docs/src/types/enums/delete-direction.ts
new file mode 100644
index 0000000000..3b4d4170d9
--- /dev/null
+++ b/packages/docs/src/types/enums/delete-direction.ts
@@ -0,0 +1,20 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export enum DeleteDirection {
+ LEFT,
+ RIGHT,
+}
diff --git a/packages/drawing-ui/package.json b/packages/drawing-ui/package.json
index ac90a013eb..6c2bdd0912 100644
--- a/packages/drawing-ui/package.json
+++ b/packages/drawing-ui/package.json
@@ -68,7 +68,7 @@
"@univerjs/drawing": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/drawing/package.json b/packages/drawing/package.json
index 65d9e76946..dda5a76617 100644
--- a/packages/drawing/package.json
+++ b/packages/drawing/package.json
@@ -59,7 +59,7 @@
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"dependencies": {
diff --git a/packages/engine-formula/package.json b/packages/engine-formula/package.json
index c81618b320..7d77931ec9 100644
--- a/packages/engine-formula/package.json
+++ b/packages/engine-formula/package.json
@@ -62,7 +62,7 @@
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/rpc": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"dependencies": {
diff --git a/packages/engine-render/package.json b/packages/engine-render/package.json
index 1d796526e1..b5b60904b8 100644
--- a/packages/engine-render/package.json
+++ b/packages/engine-render/package.json
@@ -61,7 +61,7 @@
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"dependencies": {
diff --git a/packages/engine-render/src/components/docs/layout/style/custom-range.ts b/packages/engine-render/src/components/docs/layout/style/custom-range.ts
index 34e1c5763f..070534c480 100644
--- a/packages/engine-render/src/components/docs/layout/style/custom-range.ts
+++ b/packages/engine-render/src/components/docs/layout/style/custom-range.ts
@@ -18,7 +18,7 @@ import type { ICustomRangeForInterceptor, ITextStyle, Nullable } from '@univerjs
import { BooleanNumber, CustomRangeType } from '@univerjs/core';
export function getCustomRangeStyle(customRange: ICustomRangeForInterceptor): Nullable<ITextStyle> {
- if (customRange.rangeType === CustomRangeType.HYPERLINK) {
+ if (customRange.rangeType === CustomRangeType.HYPERLINK || customRange.rangeType === CustomRangeType.MENTION) {
return {
...customRange.active ? { ul: { s: BooleanNumber.TRUE } } : null,
cl: { rgb: '#274fee' },
diff --git a/packages/facade/package.json b/packages/facade/package.json
index e6b469faf9..36b92435e8 100644
--- a/packages/facade/package.json
+++ b/packages/facade/package.json
@@ -69,7 +69,7 @@
"@univerjs/sheets-formula": "workspace:*",
"@univerjs/sheets-numfmt": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/find-replace/package.json b/packages/find-replace/package.json
index 0c092a9bfd..ccabe9442d 100644
--- a/packages/find-replace/package.json
+++ b/packages/find-replace/package.json
@@ -69,7 +69,7 @@
"@univerjs/design": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
},
diff --git a/packages/network/package.json b/packages/network/package.json
index f0f7bfbe63..8770288247 100644
--- a/packages/network/package.json
+++ b/packages/network/package.json
@@ -60,7 +60,7 @@
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/rpc/package.json b/packages/rpc/package.json
index 7bd05f378b..2640acc8e6 100644
--- a/packages/rpc/package.json
+++ b/packages/rpc/package.json
@@ -57,7 +57,7 @@
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/sheets-conditional-formatting-ui/package.json b/packages/sheets-conditional-formatting-ui/package.json
index 34d69e9b74..eb8cff33f0 100644
--- a/packages/sheets-conditional-formatting-ui/package.json
+++ b/packages/sheets-conditional-formatting-ui/package.json
@@ -73,7 +73,7 @@
"@univerjs/sheets-conditional-formatting": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0",
diff --git a/packages/sheets-conditional-formatting/package.json b/packages/sheets-conditional-formatting/package.json
index c69d4a0b21..aa8fc4f8c9 100644
--- a/packages/sheets-conditional-formatting/package.json
+++ b/packages/sheets-conditional-formatting/package.json
@@ -65,7 +65,7 @@
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/sheets": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"dayjs": ">=1.11.0",
"rxjs": ">=7.0.0"
},
diff --git a/packages/sheets-data-validation/package.json b/packages/sheets-data-validation/package.json
index 0b9042388b..02110af6bc 100644
--- a/packages/sheets-data-validation/package.json
+++ b/packages/sheets-data-validation/package.json
@@ -72,7 +72,7 @@
"@univerjs/sheets-formula": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"dayjs": ">=1.11.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
diff --git a/packages/sheets-drawing-ui/package.json b/packages/sheets-drawing-ui/package.json
index cc10e2b00f..33f66fa84a 100644
--- a/packages/sheets-drawing-ui/package.json
+++ b/packages/sheets-drawing-ui/package.json
@@ -72,7 +72,7 @@
"@univerjs/sheets-drawing": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/sheets-drawing/package.json b/packages/sheets-drawing/package.json
index 70ea43f047..a1070c9ff7 100644
--- a/packages/sheets-drawing/package.json
+++ b/packages/sheets-drawing/package.json
@@ -60,7 +60,7 @@
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/drawing": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/sheets-filter-ui/package.json b/packages/sheets-filter-ui/package.json
index 8b8de6e423..8924b5a21c 100644
--- a/packages/sheets-filter-ui/package.json
+++ b/packages/sheets-filter-ui/package.json
@@ -70,7 +70,7 @@
"@univerjs/sheets-filter": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/sheets-filter/package.json b/packages/sheets-filter/package.json
index f3109177d8..0ff0ecaec9 100644
--- a/packages/sheets-filter/package.json
+++ b/packages/sheets-filter/package.json
@@ -60,7 +60,7 @@
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/sheets": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/sheets-find-replace/package.json b/packages/sheets-find-replace/package.json
index b38ef2277b..f223129be7 100644
--- a/packages/sheets-find-replace/package.json
+++ b/packages/sheets-find-replace/package.json
@@ -67,7 +67,7 @@
"@univerjs/find-replace": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"dependencies": {
diff --git a/packages/sheets-formula/package.json b/packages/sheets-formula/package.json
index 6998f88b39..e99aec82c3 100644
--- a/packages/sheets-formula/package.json
+++ b/packages/sheets-formula/package.json
@@ -73,7 +73,7 @@
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
},
diff --git a/packages/sheets-hyper-link-ui/package.json b/packages/sheets-hyper-link-ui/package.json
index 04ff939852..aad4f14cab 100644
--- a/packages/sheets-hyper-link-ui/package.json
+++ b/packages/sheets-hyper-link-ui/package.json
@@ -75,7 +75,7 @@
"@univerjs/sheets-hyper-link": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/sheets-hyper-link/package.json b/packages/sheets-hyper-link/package.json
index fd51b3c24c..a6b62e5911 100644
--- a/packages/sheets-hyper-link/package.json
+++ b/packages/sheets-hyper-link/package.json
@@ -62,7 +62,7 @@
"@univerjs/engine-formula": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-hyper-link": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/sheets-numfmt/package.json b/packages/sheets-numfmt/package.json
index 4ec9881147..698d2adc69 100644
--- a/packages/sheets-numfmt/package.json
+++ b/packages/sheets-numfmt/package.json
@@ -72,7 +72,7 @@
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
},
diff --git a/packages/sheets-sort-ui/package.json b/packages/sheets-sort-ui/package.json
index 819b90cc60..791f3fea13 100644
--- a/packages/sheets-sort-ui/package.json
+++ b/packages/sheets-sort-ui/package.json
@@ -69,7 +69,7 @@
"@univerjs/sheets-sort": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
},
diff --git a/packages/sheets-sort/package.json b/packages/sheets-sort/package.json
index 133765c54c..2e48b48f3b 100644
--- a/packages/sheets-sort/package.json
+++ b/packages/sheets-sort/package.json
@@ -62,7 +62,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/sheets": "workspace:*",
- "@wendellhu/redi": "0.15.5"
+ "@wendellhu/redi": "0.16.0"
},
"devDependencies": {
"@univerjs/core": "workspace:*",
diff --git a/packages/sheets-thread-comment-base/package.json b/packages/sheets-thread-comment-base/package.json
index 6b486e5606..4ed439de74 100644
--- a/packages/sheets-thread-comment-base/package.json
+++ b/packages/sheets-thread-comment-base/package.json
@@ -61,7 +61,7 @@
"@univerjs/engine-formula": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/thread-comment": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/sheets-thread-comment/package.json b/packages/sheets-thread-comment/package.json
index 4adc5aa05f..c386394cce 100644
--- a/packages/sheets-thread-comment/package.json
+++ b/packages/sheets-thread-comment/package.json
@@ -69,7 +69,7 @@
"@univerjs/thread-comment": "workspace:*",
"@univerjs/thread-comment-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
},
diff --git a/packages/sheets-ui/package.json b/packages/sheets-ui/package.json
index 748e8d998a..d99bb06622 100644
--- a/packages/sheets-ui/package.json
+++ b/packages/sheets-ui/package.json
@@ -74,7 +74,7 @@
"@univerjs/engine-render": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/sheets-zen-editor/package.json b/packages/sheets-zen-editor/package.json
index aee6d250c2..d14e4e2e24 100644
--- a/packages/sheets-zen-editor/package.json
+++ b/packages/sheets-zen-editor/package.json
@@ -71,7 +71,7 @@
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/sheets/package.json b/packages/sheets/package.json
index 7b9d2c7fd4..23edca344b 100644
--- a/packages/sheets/package.json
+++ b/packages/sheets/package.json
@@ -66,7 +66,7 @@
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-numfmt": "workspace:*",
"@univerjs/rpc": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"dependencies": {
diff --git a/packages/slides-ui/package.json b/packages/slides-ui/package.json
index 3853309279..154b52d9aa 100644
--- a/packages/slides-ui/package.json
+++ b/packages/slides-ui/package.json
@@ -70,7 +70,7 @@
"@univerjs/engine-render": "workspace:*",
"@univerjs/slides": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0"
},
diff --git a/packages/slides/package.json b/packages/slides/package.json
index 3948a15bbc..4c8f3a402b 100644
--- a/packages/slides/package.json
+++ b/packages/slides/package.json
@@ -64,7 +64,7 @@
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/engine-render": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"devDependencies": {
diff --git a/packages/thread-comment-ui/package.json b/packages/thread-comment-ui/package.json
index 6f2b7da410..c27d9199db 100644
--- a/packages/thread-comment-ui/package.json
+++ b/packages/thread-comment-ui/package.json
@@ -69,7 +69,7 @@
"@univerjs/engine-render": "workspace:*",
"@univerjs/thread-comment": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"dayjs": ">=1.11.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
diff --git a/packages/thread-comment/package.json b/packages/thread-comment/package.json
index fd1db112bd..9adb8ff09d 100644
--- a/packages/thread-comment/package.json
+++ b/packages/thread-comment/package.json
@@ -62,7 +62,7 @@
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"rxjs": ">=7.0.0"
},
"dependencies": {
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 8357c7a9bc..26d9dd91ef 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -70,7 +70,7 @@
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"clsx": ">=2.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0",
diff --git a/packages/uniscript/package.json b/packages/uniscript/package.json
index e2f99d6b1d..07c1b321ea 100644
--- a/packages/uniscript/package.json
+++ b/packages/uniscript/package.json
@@ -71,7 +71,7 @@
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@wendellhu/redi": "0.15.5",
+ "@wendellhu/redi": "0.16.0",
"monaco-editor": ">=0.44.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5b85295546..16a17fda6e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -133,7 +133,7 @@ importers:
version: 1.6.0([email protected])
'@storybook/addon-essentials':
specifier: 8.1.11
'@storybook/addon-interactions':
specifier: 8.1.11
@@ -148,16 +148,16 @@ importers:
'@storybook/blocks':
specifier: 8.1.11
'@storybook/icons':
specifier: ^1.2.9
'@storybook/react':
specifier: 8.1.11
'@storybook/react-webpack5':
specifier: 8.1.11
'@storybook/types':
specifier: 8.1.11
version: 8.1.11
@@ -171,8 +171,8 @@ importers:
specifier: workspace:*
version: link:../../packages/ui
'@wendellhu/redi':
- specifier: 0.15.5
- version: 0.15.5
+ specifier: 0.16.0
+ version: 0.16.0
css-loader:
specifier: ^6.10.0
@@ -228,6 +228,9 @@ importers:
'@univerjs/docs-hyper-link-ui':
specifier: workspace:*
version: link:../packages/docs-hyper-link-ui
+ '@univerjs/docs-mention-ui':
+ specifier: workspace:*
+ version: link:../packages/docs-mention-ui
'@univerjs/docs-thread-comment-ui':
specifier: workspace:*
version: link:../packages/docs-thread-comment-ui
@@ -820,6 +823,97 @@ importers:
specifier: ^2.0.3
+ packages/docs-mention:
+ dependencies:
+ '@univerjs/ui':
+ specifier: workspace:*
+ version: link:../ui
+ devDependencies:
+ '@types/react':
+ specifier: ^18.3.3
+ version: 18.3.3
+ '@univerjs/core':
+ specifier: workspace:*
+ version: link:../core
+ '@univerjs/docs':
+ specifier: workspace:*
+ version: link:../docs
+ '@univerjs/engine-render':
+ specifier: workspace:*
+ version: link:../engine-render
+ '@univerjs/shared':
+ specifier: workspace:*
+ version: link:../../common/shared
+ '@wendellhu/redi':
+ specifier: 0.16.0
+ version: 0.16.0
+ rxjs:
+ specifier: ^7.8.1
+ version: 7.8.1
+ typescript:
+ specifier: ^5.5.3
+ version: 5.5.3
+ vite:
+ specifier: ^5.3.3
+ vitest:
+ specifier: ^1.6.0
+
+ packages/docs-mention-ui:
+ devDependencies:
+ '@types/react':
+ specifier: ^18.3.3
+ version: 18.3.3
+ '@univerjs/core':
+ specifier: workspace:*
+ version: link:../core
+ '@univerjs/design':
+ specifier: workspace:*
+ version: link:../design
+ '@univerjs/docs':
+ specifier: workspace:*
+ version: link:../docs
+ '@univerjs/docs-mention':
+ specifier: workspace:*
+ version: link:../docs-mention
+ '@univerjs/docs-ui':
+ specifier: workspace:*
+ version: link:../docs-ui
+ '@univerjs/engine-render':
+ specifier: workspace:*
+ version: link:../engine-render
+ '@univerjs/shared':
+ specifier: workspace:*
+ version: link:../../common/shared
+ '@univerjs/ui':
+ specifier: workspace:*
+ version: link:../ui
+ '@wendellhu/redi':
+ specifier: 0.16.0
+ version: 0.16.0
+ clsx:
+ specifier: ^2.1.1
+ version: 2.1.1
+ less:
+ specifier: ^4.2.0
+ version: 4.2.0
+ react:
+ specifier: 18.3.1
+ version: 18.3.1
+ rxjs:
+ specifier: ^7.8.1
+ version: 7.8.1
+ typescript:
+ specifier: ^5.5.3
+ version: 5.5.3
+ vite:
+ specifier: ^5.3.3
+ vitest:
+ specifier: ^1.6.0
+
packages/docs-thread-comment-ui:
dependencies:
'@univerjs/docs':
@@ -5439,9 +5533,15 @@ packages:
'@vitest/[email protected]':
resolution: {integrity: sha512-URM4GLsB2xD37nnTyvf6kfObFafxmycCL8un3OC9gaCs5cti2u+5rJdIflZ2fUJUen4NbvF6jCufwViAFLvz1g==}
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-P4xgwPjwesuBiHisAVz/LSSZtDjOTPYZVmNAnpHHSR6ONrf8eCJOFRvUwdHn30F5M1fxhqtl7QZQUk2dprIXAg==}
+
'@vitest/[email protected]':
resolution: {integrity: sha512-EmSP4mcjYhAcuBWwqgpjR3FYVeiA4ROzRunqKltWjBfLNs1tnMLtF+qtgd5ClTwkDP6/DGlKJTNa6WxNK0bNYQ==}
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-+Hx43f8Chus+DCmygqqfetcAZrDJwvTj0ymqjQq4CvmpKFSTVteEOBzCusu1x2tt4OJcvBflyHUE0DZSLgEMtQ==}
+
'@vitest/[email protected]':
resolution: {integrity: sha512-6OyA6v65Oe3tTzoSuRPcU6kh9m+mPL1vQ2jDlPdn9IQoUxl8rXhBnfICNOC+vwxWY684Vt5UPgtcA2aPFBb6wg==}
@@ -5548,9 +5648,6 @@ packages:
'@webassemblyjs/[email protected]':
resolution: {integrity: sha512-+X4WAlOisVWQMikjbcvY2e0rwPsKQ9F688lksZhBcPycBBuii3O7m8FACbDMWDojpAqvjIncrG8J0XHKyQfVeA==}
- '@wendellhu/[email protected]':
- resolution: {integrity: sha512-16UPZN5lHuyjBljkzFoJuXbGhK4AP0XvhUGHISWBgkNJ5omJlkdFMatWbaB5oHHRWDpsugQWNnIYl6GWnlIDUQ==}
-
'@wendellhu/[email protected]':
resolution: {integrity: sha512-0FlYhI79ol9eEUjj66dT8LTmuYdO4NXTD/y8YSPqeJ37r6dMReGWbE5fJOy6sQ8C+H3bRMuRbf4Ug4C8coZVOA==}
@@ -5599,6 +5696,10 @@ packages:
resolution: {integrity: sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==}
engines: {node: '>=0.4.0'}
+ resolution: {integrity: sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==}
+ engines: {node: '>=0.4.0'}
+
resolution: {integrity: sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==}
engines: {node: '>=0.4.0'}
@@ -8209,6 +8310,9 @@ packages:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
+ resolution: {integrity: sha512-WriZw1luRMlmV3LGJaR6QOJjWwgLUTf89OwT2lUOyjX2dJGBwgmIkbcz+7WFZjrZM635JOIR517++e/67CP9dQ==}
+
resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==}
hasBin: true
@@ -8942,6 +9046,10 @@ packages:
resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
+ resolution: {integrity: sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==}
engines: {node: '>=6'}
@@ -10194,6 +10302,9 @@ packages:
resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-Op+UycaUt/8FbN/Z2TWPBLge3jWrP3xj10f3fnYxf052bKuS3EKs1ZQcVGjnEMdsNVAM+plXRdmjrZ/KgG3Skw==}
+
resolution: {integrity: sha512-0WqXzrsMTyb8yjZJHDqwmnwRJvhALK9LfRtRc6B4UTWe8AijYLZYZ9thuJTZc2VfQWINADW/j+LiJnfy2RoC1w==}
engines: {node: '>= 12.13.0'}
@@ -10321,6 +10432,10 @@ packages:
resolution: {integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==}
+ resolution: {integrity: sha512-i11VH5gS6IFeLY3gMBQ00/MmLncVP7JLXOw1vlgkytLmJK7QnEr7NXf0LBdxfmNPAeyetukOk0bOYrJrFGjYJQ==}
+ engines: {node: '>=14.0.0'}
+
resolution: {integrity: sha512-KIKExllK7jp3uvrNtvRBYBWBOAXSX8ZvoaD8T+7KB/QHIuoJW3Pmr60zucywjAlMb5TeXUkcs/MWeWLu0qvuAQ==}
engines: {node: ^18.0.0 || >=20.0.0}
@@ -10695,6 +10810,11 @@ packages:
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
engines: {node: '>= 0.8'}
+ resolution: {integrity: sha512-de6HJgzC+TFzOu0NTC4RAIsyf/DY/ibWDYQUcuEA84EMHhcefTUGkjFHKKEJhQN4A+6I0u++kr3l36ZF2d7XRw==}
+ engines: {node: ^18.0.0 || >=20.0.0}
+ hasBin: true
+
resolution: {integrity: sha512-14jzwMx7XTcMB+9BhGQyoEAmSl0eOr3nrnn+Z12WNERtOvLN+d2scbRUvyni05rT3997Bg+rZb47NyP4IQPKXg==}
engines: {node: ^18.0.0 || >=20.0.0}
@@ -10738,6 +10858,31 @@ packages:
terser:
optional: true
+ resolution: {integrity: sha512-H5r/dN06swuFnzNFhq/dnz37bPXnq8xB2xB5JOVk8K09rUtoeNN+LHWkoQ0A/i3hvbUKKcCei9KpbxqHMLhLLA==}
+ engines: {node: ^18.0.0 || >=20.0.0}
+ hasBin: true
+ peerDependencies:
+ '@edge-runtime/vm': '*'
+ '@types/node': ^18.0.0 || >=20.0.0
+ '@vitest/browser': 1.6.0
+ '@vitest/ui': 1.6.0
+ happy-dom: '*'
+ jsdom: '*'
+ peerDependenciesMeta:
+ '@edge-runtime/vm':
+ optional: true
+ '@types/node':
+ optional: true
+ '@vitest/browser':
+ optional: true
+ '@vitest/ui':
+ optional: true
+ happy-dom:
+ optional: true
+ jsdom:
+ optional: true
+
resolution: {integrity: sha512-o3HRvU93q6qZK4rI2JrhKyZMMuxg/JRt30E6qeQs6ueaiz5hr1cPj+Sk2kATgQzMMqsa2DiNI0TIK++1ULx8Jw==}
engines: {node: ^18.0.0 || >=20.0.0}
@@ -13100,9 +13245,9 @@ snapshots:
memoizerific: 1.11.3
ts-dedent: 2.2.0
dependencies:
dequal: 2.0.3
lodash: 4.17.21
ts-dedent: 2.2.0
@@ -13115,11 +13260,11 @@ snapshots:
- react-dom
- supports-color
dependencies:
'@babel/core': 7.24.7
'@mdx-js/react': 3.0.1(@types/[email protected])([email protected])
'@storybook/client-logger': 8.1.11
'@storybook/csf-plugin': 8.1.11
@@ -13143,18 +13288,18 @@ snapshots:
- prettier
- supports-color
dependencies:
'@storybook/addon-actions': 8.1.11
'@storybook/addon-backgrounds': 8.1.11
- '@storybook/addon-docs': 8.1.11(@types/[email protected])([email protected])
+ '@storybook/addon-docs': 8.1.11(@types/[email protected])([email protected])
'@storybook/addon-highlight': 8.1.11
'@storybook/addon-measure': 8.1.11
'@storybook/addon-outline': 8.1.11
'@storybook/addon-toolbars': 8.1.11
'@storybook/addon-viewport': 8.1.11
- '@storybook/core-common': 8.1.11([email protected])
+ '@storybook/core-common': 8.1.11([email protected])
'@storybook/manager-api': 8.1.11([email protected]([email protected]))([email protected])
'@storybook/node-logger': 8.1.11
'@storybook/preview-api': 8.1.11
@@ -13224,14 +13369,14 @@ snapshots:
- '@swc/helpers'
- webpack
dependencies:
'@storybook/channels': 8.1.11
'@storybook/client-logger': 8.1.11
'@storybook/core-events': 8.1.11
'@storybook/csf': 0.1.8
- '@storybook/docs-tools': 8.1.11([email protected])
+ '@storybook/docs-tools': 8.1.11([email protected])
'@storybook/global': 5.0.0
'@storybook/manager-api': 8.1.11([email protected]([email protected]))([email protected])
@@ -13260,10 +13405,10 @@ snapshots:
- prettier
- supports-color
dependencies:
'@fal-works/esbuild-plugin-global-externals': 2.1.2
- '@storybook/core-common': 8.1.11([email protected])
+ '@storybook/core-common': 8.1.11([email protected])
'@storybook/manager': 8.1.11
'@storybook/node-logger': 8.1.11
'@types/ejs': 3.1.5
@@ -13281,13 +13426,13 @@ snapshots:
- prettier
- supports-color
dependencies:
'@storybook/channels': 8.1.11
'@storybook/client-logger': 8.1.11
- '@storybook/core-common': 8.1.11([email protected])
+ '@storybook/core-common': 8.1.11([email protected])
'@storybook/core-events': 8.1.11
- '@storybook/core-webpack': 8.1.11([email protected])
+ '@storybook/core-webpack': 8.1.11([email protected])
'@storybook/node-logger': 8.1.11
'@storybook/preview': 8.1.11
'@storybook/preview-api': 8.1.11
@@ -13343,12 +13488,12 @@ snapshots:
'@babel/types': 7.24.7
'@ndelangen/get-tarball': 3.0.9
'@storybook/codemod': 8.1.11
- '@storybook/core-common': 8.1.11([email protected])
+ '@storybook/core-common': 8.1.11([email protected])
'@storybook/core-events': 8.1.11
'@storybook/csf-tools': 8.1.11
'@storybook/node-logger': 8.1.11
- '@storybook/telemetry': 8.1.11([email protected])
+ '@storybook/telemetry': 8.1.11([email protected])
'@storybook/types': 8.1.11
'@types/semver': 7.5.8
'@yarnpkg/fslib': 2.10.3
@@ -13426,6 +13571,43 @@ snapshots:
- '@types/react'
- '@types/react-dom'
+ dependencies:
+ '@storybook/core-events': 8.1.11
+ '@storybook/csf-tools': 8.1.11
+ '@storybook/node-logger': 8.1.11
+ '@storybook/types': 8.1.11
+ '@yarnpkg/fslib': 2.10.3
+ '@yarnpkg/libzip': 2.3.0
+ chalk: 4.1.2
+ cross-spawn: 7.0.3
+ esbuild: 0.20.2
+ esbuild-register: 3.5.0([email protected])
+ execa: 5.1.1
+ file-system-cache: 2.3.0
+ find-cache-dir: 3.3.2
+ find-up: 5.0.0
+ fs-extra: 11.2.0
+ glob: 10.4.1
+ handlebars: 4.7.8
+ lazy-universal-dotenv: 4.0.0
+ node-fetch: 2.7.0
+ picomatch: 2.3.1
+ pkg-dir: 5.0.0
+ prettier-fallback: [email protected]
+ pretty-hrtime: 1.0.3
+ resolve-from: 5.0.0
+ semver: 7.6.2
+ tempy: 3.1.0
+ tiny-invariant: 1.3.3
+ ts-dedent: 2.2.0
+ util: 0.12.5
+ optionalDependencies:
+ prettier: 3.3.2
+ transitivePeerDependencies:
+ - encoding
+ - supports-color
+
dependencies:
'@storybook/core-events': 8.1.11
@@ -13468,15 +13650,15 @@ snapshots:
'@storybook/csf': 0.1.8
ts-dedent: 2.2.0
dependencies:
'@aw-web-design/x-default-browser': 1.4.126
'@babel/core': 7.24.7
'@babel/parser': 7.24.7
'@discoveryjs/json-ext': 0.5.7
- '@storybook/builder-manager': 8.1.11([email protected])
+ '@storybook/builder-manager': 8.1.11([email protected])
'@storybook/channels': 8.1.11
- '@storybook/core-common': 8.1.11([email protected])
+ '@storybook/core-common': 8.1.11([email protected])
'@storybook/core-events': 8.1.11
'@storybook/csf': 0.1.8
'@storybook/csf-tools': 8.1.11
@@ -13486,7 +13668,7 @@ snapshots:
'@storybook/manager-api': 8.1.11([email protected]([email protected]))([email protected])
'@storybook/node-logger': 8.1.11
'@storybook/preview-api': 8.1.11
- '@storybook/telemetry': 8.1.11([email protected])
+ '@storybook/telemetry': 8.1.11([email protected])
'@storybook/types': 8.1.11
'@types/detect-port': 1.3.5
'@types/diff': 5.2.1
@@ -13524,9 +13706,9 @@ snapshots:
- supports-color
- utf-8-validate
dependencies:
- '@storybook/core-common': 8.1.11([email protected])
+ '@storybook/core-common': 8.1.11([email protected])
'@storybook/node-logger': 8.1.11
'@storybook/types': 8.1.11
'@types/node': 18.19.34
@@ -13563,6 +13745,21 @@ snapshots:
'@storybook/[email protected]': {}
+ dependencies:
+ '@storybook/core-common': 8.1.11([email protected])
+ '@storybook/core-events': 8.1.11
+ '@storybook/preview-api': 8.1.11
+ '@storybook/types': 8.1.11
+ '@types/doctrine': 0.0.3
+ assert: 2.1.0
+ doctrine: 3.0.0
+ lodash: 4.17.21
+ transitivePeerDependencies:
+ - encoding
+ - prettier
+ - supports-color
+
dependencies:
'@storybook/core-common': 8.1.11([email protected])
@@ -13622,12 +13819,12 @@ snapshots:
'@storybook/[email protected]': {}
dependencies:
- '@storybook/core-webpack': 8.1.11([email protected])
- '@storybook/docs-tools': 8.1.11([email protected])
+ '@storybook/core-webpack': 8.1.11([email protected])
+ '@storybook/docs-tools': 8.1.11([email protected])
'@storybook/node-logger': 8.1.11
'@storybook/react-docgen-typescript-plugin': 1.0.6--canary.9.0c3f3b7.0([email protected])([email protected](@swc/[email protected])([email protected]))
'@types/node': 18.19.34
'@types/semver': 7.5.8
@@ -13690,11 +13887,11 @@ snapshots:
react: 18.3.1
react-dom: 18.3.1([email protected])
dependencies:
- '@storybook/builder-webpack5': 8.1.11(@swc/[email protected])([email protected])([email protected])([email protected])
+ '@storybook/builder-webpack5': 8.1.11(@swc/[email protected])([email protected])([email protected])([email protected])
'@storybook/types': 8.1.11
'@types/node': 18.19.34
react: 18.3.1
@@ -13711,6 +13908,38 @@ snapshots:
- uglify-js
- webpack-cli
+ dependencies:
+ '@storybook/client-logger': 8.1.11
+ '@storybook/docs-tools': 8.1.11([email protected])
+ '@storybook/global': 5.0.0
+ '@storybook/preview-api': 8.1.11
+ '@storybook/react-dom-shim': 8.1.11([email protected]([email protected]))([email protected])
+ '@storybook/types': 8.1.11
+ '@types/escodegen': 0.0.6
+ '@types/estree': 0.0.51
+ '@types/node': 18.19.34
+ acorn: 7.4.1
+ acorn-jsx: 5.3.2([email protected])
+ acorn-walk: 7.2.0
+ escodegen: 2.1.0
+ html-tags: 3.3.1
+ lodash: 4.17.21
+ prop-types: 15.8.1
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ react-element-to-jsx-string: 15.0.0([email protected]([email protected]))([email protected])
+ semver: 7.6.2
+ ts-dedent: 2.2.0
+ type-fest: 2.19.0
+ util-deprecate: 1.0.2
+ optionalDependencies:
+ typescript: 5.5.3
+ transitivePeerDependencies:
+ - encoding
+ - prettier
+ - supports-color
+
dependencies:
'@storybook/client-logger': 8.1.11
@@ -13749,10 +13978,10 @@ snapshots:
memoizerific: 1.11.3
qs: 6.12.1
dependencies:
'@storybook/client-logger': 8.1.11
- '@storybook/core-common': 8.1.11([email protected])
+ '@storybook/core-common': 8.1.11([email protected])
'@storybook/csf-tools': 8.1.11
chalk: 4.1.2
detect-package-manager: 2.0.1
@@ -14343,11 +14572,23 @@ snapshots:
dependencies:
tinyrainbow: 1.2.0
+ '@vitest/[email protected]':
+ dependencies:
+ '@vitest/utils': 1.6.0
+ p-limit: 5.0.0
+ pathe: 1.1.2
+
'@vitest/[email protected]':
dependencies:
'@vitest/utils': 2.0.3
pathe: 1.1.2
+ '@vitest/[email protected]':
+ dependencies:
+ magic-string: 0.30.10
+ pathe: 1.1.2
+ pretty-format: 29.7.0
+
'@vitest/[email protected]':
dependencies:
'@vitest/pretty-format': 2.0.3
@@ -14532,8 +14773,6 @@ snapshots:
'@webassemblyjs/ast': 1.12.1
'@xtuc/long': 4.2.2
- '@wendellhu/[email protected]': {}
-
'@wendellhu/[email protected]': {}
'@xtuc/[email protected]': {}
@@ -14581,6 +14820,10 @@ snapshots:
+ dependencies:
+ acorn: 8.12.0
+
@@ -17514,6 +17757,8 @@ snapshots:
+
dependencies:
argparse: 2.0.1
@@ -18258,6 +18503,10 @@ snapshots:
dependencies:
yocto-queue: 1.0.0
+ dependencies:
+ yocto-queue: 1.0.0
+
dependencies:
p-limit: 2.3.0
@@ -19752,6 +20001,10 @@ snapshots:
+ dependencies:
+ js-tokens: 9.0.0
+
dependencies:
webpack: 5.92.0(@swc/[email protected])([email protected])
@@ -19883,6 +20136,8 @@ snapshots:
+
@@ -20226,6 +20481,23 @@ snapshots:
+ dependencies:
+ cac: 6.7.14
+ debug: 4.3.5
+ pathe: 1.1.2
+ picocolors: 1.0.1
+ transitivePeerDependencies:
+ - '@types/node'
+ - less
+ - lightningcss
+ - sass
+ - stylus
+ - sugarss
+ - supports-color
+ - terser
+
dependencies:
cac: 6.7.14
@@ -20272,6 +20544,41 @@ snapshots:
sass: 1.77.5
terser: 5.31.1
+ dependencies:
+ '@vitest/expect': 1.6.0
+ '@vitest/runner': 1.6.0
+ '@vitest/snapshot': 1.6.0
+ '@vitest/spy': 1.6.0
+ '@vitest/utils': 1.6.0
+ acorn-walk: 8.3.3
+ chai: 4.4.1
+ debug: 4.3.5
+ execa: 8.0.1
+ local-pkg: 0.5.0
+ magic-string: 0.30.10
+ pathe: 1.1.2
+ picocolors: 1.0.1
+ std-env: 3.7.0
+ strip-literal: 2.1.0
+ tinybench: 2.8.0
+ tinypool: 0.8.4
+ why-is-node-running: 2.2.2
+ optionalDependencies:
+ '@types/node': 20.14.10
+ happy-dom: 13.3.8
+ jsdom: 24.1.0
+ transitivePeerDependencies:
+ - less
+ - lightningcss
+ - sass
+ - stylus
+ - sugarss
+ - supports-color
+ - terser
+
dependencies:
'@ampproject/remapping': 2.3.0