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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(sheets-note-ui): enhance note popup functionality with default trigger (#6554)
白熱160e5e4ec95b
diff --git a/SECURITY.md b/SECURITY.mdindex 69897c25ff..37cad9a3fe 100644--- a/SECURITY.md+++ b/SECURITY.md@@ -19,7 +19,7 @@ As Univer is still not reaching version 1.0 and we are moving fast with latest fWe encourage responsible disclosure of security vulnerabilities. If you discover a potential issue, please follow these steps:1. How to Report:- - Email us at: [email protected]+ - Email us at: [email protected]- Alternatively, submit a private Security Advisory via GitHub (if applicable).2. What to Include:- Description: A detailed explanation of the vulnerability and its potential impact.diff --git a/common/debugger/src/views/use-locale.ts b/common/debugger/src/views/use-locale.tsindex 944f11e9a0..d121f82c78 100644--- a/common/debugger/src/views/use-locale.ts+++ b/common/debugger/src/views/use-locale.ts@@ -35,6 +35,10 @@ const locales = [label: 'Tiếng Việt',value: LocaleType.VI_VN,},+ {+ label: 'فارسی',+ value: LocaleType.FA_IR,+ },{label: 'Español',value: LocaleType.ES_ES,@@ -91,7 +95,7 @@ export function useLocale() {locales = await import('@univerjs/mockdata/locales/ja-JP');break;case LocaleType.FA_IR:- locales = await import('@univerjs/mockdata/locales/fr-FR');+ locales = await import('@univerjs/mockdata/locales/fa-IR');break;case LocaleType.KO_KR:locales = await import('@univerjs/mockdata/locales/ko-KR');diff --git a/packages/sheets-note-ui/src/commands/operations/add-note-popup.operation.ts b/packages/sheets-note-ui/src/commands/operations/add-note-popup.operation.tsindex 94720b5ea5..9d584329a5 100644--- a/packages/sheets-note-ui/src/commands/operations/add-note-popup.operation.ts+++ b/packages/sheets-note-ui/src/commands/operations/add-note-popup.operation.ts@@ -50,7 +50,7 @@ export const AddNotePopupOperation: ICommand = {row: primary.actualRow,col: primary.actualColumn,temp: false,- trigger: params?.trigger,+ trigger: params?.trigger ?? 'add-note',});return true;diff --git a/packages/sheets-note-ui/src/controllers/sheets-note-popup.controller.ts b/packages/sheets-note-ui/src/controllers/sheets-note-popup.controller.tsindex 1bb8c5c644..1062252725 100644--- a/packages/sheets-note-ui/src/controllers/sheets-note-popup.controller.ts+++ b/packages/sheets-note-ui/src/controllers/sheets-note-popup.controller.ts@@ -110,15 +110,34 @@ export class SheetsNotePopupController extends Disposable {if (!cell?.location) return;const { unitId, subUnitId, row, col } = cell.location;+ const render = this._renderManagerService.getRenderById(unitId);+ const skeleton = render?.with(SheetSkeletonManagerService).getSkeletonParam(subUnitId)?.skeleton;- const note = this._sheetsNoteModel.getNote(unitId, subUnitId, row, col);+ let targetRow = row;+ let targetCol = col;+ let note = this._sheetsNoteModel.getNote(unitId, subUnitId, targetRow, targetCol);+ if (!note && skeleton) {+ const actualCell = skeleton.getCellWithCoordByIndex(row, col);+ const { startRow, endRow, startColumn, endColumn } = actualCell.mergeInfo;+ if (startRow !== endRow || startColumn !== endColumn) {+ const sheetNotes = this._sheetsNoteModel.getSheetNotes(unitId, subUnitId);+ sheetNotes?.forValue((r, c, candidate) => {+ if (r >= startRow && r <= endRow && c >= startColumn && c <= endColumn) {+ note = candidate;+ targetRow = r;+ targetCol = c;+ return false;+ }+ });+ }+ }if (note?.show) return;if (note) {this._sheetsNotePopupService.showPopup({unitId,subUnitId,- row,- col,+ row: targetRow,+ col: targetCol,temp: true,});} else {diff --git a/packages/sheets-note-ui/src/views/note.tsx b/packages/sheets-note-ui/src/views/note.tsxindex 321cf1da44..dd61a0015d 100644--- a/packages/sheets-note-ui/src/views/note.tsx+++ b/packages/sheets-note-ui/src/views/note.tsx@@ -26,7 +26,12 @@ import { useConfigValue, useDebounceFn, useDependency } from '@univerjs/ui';import { useCallback, useEffect, useRef, useState } from 'react';import { SHEETS_NOTE_UI_PLUGIN_CONFIG_KEY } from '../controllers/config.schema';-export const SheetsNote = (props: { popup: IPopup<{ location: ISheetLocationBase }> }) => {+type INotePopupLocation = ISheetLocationBase & {+ temp?: boolean;+ trigger?: string;+};++export const SheetsNote = (props: { popup: IPopup<{ location: INotePopupLocation }> }) => {const { popup } = props;const noteModel = useDependency(SheetsNoteModel);@@ -59,6 +64,17 @@ export const SheetsNote = (props: { popup: IPopup<{ location: ISheetLocationBase}}, [activePopup, textareaRef]);+ useEffect(() => {+ if (!activePopup || activePopup.temp || !activePopup.trigger) return;+ if (!textareaRef.current) return;++ const focusId = requestAnimationFrame(() => {+ textareaRef.current?.focus();+ });++ return () => cancelAnimationFrame(focusId);+ }, [activePopup]);+const commandService = useDependency(ICommandService);const updateNote = useDebounceFn((newNote: ISheetNote) => {if (!activePopup) return;