From ae0fa00c233b7dad31d4cecbd39045d885894825 Mon Sep 17 00:00:00 2001 From: zhangw Date: Fri, 15 Nov 2024 18:25:49 +0800 Subject: [PATCH 1/9] feat: update --- .../src/commands/commands/doc-mention.command.ts | 4 ++-- packages/docs-mention-ui/src/types/enums/mention-type.ts | 4 ++++ packages/docs-mention-ui/src/types/interfaces/i-mention.ts | 2 +- .../docs-mention-ui/src/views/mention-edit-popup/index.tsx | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts b/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts index 1e7c8dae9ee..c1f971a08a2 100644 --- a/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts +++ b/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts @@ -41,7 +41,7 @@ export const AddDocMentionCommand: ICommand = { return false; } - const { extra, ...mentionConfig } = mention; + const { metadata, ...mentionConfig } = mention; const dataStream = ` @${mention.label} `; const body: IDocumentBody = { dataStream, @@ -53,7 +53,7 @@ export const AddDocMentionCommand: ICommand = { wholeEntity: true, properties: { ...mentionConfig, - ...extra, + ...metadata, }, }], }; diff --git a/packages/docs-mention-ui/src/types/enums/mention-type.ts b/packages/docs-mention-ui/src/types/enums/mention-type.ts index c2d74c09bda..eb017be6c99 100644 --- a/packages/docs-mention-ui/src/types/enums/mention-type.ts +++ b/packages/docs-mention-ui/src/types/enums/mention-type.ts @@ -16,4 +16,8 @@ export enum MentionType { PERSON, + FILE, + DATE, + LOCATION, + EVENT, } diff --git a/packages/docs-mention-ui/src/types/interfaces/i-mention.ts b/packages/docs-mention-ui/src/types/interfaces/i-mention.ts index 7099a5eea1d..1748c7e405a 100644 --- a/packages/docs-mention-ui/src/types/interfaces/i-mention.ts +++ b/packages/docs-mention-ui/src/types/interfaces/i-mention.ts @@ -25,5 +25,5 @@ export interface IMention { objectType: MentionType; objectId: string; label: string; - extra?: Record; + metadata?: Record; } 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 index 220e16da117..e2ec3d1aecc 100644 --- a/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx +++ b/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx @@ -14,6 +14,7 @@ * limitations under the License. */ +import type { IMention } from '../../types/interfaces/i-mention'; import { ICommandService, IUniverInstanceService, Tools, UniverInstanceType, useDependency, useObservable, UserManagerService } from '@univerjs/core'; import { DocSelectionRenderService } from '@univerjs/docs-ui'; import { IRenderManagerService } from '@univerjs/engine-render'; @@ -22,7 +23,6 @@ import { AddDocMentionCommand } from '../../commands/commands/doc-mention.comman import { DocMentionPopupService } from '../../services/doc-mention-popup.service'; import { MentionType } from '../../types/enums/mention-type'; import { MentionList } from '../mention-list'; -import type { IMention } from '../../types/interfaces/i-mention'; export const MentionEditPopup = () => { const popupService = useDependency(DocMentionPopupService); @@ -35,7 +35,7 @@ export const MentionEditPopup = () => { objectId: user.userID, label: user.name, objectType: MentionType.PERSON, - extra: { + metadata: { icon: user.avatar, }, })); From 94edcd791578b2700802aee774a7cd00fc964595 Mon Sep 17 00:00:00 2001 From: zhangw Date: Sat, 16 Nov 2024 17:00:46 +0800 Subject: [PATCH 2/9] feat: update --- packages/core/src/types/enum/index.ts | 1 + .../types/enums => core/src/types/enum}/mention-type.ts | 0 packages/core/src/types/interfaces/i-document-data.ts | 3 +++ .../src/types/interfaces/i-mention.ts | 5 ++--- packages/core/src/types/interfaces/index.ts | 1 + .../src/commands/commands/doc-mention.command.ts | 3 +-- .../src/views/mention-edit-popup/index.tsx | 5 ++--- packages/docs-mention-ui/src/views/mention-list/index.tsx | 8 ++++---- 8 files changed, 14 insertions(+), 12 deletions(-) rename packages/{docs-mention-ui/src/types/enums => core/src/types/enum}/mention-type.ts (100%) rename packages/{docs-mention-ui => core}/src/types/interfaces/i-mention.ts (85%) diff --git a/packages/core/src/types/enum/index.ts b/packages/core/src/types/enum/index.ts index 9d8fc744816..719a26ced4d 100644 --- a/packages/core/src/types/enum/index.ts +++ b/packages/core/src/types/enum/index.ts @@ -26,6 +26,7 @@ export * from './direction'; export * from './format-type'; export * from './interpolation-point-type'; export * from './locale-type'; +export * from './mention-type'; export * from './protection-type'; export * from './prst-geom-type'; export * from './relative-date'; diff --git a/packages/docs-mention-ui/src/types/enums/mention-type.ts b/packages/core/src/types/enum/mention-type.ts similarity index 100% rename from packages/docs-mention-ui/src/types/enums/mention-type.ts rename to packages/core/src/types/enum/mention-type.ts diff --git a/packages/core/src/types/interfaces/i-document-data.ts b/packages/core/src/types/interfaces/i-document-data.ts index 736920428a4..374030c1bf9 100644 --- a/packages/core/src/types/interfaces/i-document-data.ts +++ b/packages/core/src/types/interfaces/i-document-data.ts @@ -17,6 +17,7 @@ import type { IAbsoluteTransform, ISize } from '../../shared/shape'; import type { Nullable } from '../../shared/types'; import type { BooleanNumber, CellValueType, HorizontalAlign, LocaleType, TextDirection, VerticalAlign, WrapStrategy } from '../enum'; +import type { IMention } from './i-mention'; import type { IColorStyle, IStyleBase } from './i-style-data'; // Attention: all dimensional units, unless otherwise stated, refer to pt,1 pt = 1 / 72 in @@ -360,6 +361,8 @@ export interface ICustomRange = Record; +export type IMentionCustomRange = ICustomRange; + export enum CustomRangeType { HYPERLINK, FIELD, // 17.16 Fields and Hyperlinks diff --git a/packages/docs-mention-ui/src/types/interfaces/i-mention.ts b/packages/core/src/types/interfaces/i-mention.ts similarity index 85% rename from packages/docs-mention-ui/src/types/interfaces/i-mention.ts rename to packages/core/src/types/interfaces/i-mention.ts index 1748c7e405a..d409fe68d3f 100644 --- a/packages/docs-mention-ui/src/types/interfaces/i-mention.ts +++ b/packages/core/src/types/interfaces/i-mention.ts @@ -14,16 +14,15 @@ * limitations under the License. */ -import type { MentionType } from '../enums/mention-type'; +import type { MentionType } from '../enum/mention-type'; export interface IDocMention extends IMention { id: string; } export interface IMention { - // mention payload objectType: MentionType; objectId: string; label: string; - metadata?: Record; + metadata?: Record; } diff --git a/packages/core/src/types/interfaces/index.ts b/packages/core/src/types/interfaces/index.ts index 404e1bc2446..e9cef83e083 100644 --- a/packages/core/src/types/interfaces/index.ts +++ b/packages/core/src/types/interfaces/index.ts @@ -17,6 +17,7 @@ export * from './i-document-data'; export * from './i-document-data-interceptor'; export * from './i-image-properties'; +export * from './i-mention'; export * from './i-need-check-disposable'; export * from './i-placeholder'; export * from './i-shape-properties'; diff --git a/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts b/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts index c1f971a08a2..9a1f421036d 100644 --- a/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts +++ b/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts @@ -14,8 +14,7 @@ * limitations under the License. */ -import type { ICommand, IDocumentBody } from '@univerjs/core'; -import type { IDocMention } from '../../types/interfaces/i-mention'; +import type { ICommand, IDocMention, IDocumentBody } from '@univerjs/core'; import { CommandType, CustomRangeType, ICommandService } from '@univerjs/core'; import { deleteCustomRangeFactory, DocSelectionManagerService, replaceSelectionFactory } from '@univerjs/docs'; 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 index e2ec3d1aecc..37e3c9fbe3a 100644 --- a/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx +++ b/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx @@ -14,14 +14,13 @@ * limitations under the License. */ -import type { IMention } from '../../types/interfaces/i-mention'; -import { ICommandService, IUniverInstanceService, Tools, UniverInstanceType, useDependency, useObservable, UserManagerService } from '@univerjs/core'; +import type { IMention } from '@univerjs/core'; +import { ICommandService, IUniverInstanceService, MentionType, Tools, UniverInstanceType, useDependency, useObservable, UserManagerService } from '@univerjs/core'; import { DocSelectionRenderService } from '@univerjs/docs-ui'; import { IRenderManagerService } from '@univerjs/engine-render'; import React, { useEffect } from 'react'; import { AddDocMentionCommand } from '../../commands/commands/doc-mention.command'; import { DocMentionPopupService } from '../../services/doc-mention-popup.service'; -import { MentionType } from '../../types/enums/mention-type'; import { MentionList } from '../mention-list'; export const MentionEditPopup = () => { diff --git a/packages/docs-mention-ui/src/views/mention-list/index.tsx b/packages/docs-mention-ui/src/views/mention-list/index.tsx index d916ce565eb..fa88cd45d35 100644 --- a/packages/docs-mention-ui/src/views/mention-list/index.tsx +++ b/packages/docs-mention-ui/src/views/mention-list/index.tsx @@ -14,10 +14,10 @@ * limitations under the License. */ -import React, { useEffect, useRef, useState } from 'react'; -import cs from 'clsx'; +import type { IMention } from '@univerjs/core'; import { KeyCode } from '@univerjs/ui'; -import type { IMention } from '../../types/interfaces/i-mention'; +import cs from 'clsx'; +import React, { useEffect, useRef, useState } from 'react'; import styles from './index.module.less'; export interface IMentionListProps { @@ -62,7 +62,7 @@ export const MentionList = (props: IMentionListProps) => { className={cs(styles.docMention, { [styles.docMentionActive]: activeId === mention.objectId })} onClick={() => handleSelect(mention)} > - +
{mention.label}
))} From b99e847ea5796eadf7507ccfefaaf31c874faddb Mon Sep 17 00:00:00 2001 From: zhangw Date: Mon, 18 Nov 2024 10:45:59 +0800 Subject: [PATCH 3/9] feat: update --- packages/core/src/index.ts | 2 + .../mention-io/mention-io-local.service.ts | 49 +++++++++++++++++++ packages/core/src/services/mention-io/type.ts | 45 +++++++++++++++++ packages/core/src/univer.ts | 3 ++ vitest.workspace.js | 32 ------------ 5 files changed, 99 insertions(+), 32 deletions(-) create mode 100644 packages/core/src/services/mention-io/mention-io-local.service.ts create mode 100644 packages/core/src/services/mention-io/type.ts delete mode 100644 vitest.workspace.js diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 7196b4fb30c..48a67fd6589 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -72,6 +72,8 @@ export { getCustomDecorationSlice, getCustomRangeSlice, normalizeBody } from './ export { EventState, EventSubject, fromEventSubject, type IEventObserver } from './observer/observable'; export { AuthzIoLocalService } from './services/authz-io/authz-io-local.service'; export { IAuthzIoService } from './services/authz-io/type'; +export { MentionIOLocalService } from './services/mention-io/mention-io-local.service'; +export { IMentionIOService } from './services/mention-io/type'; export { type CommandListener, CommandService, diff --git a/packages/core/src/services/mention-io/mention-io-local.service.ts b/packages/core/src/services/mention-io/mention-io-local.service.ts new file mode 100644 index 00000000000..d11fcdbf63c --- /dev/null +++ b/packages/core/src/services/mention-io/mention-io-local.service.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 type { IListMentionParam, IListMentionResponse, IMentionIOService } from './type'; +import { Inject } from '@wendellhu/redi'; +import { MentionType } from '../../types/enum'; +import { UserManagerService } from '../user-manager/user-manager.service'; + +export class MentionIOLocalService implements IMentionIOService { + constructor( + @Inject(UserManagerService) private _userManagerService: UserManagerService + ) {} + + async list(params: IListMentionParam): Promise { + return { + list: [{ + type: MentionType.PERSON, + mentions: [ + { + objectType: MentionType.PERSON, + objectId: this._userManagerService.getCurrentUser().userID, + label: this._userManagerService.getCurrentUser().name, + metadata: { + icon: this._userManagerService.getCurrentUser().avatar, + }, + }, + ], + metadata: {}, + title: 'PEOPLE', + }], + page: params.page, + size: params.size, + total: 1, + }; + } +} diff --git a/packages/core/src/services/mention-io/type.ts b/packages/core/src/services/mention-io/type.ts new file mode 100644 index 00000000000..d23dc55e20d --- /dev/null +++ b/packages/core/src/services/mention-io/type.ts @@ -0,0 +1,45 @@ +/** + * 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 '../../types/enum'; +import type { IMention } from '../../types/interfaces'; +import { createIdentifier } from '@wendellhu/redi'; + +export interface IListMentionParam { + search?: string; + type?: MentionType; + page?: number; + size?: number; + unitId?: string; +} + +export interface IListMentionResponse { + list: { + mentions: IMention[]; + type: MentionType; + metadata: Record; + title: string; + }[]; + page?: number; + size?: number; + total?: number; +} + +export interface IMentionIOService { + list (params: IListMentionParam): Promise; +} + +export const IMentionIOService = createIdentifier('univer.service.mention-io'); diff --git a/packages/core/src/univer.ts b/packages/core/src/univer.ts index 07b58fb71bf..aca4a000440 100644 --- a/packages/core/src/univer.ts +++ b/packages/core/src/univer.ts @@ -40,6 +40,8 @@ import { LifecycleStages } from './services/lifecycle/lifecycle'; import { LifecycleService } from './services/lifecycle/lifecycle.service'; import { LocaleService } from './services/locale/locale.service'; import { DesktopLogService, ILogService } from './services/log/log.service'; +import { MentionIOLocalService } from './services/mention-io/mention-io-local.service'; +import { IMentionIOService } from './services/mention-io/type'; import { PermissionService } from './services/permission/permission.service'; import { IPermissionService } from './services/permission/type'; import { PluginService } from './services/plugin/plugin.service'; @@ -194,6 +196,7 @@ function createUniverInjector(parentInjector?: Injector, override?: DependencyOv [IResourceManagerService, { useClass: ResourceManagerService, lazy: true }], [IResourceLoaderService, { useClass: ResourceLoaderService, lazy: true }], [IAuthzIoService, { useClass: AuthzIoLocalService, lazy: true }], + [IMentionIOService, { useClass: MentionIOLocalService, lazy: true }], ], override); const injector = parentInjector ? parentInjector.createChild(dependencies) : new Injector(dependencies); diff --git a/vitest.workspace.js b/vitest.workspace.js deleted file mode 100644 index 041060e1f1f..00000000000 --- a/vitest.workspace.js +++ /dev/null @@ -1,32 +0,0 @@ -import { defineWorkspace } from 'vitest/config'; - -export default defineWorkspace([ - './packages/network/vite.config.ts', - './packages/slides-ui/vite.config.ts', - './packages/engine-formula/vite.config.ts', - './packages/rpc/vite.config.ts', - './packages/design/vite.config.ts', - './packages/core/vite.config.ts', - './packages/sheets-zen-editor/vite.config.ts', - './packages/sheets-filter/vite.config.ts', - './packages/sheets-ui/vite.config.ts', - './packages/engine-numfmt/vite.config.ts', - './packages/sheets-formula/vite.config.ts', - './packages/sheets-filter-ui/vite.config.ts', - './packages/docs-ui/vite.config.ts', - './packages/sheets-find-replace/vite.config.ts', - './packages/image/vite.config.ts', - './packages/sheets-data-validation/vite.config.ts', - './packages/docs/vite.config.ts', - './packages/facade/vite.config.ts', - './packages/ui/vite.config.ts', - './packages/uniscript/vite.config.ts', - './packages/engine-render/vite.config.ts', - './packages/sheets/vite.config.ts', - './packages/sheets-conditional-formatting/vite.config.ts', - './packages/find-replace/vite.config.ts', - './packages/data-validation/vite.config.ts', - './packages/slides/vite.config.ts', - './packages/sheets-conditional-formatting-ui/vite.config.ts', - './packages/sheets-numfmt/vite.config.ts', -]); From c339ffc3683f30e9756b88a1c990d6cf2adff8ba Mon Sep 17 00:00:00 2001 From: zhangw Date: Mon, 18 Nov 2024 14:19:25 +0800 Subject: [PATCH 4/9] feat: update --- examples/src/sheets/main.ts | 29 +---------- examples/src/uni/main.ts | 38 +------------- packages/core/src/services/mention-io/type.ts | 2 +- packages/sheets-thread-comment-ui/README.md | 4 +- .../sheets-thread-comment-ui/src/index.ts | 2 - packages/thread-comment-ui/src/index.ts | 1 - packages/thread-comment-ui/src/plugin.ts | 2 - .../thread-comment-mention-data.service.ts | 49 ------------------- .../src/views/thread-comment-editor/index.tsx | 29 +++++++---- 9 files changed, 25 insertions(+), 131 deletions(-) delete mode 100644 packages/thread-comment-ui/src/services/thread-comment-mention-data.service.ts diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts index a7fba766bbd..9529df59602 100644 --- a/examples/src/sheets/main.ts +++ b/examples/src/sheets/main.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import type { Nullable } from '@univerjs/core'; import type { IUniverRPCMainThreadConfig } from '@univerjs/rpc'; import { FUniver, LocaleType, LogLevel, Univer, UniverInstanceType, UserManagerService } from '@univerjs/core'; import { UniverDebuggerPlugin } from '@univerjs/debugger'; @@ -39,7 +38,7 @@ import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment import { UniverSheetsThreadCommentUIPlugin } from '@univerjs/sheets-thread-comment-ui'; import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui'; import { UniverSheetsZenEditorPlugin } from '@univerjs/sheets-zen-editor'; -import { IThreadCommentMentionDataService, type IThreadCommentMentionDataSource, UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui'; +import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui'; import { UniverUIPlugin } from '@univerjs/ui'; import { enUS, faIR, ruRU, viVN, zhCN, zhTW } from '../locales'; @@ -69,28 +68,6 @@ export const mockUser = { canBindAnonymous: false, }; -class CustomMentionDataService implements IThreadCommentMentionDataService { - dataSource: Nullable; - trigger: string = '@'; - - async getMentions() { - return [ - { - id: mockUser.userID, - label: mockUser.name, - type: 'user', - icon: mockUser.avatar, - }, - { - id: '2', - label: 'User2', - type: 'user', - icon: mockUser.avatar, - }, - ]; - } -} - // univer const univer = new Univer({ theme: defaultTheme, @@ -128,9 +105,7 @@ univer.registerPlugin(UniverSheetsConditionalFormattingPlugin); univer.registerPlugin(UniverSheetsFilterPlugin); univer.registerPlugin(UniverSheetsSortPlugin); univer.registerPlugin(UniverSheetsHyperLinkPlugin); -univer.registerPlugin(UniverThreadCommentUIPlugin, { - overrides: [[IThreadCommentMentionDataService, { useClass: CustomMentionDataService }]], -}); +univer.registerPlugin(UniverThreadCommentUIPlugin); univer.registerPlugin(UniverSheetsThreadCommentPlugin); univer.registerPlugin(UniverSheetsThreadCommentUIPlugin); diff --git a/examples/src/uni/main.ts b/examples/src/uni/main.ts index da0ba546cea..d7ce102e2a1 100644 --- a/examples/src/uni/main.ts +++ b/examples/src/uni/main.ts @@ -14,9 +14,7 @@ * limitations under the License. */ -import type { Nullable } from '@univerjs/core'; import type { IUniverRPCMainThreadConfig } from '@univerjs/rpc'; -import type { IThreadCommentMentionDataSource } from '@univerjs/thread-comment-ui'; import { FUniver, Injector, LocaleType, LogLevel, Univer, UniverInstanceType } from '@univerjs/core'; import { UniverDebuggerPlugin } from '@univerjs/debugger'; import { defaultTheme } from '@univerjs/design'; @@ -41,7 +39,7 @@ import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment import { SheetUIController, UniverSheetsUIPlugin } from '@univerjs/sheets-ui'; import { UniverSlidesPlugin } from '@univerjs/slides'; import { SlidesUIController, UniverSlidesUIPlugin } from '@univerjs/slides-ui'; -import { IThreadCommentMentionDataService, UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui'; +import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui'; import { UniDocsUIController } from '@univerjs/uni-docs-ui'; import { UniverDocUniFormulaPlugin } from '@univerjs/uni-formula'; import { UniSheetsUIController } from '@univerjs/uni-sheets-ui'; @@ -67,36 +65,6 @@ registerSheetPlugins(univer); registerSlidePlugins(univer); registerUniPlugins(univer); -const mockUser = { - userID: 'Owner_qxVnhPbQ', - name: 'Owner', - avatar: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAInSURBVHgBtZU9TxtBEIbfWRzFSIdkikhBSqRQkJqkCKTCFkqVInSUSaT0wC8w/gXxD4gU2nRJkXQWhAZowDUUWKIwEgWWbEEB3mVmx3dn4DA2nB/ppNuPeWd29mMIPXDr+RxwtgRHeW6+guNPRxogqnL7Dwz9psJ27S4NShaeZTH3kwXy6I81dlRKcmRui88swdq9AcSFL7Buz1Vmlns64MiLsCjzwnIYHLH57tbfFbs7KRaXyEU8FVZofqccOfA5l7Q8LPIkGrwnb2RPNEXWFVMUF3L+kDCk0btDDAMzOm5YfAHDwp4tG74wnzAsiOYMnJ3GoDybA7IT98/jm5+JNnfiIzAS6LlqHQBN/i6b2t/cV1Hh6BfwYlHnHP4AXi5q/8kmMMpOs8+BixZw/Fd6xUEHEbnkgclvQP2fGp7uShRKnQ3G32rkjV1th8JhIGG7tR/JyjGteSOZELwGMmNqIIigRCLRh2OZIE6BjItdd7pCW6Uhm1zzkUtungSxwEUzNpQ+GQumtH1ej1MqgmNT6vwmhCq5yuwq56EYTbgeQUz3yvrpV1b4ok3nYJ+eYhgYmjRUqErx2EDq0Fr8FhG++iqVGqxlUJI/70Ar0UgJaWHj6hYVHJrfKssAHot1JfqwE9WVWzXZVd5z2Ws/4PnmtEjkXeKJDvxUecLbWOXH/DP6QQ4J72NS0adedp1aseBfXP8odlZFfPvBF7SN/8hky1TYuPOAXAEipMx15u5ToAAAAABJRU5ErkJggg==', - anonymous: false, - canBindAnonymous: false, -}; - -class CustomMentionDataService implements IThreadCommentMentionDataService { - dataSource: Nullable; - trigger: string = '@'; - - async getMentions() { - return [ - { - id: mockUser.userID, - label: mockUser.name, - type: 'user', - icon: mockUser.avatar, - }, - { - id: '2', - label: 'User2', - type: 'user', - icon: mockUser.avatar, - }, - ]; - } -} - // create univer instances univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO); univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_EN); @@ -149,9 +117,7 @@ function registerBasicPlugins(univer: Univer) { univer.registerPlugin(UniverRPCMainThreadPlugin, { workerURL: new Worker(new URL('./worker.js', import.meta.url), { type: 'module' }), } as IUniverRPCMainThreadConfig); - univer.registerPlugin(UniverThreadCommentUIPlugin, { - overrides: [[IThreadCommentMentionDataService, { useClass: CustomMentionDataService }]], - }); + univer.registerPlugin(UniverThreadCommentUIPlugin); univer.registerPlugin(UniverDocsDrawingUIPlugin); } diff --git a/packages/core/src/services/mention-io/type.ts b/packages/core/src/services/mention-io/type.ts index d23dc55e20d..4eda2256665 100644 --- a/packages/core/src/services/mention-io/type.ts +++ b/packages/core/src/services/mention-io/type.ts @@ -42,4 +42,4 @@ export interface IMentionIOService { list (params: IListMentionParam): Promise; } -export const IMentionIOService = createIdentifier('univer.service.mention-io'); +export const IMentionIOService = createIdentifier('univer.service.mention-io'); diff --git a/packages/sheets-thread-comment-ui/README.md b/packages/sheets-thread-comment-ui/README.md index 893f74bd2a2..4f53928aa4c 100644 --- a/packages/sheets-thread-comment-ui/README.md +++ b/packages/sheets-thread-comment-ui/README.md @@ -57,9 +57,7 @@ class CustomMentionDataService implements IThreadCommentMentionDataService { } } -univer.registerPlugin(UniverSheetsThreadCommentPlugin, { - overrides: [[IThreadCommentMentionDataService, { useClass: CustomMentionDataService }]], -}); +univer.registerPlugin(UniverSheetsThreadCommentPlugin); ``` ### API diff --git a/packages/sheets-thread-comment-ui/src/index.ts b/packages/sheets-thread-comment-ui/src/index.ts index da4ed6e5223..5e56084e0b3 100644 --- a/packages/sheets-thread-comment-ui/src/index.ts +++ b/packages/sheets-thread-comment-ui/src/index.ts @@ -20,10 +20,8 @@ export { SheetsThreadCommentPopupService } from './services/sheets-thread-commen export { SHEETS_THREAD_COMMENT } from './types/const'; export { IThreadCommentDataSourceService } from '@univerjs/thread-comment'; export { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui'; -export { IThreadCommentMentionDataService } from '@univerjs/thread-comment-ui'; // #region - all commands - export { AddCommentCommand, DeleteCommentCommand, diff --git a/packages/thread-comment-ui/src/index.ts b/packages/thread-comment-ui/src/index.ts index 6d8971cbf2c..26d95fcb608 100644 --- a/packages/thread-comment-ui/src/index.ts +++ b/packages/thread-comment-ui/src/index.ts @@ -21,7 +21,6 @@ export type { IThreadCommentPanelProps } from './views/thread-comment-panel'; export { ThreadCommentTree } from './views/thread-comment-tree'; export type { IThreadCommentTreeProps } from './views/thread-comment-tree'; export { THREAD_COMMENT_PANEL } from './types/const'; -export { IThreadCommentMentionDataService, type IThreadCommentMentionDataSource } from './services/thread-comment-mention-data.service'; // #region - all commands diff --git a/packages/thread-comment-ui/src/plugin.ts b/packages/thread-comment-ui/src/plugin.ts index 73aff900f39..ec82fad83d2 100644 --- a/packages/thread-comment-ui/src/plugin.ts +++ b/packages/thread-comment-ui/src/plugin.ts @@ -20,7 +20,6 @@ import { DependentOn, ICommandService, IConfigService, Inject, Injector, mergeOv import { UniverThreadCommentPlugin } from '@univerjs/thread-comment'; import { SetActiveCommentOperation, ToggleSheetCommentPanelOperation } from './commands/operations/comment.operations'; import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema'; -import { IThreadCommentMentionDataService, ThreadCommentMentionDataService } from './services/thread-comment-mention-data.service'; import { ThreadCommentPanelService } from './services/thread-comment-panel.service'; import { PLUGIN_NAME } from './types/const'; @@ -48,7 +47,6 @@ export class UniverThreadCommentUIPlugin extends Plugin { override onStarting(): void { (mergeOverrideWithDependencies([ [ThreadCommentPanelService], - [IThreadCommentMentionDataService, { useClass: ThreadCommentMentionDataService }], ], this._config?.overrides) as Dependency[]).forEach((dep) => { this._injector.add(dep); }); diff --git a/packages/thread-comment-ui/src/services/thread-comment-mention-data.service.ts b/packages/thread-comment-ui/src/services/thread-comment-mention-data.service.ts deleted file mode 100644 index 668312059bb..00000000000 --- a/packages/thread-comment-ui/src/services/thread-comment-mention-data.service.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2023-present DreamNum Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Nullable } from '@univerjs/core'; -import type { MentionProps } from '@univerjs/design'; -import type { IThreadCommentMention } from '@univerjs/thread-comment'; -import { createIdentifier } from '@univerjs/core'; - -export interface IThreadCommentMentionDataSource { - getMentions(search: string, unitId: string, subUnitId: string): Promise; -} - -export interface IThreadCommentMentionDataService { - dataSource: Nullable; - - getMentions: (search: string, unitId: string, subUnitId: string) => Promise; - trigger: string; - renderSuggestion?: MentionProps['renderSuggestion']; -} - -export class ThreadCommentMentionDataService implements IThreadCommentMentionDataService { - dataSource: Nullable; - - renderSuggestion: MentionProps['renderSuggestion']; - - async getMentions(search: string, unitId: string, subUnitId: string) { - if (this.dataSource) { - return this.dataSource.getMentions(search, unitId, subUnitId); - } - return []; - } - - trigger = '@'; -} - -export const IThreadCommentMentionDataService = createIdentifier('thread-comment.mention-data.service'); diff --git a/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx b/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx index 24b31ae2f2f..85ac407ffb1 100644 --- a/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx +++ b/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx @@ -17,16 +17,15 @@ import type { IDocumentBody } from '@univerjs/core'; import type { MentionProps } from '@univerjs/design'; import type { IThreadComment } from '@univerjs/thread-comment'; -import { ICommandService, LocaleService, UniverInstanceType, useDependency } from '@univerjs/core'; +import { ICommandService, IMentionIOService, LocaleService, UniverInstanceType, useDependency } from '@univerjs/core'; import { Button, Mention, Mentions } from '@univerjs/design'; import { DocSelectionManagerService } from '@univerjs/docs'; import { DocSelectionRenderService } from '@univerjs/docs-ui'; import { IRenderManagerService } from '@univerjs/engine-render'; import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react'; import { SetActiveCommentOperation } from '../../commands/operations/comment.operations'; -import { IThreadCommentMentionDataService } from '../../services/thread-comment-mention-data.service'; import styles from './index.module.less'; -import { parseMentions, transformDocument2TextNodes, transformMention, transformTextNode2Text, transformTextNodes2Document } from './util'; +import { parseMentions, transformDocument2TextNodes, transformTextNode2Text, transformTextNodes2Document } from './util'; export interface IThreadCommentEditorProps { id?: string; @@ -55,8 +54,8 @@ const defaultRenderSuggestion: MentionProps['renderSuggestion'] = (mention, sear }; export const ThreadCommentEditor = forwardRef((props, ref) => { - const { comment, onSave, id, onCancel, autoFocus, unitId, subUnitId } = props; - const mentionDataService = useDependency(IThreadCommentMentionDataService); + const { comment, onSave, id, onCancel, autoFocus, unitId } = props; + const mentionIOService = useDependency(IMentionIOService); const commandService = useDependency(ICommandService); const localeService = useDependency(LocaleService); const [localComment, setLocalComment] = useState({ ...comment }); @@ -114,13 +113,23 @@ export const ThreadCommentEditor = forwardRef mentionDataService.getMentions!(query, unitId, subUnitId) - .then((res) => res.map(transformMention)) + key="@" + trigger="@" + data={(query, callback) => mentionIOService.list({ search: query, unitId }) + .then((res) => res.list.map( + (typeMentions) => ( + typeMentions.mentions.map( + (mention) => ({ + id: mention.objectId, + display: mention.label, + raw: mention, + }) + ) + ) + ).flat()) .then(callback) as any} displayTransform={(id, label) => `@${label} `} - renderSuggestion={mentionDataService.renderSuggestion ?? defaultRenderSuggestion} + renderSuggestion={defaultRenderSuggestion} /> From ca112bc6c397ffb4bb9cd4c3dcc11a2f8d643f38 Mon Sep 17 00:00:00 2001 From: zhangw Date: Mon, 18 Nov 2024 15:18:57 +0800 Subject: [PATCH 5/9] feat: update --- packages/core/src/index.ts | 2 +- packages/core/src/services/mention-io/type.ts | 14 +++--- .../src/services/doc-mention-popup.service.ts | 4 +- .../src/views/mention-edit-popup/index.tsx | 36 ++++++++++----- .../src/views/mention-list/index.module.less | 7 +-- .../src/views/mention-list/index.tsx | 46 ++++++++----------- 6 files changed, 57 insertions(+), 52 deletions(-) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 48a67fd6589..8a413e2e6ba 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -73,7 +73,7 @@ export { EventState, EventSubject, fromEventSubject, type IEventObserver } from export { AuthzIoLocalService } from './services/authz-io/authz-io-local.service'; export { IAuthzIoService } from './services/authz-io/type'; export { MentionIOLocalService } from './services/mention-io/mention-io-local.service'; -export { IMentionIOService } from './services/mention-io/type'; +export { type IListMentionParam, type IListMentionResponse, IMentionIOService, type ITypeMentionList } from './services/mention-io/type'; export { type CommandListener, CommandService, diff --git a/packages/core/src/services/mention-io/type.ts b/packages/core/src/services/mention-io/type.ts index 4eda2256665..cda49a039f2 100644 --- a/packages/core/src/services/mention-io/type.ts +++ b/packages/core/src/services/mention-io/type.ts @@ -26,13 +26,15 @@ export interface IListMentionParam { unitId?: string; } +export interface ITypeMentionList { + mentions: IMention[]; + type: MentionType; + metadata: Record; + title: string; +} + export interface IListMentionResponse { - list: { - mentions: IMention[]; - type: MentionType; - metadata: Record; - title: string; - }[]; + list: ITypeMentionList[]; page?: number; size?: number; total?: number; diff --git a/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts b/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts index 9e3c5024d85..34d6c76c306 100644 --- a/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts +++ b/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts @@ -28,7 +28,7 @@ export class DocMentionPopupService extends Disposable { return this._infoPopup$.value; } - private readonly _editPopup$ = new BehaviorSubject>(undefined); + private readonly _editPopup$ = new BehaviorSubject>(undefined); readonly editPopup$ = this._editPopup$.asObservable(); get editPopup() { return this._editPopup$.value; @@ -66,7 +66,7 @@ export class DocMentionPopupService extends Disposable { }, unitId ); - this._editPopup$.next({ popup: dispose, anchor: index }); + this._editPopup$.next({ popup: dispose, anchor: index, unitId }); } closeEditPopup() { 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 index 37e3c9fbe3a..63e61de2b85 100644 --- a/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx +++ b/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx @@ -14,11 +14,13 @@ * limitations under the License. */ -import type { IMention } from '@univerjs/core'; -import { ICommandService, IUniverInstanceService, MentionType, Tools, UniverInstanceType, useDependency, useObservable, UserManagerService } from '@univerjs/core'; +import type { DocumentDataModel, ITypeMentionList } from '@univerjs/core'; +import { ICommandService, IMentionIOService, IUniverInstanceService, Tools, UniverInstanceType, useDependency, useObservable } from '@univerjs/core'; +import { DocSelectionManagerService } from '@univerjs/docs'; import { DocSelectionRenderService } from '@univerjs/docs-ui'; import { IRenderManagerService } from '@univerjs/engine-render'; -import React, { useEffect } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; +import { filter } from 'rxjs'; import { AddDocMentionCommand } from '../../commands/commands/doc-mention.command'; import { DocMentionPopupService } from '../../services/doc-mention-popup.service'; import { MentionList } from '../mention-list'; @@ -28,16 +30,26 @@ export const MentionEditPopup = () => { const commandService = useDependency(ICommandService); const univerInstanceService = useDependency(IUniverInstanceService); const editPopup = useObservable(popupService.editPopup$); - const userService = useDependency(UserManagerService); + const mentionIOService = useDependency(IMentionIOService); + const documentDataModel = editPopup ? univerInstanceService.getUnit(editPopup.unitId) : null; + const textSelectionService = useDependency(DocSelectionManagerService); + const [mentions, setMentions] = useState([]); + const textSelection$ = useMemo(() => + textSelectionService.textSelection$.pipe( + filter((selection) => selection.unitId === editPopup?.unitId) + ), [textSelectionService.textSelection$, editPopup]); - const mentions: IMention[] = userService.list().map((user) => ({ - objectId: user.userID, - label: user.name, - objectType: MentionType.PERSON, - metadata: { - icon: user.avatar, - }, - })); + const textSelection = useObservable(textSelection$); + const search = editPopup ? documentDataModel?.getBody()?.dataStream.slice(editPopup.anchor, textSelection?.textRanges[0].startOffset) : ''; + + useEffect(() => { + (async () => { + if (editPopup) { + const res = await mentionIOService.list({ unitId: editPopup.unitId, search }); + setMentions(res.list); + } + })(); + }, [mentionIOService, editPopup, search]); const renderManagerService = useDependency(IRenderManagerService); 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 index fb57468153b..63690c41360 100644 --- a/packages/docs-mention-ui/src/views/mention-list/index.module.less +++ b/packages/docs-mention-ui/src/views/mention-list/index.module.less @@ -16,6 +16,7 @@ align-items: center; flex-direction: row; cursor: pointer; + border-radius: var(--border-radius-base); &-icon { width: 24px; @@ -24,10 +25,10 @@ margin-right: 6px; flex: 0 0 auto; border-radius: 6px; + } - &-active { - background: rgb(var(--grey-50)); - } + &-active { + background: rgb(var(--grey-50)); } &-icon:hover { diff --git a/packages/docs-mention-ui/src/views/mention-list/index.tsx b/packages/docs-mention-ui/src/views/mention-list/index.tsx index fa88cd45d35..f2592ac6196 100644 --- a/packages/docs-mention-ui/src/views/mention-list/index.tsx +++ b/packages/docs-mention-ui/src/views/mention-list/index.tsx @@ -14,14 +14,13 @@ * limitations under the License. */ -import type { IMention } from '@univerjs/core'; -import { KeyCode } from '@univerjs/ui'; +import type { IMention, ITypeMentionList } from '@univerjs/core'; import cs from 'clsx'; import React, { useEffect, useRef, useState } from 'react'; import styles from './index.module.less'; export interface IMentionListProps { - mentions: IMention[]; + mentions: ITypeMentionList[]; active?: string; onSelect?: (item: IMention) => void; onClick?: () => void; @@ -30,7 +29,7 @@ export interface IMentionListProps { export const MentionList = (props: IMentionListProps) => { const { mentions, active, onSelect, onClick } = props; const ref = useRef(null); - const [activeId, setActiveId] = useState(active ?? mentions[0]?.objectId); + const [activeId, setActiveId] = useState(active ?? mentions[0]?.mentions[0]?.objectId); const handleSelect = (item: IMention) => { onSelect?.(item); }; @@ -39,31 +38,22 @@ export const MentionList = (props: IMentionListProps) => { ref.current?.focus(); }, []); - const handleKeyDown = (evt: React.KeyboardEvent) => { - 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 ( -
- {mentions.map((mention) => ( -
handleSelect(mention)} - > - -
{mention.label}
+
+ {mentions.map((typeMentions) => ( +
+
{typeMentions.title}
+ {typeMentions.mentions.map((mention) => ( +
handleSelect(mention)} + onMouseEnter={() => setActiveId(mention.objectId)} + > + +
{mention.label}
+
+ ))}
))}
From de66df31d69926b24281bb7e58766127784d1fd2 Mon Sep 17 00:00:00 2001 From: zhangw Date: Mon, 18 Nov 2024 15:38:32 +0800 Subject: [PATCH 6/9] feat: update --- examples/src/sheets/main.ts | 2 ++ .../src/views/mention-edit-popup/index.tsx | 13 ------------- .../src/views/mention-list/index.tsx | 8 ++++---- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts index 9529df59602..edba642b788 100644 --- a/examples/src/sheets/main.ts +++ b/examples/src/sheets/main.ts @@ -19,6 +19,7 @@ import { FUniver, LocaleType, LogLevel, Univer, UniverInstanceType, UserManagerS import { UniverDebuggerPlugin } from '@univerjs/debugger'; import { defaultTheme } from '@univerjs/design'; import { UniverDocsPlugin } from '@univerjs/docs'; +import { UniverDocsMentionUIPlugin } from '@univerjs/docs-mention-ui'; import { UniverDocsUIPlugin } from '@univerjs/docs-ui'; import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'; import { UniverRenderEnginePlugin } from '@univerjs/engine-render'; @@ -91,6 +92,7 @@ univer.registerPlugin(UniverDocsPlugin); univer.registerPlugin(UniverRenderEnginePlugin); univer.registerPlugin(UniverUIPlugin, { container: 'app' }); univer.registerPlugin(UniverDocsUIPlugin); +univer.registerPlugin(UniverDocsMentionUIPlugin); univer.registerPlugin(UniverSheetsPlugin, { notExecuteFormula: true }); univer.registerPlugin(UniverSheetsUIPlugin); 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 index 63e61de2b85..91be5187e28 100644 --- a/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx +++ b/packages/docs-mention-ui/src/views/mention-edit-popup/index.tsx @@ -17,8 +17,6 @@ import type { DocumentDataModel, ITypeMentionList } from '@univerjs/core'; import { ICommandService, IMentionIOService, IUniverInstanceService, Tools, UniverInstanceType, useDependency, useObservable } from '@univerjs/core'; import { DocSelectionManagerService } from '@univerjs/docs'; -import { DocSelectionRenderService } from '@univerjs/docs-ui'; -import { IRenderManagerService } from '@univerjs/engine-render'; import React, { useEffect, useMemo, useState } from 'react'; import { filter } from 'rxjs'; import { AddDocMentionCommand } from '../../commands/commands/doc-mention.command'; @@ -51,17 +49,6 @@ export const MentionEditPopup = () => { })(); }, [mentionIOService, editPopup, search]); - const renderManagerService = useDependency(IRenderManagerService); - - const docSelectionRenderService = renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)?.with(DocSelectionRenderService); - - useEffect(() => { - docSelectionRenderService?.blur(); - return () => { - docSelectionRenderService?.focus(); - }; - }, [docSelectionRenderService]); - if (!editPopup) { return null; } diff --git a/packages/docs-mention-ui/src/views/mention-list/index.tsx b/packages/docs-mention-ui/src/views/mention-list/index.tsx index f2592ac6196..2912f771023 100644 --- a/packages/docs-mention-ui/src/views/mention-list/index.tsx +++ b/packages/docs-mention-ui/src/views/mention-list/index.tsx @@ -16,7 +16,7 @@ import type { IMention, ITypeMentionList } from '@univerjs/core'; import cs from 'clsx'; -import React, { useEffect, useRef, useState } from 'react'; +import React, { useRef, useState } from 'react'; import styles from './index.module.less'; export interface IMentionListProps { @@ -34,9 +34,9 @@ export const MentionList = (props: IMentionListProps) => { onSelect?.(item); }; - useEffect(() => { - ref.current?.focus(); - }, []); + // useEffect(() => { + // ref.current?.focus(); + // }, []); return (
From baff65cb1b15bef2aa0cb2360b48964a13a69524 Mon Sep 17 00:00:00 2001 From: zhangw Date: Mon, 18 Nov 2024 15:44:30 +0800 Subject: [PATCH 7/9] feat: update --- .../src/controllers/doc-mention-trigger.controller.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 index 0b681f593aa..a47c412b3af 100644 --- a/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts +++ b/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts @@ -41,10 +41,12 @@ export class DocMentionTriggerController extends Disposable { const params = commandInfo.params as IInsertCommandParams; const activeRange = this._textSelectionManagerService.getActiveTextRange(); if (params.body.dataStream === '@' && activeRange && !Tools.isDefine(this._docMentionService.editing)) { - this._commandService.executeCommand(ShowMentionEditPopupOperation.id, { - startIndex: activeRange.startOffset - 1, - unitId: params.unitId, - }); + setTimeout(() => { + this._commandService.executeCommand(ShowMentionEditPopupOperation.id, { + startIndex: activeRange.startOffset - 1, + unitId: params.unitId, + }); + }, 100); } } From 97640a5e7bdf607a8bde130fc83b97eb1c8ba553 Mon Sep 17 00:00:00 2001 From: zhangw Date: Mon, 18 Nov 2024 21:41:51 +0800 Subject: [PATCH 8/9] feat: update --- packages/docs-ui/src/basics/custom-decoration-factory.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/docs-ui/src/basics/custom-decoration-factory.ts b/packages/docs-ui/src/basics/custom-decoration-factory.ts index 9458407b3eb..428c99d9fbf 100644 --- a/packages/docs-ui/src/basics/custom-decoration-factory.ts +++ b/packages/docs-ui/src/basics/custom-decoration-factory.ts @@ -37,7 +37,7 @@ export function addCustomDecorationFactory(param: IAddCustomDecorationParam) { unitId, actions: [], textRanges: undefined, - noHistory: true, + // noHistory: true, segmentId, }, }; @@ -109,7 +109,7 @@ export function deleteCustomDecorationFactory(accessor: IAccessor, params: IDele unitId, actions: [], textRanges: undefined, - noHistory: true, + // noHistory: true, segmentId, }, }; From 4dad32b7242a47e9d1f7e91ec530b85338344e23 Mon Sep 17 00:00:00 2001 From: zhangw Date: Mon, 18 Nov 2024 22:53:34 +0800 Subject: [PATCH 9/9] feat: update --- .../src/commands/commands/doc-mention.command.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts b/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts index 9a1f421036d..bb5db840f59 100644 --- a/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts +++ b/packages/docs-mention-ui/src/commands/commands/doc-mention.command.ts @@ -41,7 +41,7 @@ export const AddDocMentionCommand: ICommand = { } const { metadata, ...mentionConfig } = mention; - const dataStream = ` @${mention.label} `; + const dataStream = `@${mention.label}`; const body: IDocumentBody = { dataStream, customRanges: [{