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.

fix(sheets-hyper-link): hyper-link operator issues (#3628)

zhangwe27bf5e6631a
diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo.ts b/mockdata/src/sheets/demo/default-workbook-data-demo.ts
index c51300adb7..b8aa09c90a 100644
--- a/mockdata/src/sheets/demo/default-workbook-data-demo.ts
+++ b/mockdata/src/sheets/demo/default-workbook-data-demo.ts
@@ -15,8 +15,6 @@
*/
import type { IDataValidationRule, IDocumentData, IWorkbookData } from '@univerjs/core';
-import type { ICellHyperLink } from '@univerjs/sheets-hyper-link';
-
import { BooleanNumber, DataValidationErrorStyle, DataValidationOperator, DataValidationType, LocaleType } from '@univerjs/core';
import { DATA_VALIDATION_PLUGIN_NAME } from '@univerjs/sheets-data-validation';
import { PAGE5_RICHTEXT_1 } from '../../slides/rich-text/page5-richtext1';
@@ -208,23 +206,6 @@ const dv2 = [
},
];
-const hyperLink = [
- {
- row: 20,
- column: 8,
- id: '321',
- display: 'linkTest',
- payload: '#gid=sheet-0011&range=1:1',
- },
- {
- row: 20,
- column: 12,
- id: '123',
- display: 'linkTest哈哈哈哈',
- payload: '#gid=sheet-0011&range=1:1',
- },
-] as ICellHyperLink[];
-
export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
id: 'workbook-01',
locale: LocaleType.ZH_CN,
@@ -14165,12 +14146,119 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
t: 2,
},
8: {
- v: 'linkTest',
- t: 1,
+ p: {
+ id: '__INTERNAL_EDITOR__DOCS_NORMAL',
+ documentStyle: {
+ pageSize: {
+ width: 270.44940185546875,
+ height: undefined,
+ },
+ marginTop: 0,
+ marginBottom: 1,
+ marginRight: 2,
+ marginLeft: 2,
+ renderConfig: {
+ horizontalAlign: 0,
+ verticalAlign: 0,
+ centerAngle: 0,
+ vertexAngle: 0,
+ wrapStrategy: 0,
+ },
+ },
+ body: {
+ dataStream:
+ '\u001Fhttps://univer-preview.vercel.app/sheets/\u001E\r12323\r\u001FA100\u001E\r\n',
+ textRuns: [],
+ paragraphs: [
+ {
+ startIndex: 43,
+ paragraphStyle: {
+ horizontalAlign: 0,
+ },
+ },
+ {
+ startIndex: 49,
+ paragraphStyle: {
+ horizontalAlign: 0,
+ },
+ },
+ {
+ startIndex: 93,
+ paragraphStyle: {
+ horizontalAlign: 0,
+ },
+ },
+ ],
+ sectionBreaks: [
+ {
+ startIndex: 94,
+ },
+ ],
+ customRanges: [
+ {
+ startIndex: 0,
+ endIndex: 42,
+ rangeId: 'tnxxGNtWAuHrpz4fBGAYh',
+ rangeType: 0,
+ properties: {
+ url: 'https://univer-preview.vercel.app/sheets/',
+ },
+ },
+ {
+ startIndex: 50,
+ endIndex: 55,
+ rangeId: 'j4NsUHxjolNihMoYdZ-oj',
+ rangeType: 0,
+ properties: {
+ url: '#gid=sheet-0011&range=A100',
+ },
+ },
+ ],
+ customDecorations: [],
+ },
+ drawings: {},
+ drawingsOrder: [],
+ settings: {
+ zoomRatio: 1,
+ },
+ },
},
12: {
- v: 'linkTest哈哈哈哈',
- t: 1,
+ p: {
+ id: 'd',
+ documentStyle: {
+ pageSize: {
+ width: 111.55900573730469,
+ },
+ marginTop: 0,
+ marginBottom: 1,
+ marginRight: 2,
+ marginLeft: 2,
+ renderConfig: {
+ horizontalAlign: 0,
+ verticalAlign: 0,
+ centerAngle: 0,
+ vertexAngle: 0,
+ wrapStrategy: 0,
+ },
+ },
+ body: {
+ dataStream: '\u001Fhttps://univer.ai/\u001E\r\n',
+ customRanges: [
+ {
+ startIndex: 0,
+ endIndex: 19,
+ rangeId: 'QY6zbQrxGw8IaLGXDgVVj',
+ rangeType: 0,
+ properties: {
+ url: 'https://univer.ai/',
+ },
+ },
+ ],
+ },
+ drawings: {},
+ drawingsOrder: [],
+ },
},
},
21: {
@@ -14260,8 +14348,8 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
},
20: {
hd: 0,
- h: 19,
- ah: 19,
+ h: 60,
+ ah: 60,
},
21: {
hd: 0,
@@ -23804,12 +23892,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
// },
},
resources: [
- {
- name: 'SHEET_HYPER_LINK_PLUGIN',
- data: JSON.stringify({
- 'sheet-0011': hyperLink,
- }),
- },
{
name: DATA_VALIDATION_PLUGIN_NAME,
data: JSON.stringify({
diff --git a/packages/core/src/docs/data-model/text-x/build-utils/index.ts b/packages/core/src/docs/data-model/text-x/build-utils/index.ts
index a9415ecaab..a586cbc36c 100644
--- a/packages/core/src/docs/data-model/text-x/build-utils/index.ts
+++ b/packages/core/src/docs/data-model/text-x/build-utils/index.ts
@@ -15,7 +15,7 @@
*/
import { copyCustomRange, getCustomRangesInterestsWithRange, isIntersecting, shouldDeleteCustomRange } from './custom-range';
-import { fromPlainText, getPlainText } from './parse';
+import { fromPlainText, getPlainText, isEmptyDocument } from './parse';
import { getDeleteSelection, getInsertSelection, getRetainAndDeleteFromReplace, isSegmentIntersects, makeSelection, normalizeSelection } from './selection';
import { addCustomRangeTextX, deleteCustomRangeTextX, getRetainAndDeleteAndExcludeLineBreak, replaceSelectionTextX } from './text-x-utils';
@@ -50,6 +50,7 @@ export class BuildTextUtils {
static transform = {
getPlainText,
fromPlainText,
+ isEmptyDocument,
};
}
diff --git a/packages/core/src/docs/data-model/text-x/build-utils/parse.ts b/packages/core/src/docs/data-model/text-x/build-utils/parse.ts
index 4420848392..e33e4d1159 100644
--- a/packages/core/src/docs/data-model/text-x/build-utils/parse.ts
+++ b/packages/core/src/docs/data-model/text-x/build-utils/parse.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
+import type { ICustomRange, IDocumentBody, IParagraph } from '../../../../types/interfaces';
import { generateRandomId, Tools } from '../../../../shared';
import { CustomRangeType } from '../../../../types/interfaces';
import { DataStreamTreeTokenType } from '../../types';
-import type { ICustomRange, IDocumentBody, IParagraph } from '../../../../types/interfaces';
const tags = [
// DataStreamTreeTokenType.PARAGRAPH, // 段落
@@ -43,6 +43,14 @@ export const getPlainText = (dataStream: string) => {
return tags.reduce((res, curr) => res.replaceAll(curr, ''), text);
};
+export const isEmptyDocument = (dataStream?: string) => {
+ if (!dataStream) {
+ return true;
+ }
+ const text = getPlainText(dataStream).replaceAll('\r', '');
+ return text === '';
+};
+
export const fromPlainText = (text: string): IDocumentBody => {
const dataStream = text.replace(/\n/g, '\r');
const paragraphs: IParagraph[] = [];
diff --git a/packages/core/src/docs/data-model/text-x/build-utils/text-x-utils.ts b/packages/core/src/docs/data-model/text-x/build-utils/text-x-utils.ts
index dbbfa2f40b..6e3b596b4a 100644
--- a/packages/core/src/docs/data-model/text-x/build-utils/text-x-utils.ts
+++ b/packages/core/src/docs/data-model/text-x/build-utils/text-x-utils.ts
@@ -15,26 +15,27 @@
*/
import type { IAccessor } from '@wendellhu/redi';
-import { DataStreamTreeTokenType } from '../../types';
-import { TextXActionType } from '../action-types';
-import { TextX } from '../text-x';
-import { excludePointsFromRange, isIntersecting, shouldDeleteCustomRange } from './custom-range';
-import { getDeleteSelection, getSelectionForAddCustomRange } from './selection';
import type { Nullable } from '../../../../shared';
import type { ITextRange, ITextRangeParam } from '../../../../sheets/typedef';
import type { CustomRangeType, IDocumentBody } from '../../../../types/interfaces';
import type { DocumentDataModel } from '../../document-data-model';
import type { IDeleteAction, IRetainAction } from '../action-types';
+import { DataStreamTreeTokenType } from '../../types';
+import { TextXActionType } from '../action-types';
+import { TextX } from '../text-x';
+import { excludePointsFromRange, isIntersecting, shouldDeleteCustomRange } from './custom-range';
+import { getDeleteSelection, getSelectionForAddCustomRange } from './selection';
export interface IDeleteCustomRangeParam {
rangeId: string;
segmentId?: string;
documentDataModel: DocumentDataModel;
insert?: Nullable<IDocumentBody>;
+ textRange?: { startOffset: number; endOffset: number };
}
export function deleteCustomRangeTextX(accessor: IAccessor, params: IDeleteCustomRangeParam) {
- const { rangeId, segmentId, documentDataModel, insert } = params;
+ const { rangeId, segmentId, documentDataModel, insert, textRange } = params;
const range = documentDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()?.customRanges?.find((r) => r.rangeId === rangeId);
if (!range) {
@@ -60,6 +61,14 @@ export function deleteCustomRangeTextX(accessor: IAccessor, params: IDeleteCusto
segmentId,
line: 0,
});
+ if (textRange) {
+ if (textRange.startOffset >= startIndex) {
+ textRange.startOffset--;
+ }
+ if (textRange.endOffset > startIndex) {
+ textRange.endOffset--;
+ }
+ }
if (len - 2 > 0) {
textX.push({
@@ -76,6 +85,15 @@ export function deleteCustomRangeTextX(accessor: IAccessor, params: IDeleteCusto
line: 0,
});
+ if (textRange) {
+ if (textRange.startOffset > endIndex) {
+ textRange.startOffset--;
+ }
+ if (textRange.endOffset > endIndex) {
+ textRange.endOffset--;
+ }
+ }
+
if (insert) {
textX.push({
body: insert,
@@ -84,6 +102,15 @@ export function deleteCustomRangeTextX(accessor: IAccessor, params: IDeleteCusto
segmentId,
line: 1,
});
+
+ if (textRange) {
+ if (textRange.startOffset >= endIndex) {
+ textRange.startOffset += insert.dataStream.length;
+ }
+ if (textRange.endOffset > endIndex) {
+ textRange.endOffset += insert.dataStream.length;
+ }
+ }
}
return textX;
}
diff --git a/packages/core/src/shared/tools.ts b/packages/core/src/shared/tools.ts
index dd60582774..23be3ce536 100644
--- a/packages/core/src/shared/tools.ts
+++ b/packages/core/src/shared/tools.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
+import type { IKeyValue } from './types';
import { customAlphabet, nanoid } from 'nanoid';
-import { isLegalUrl, normalizeUrl } from '../common/url';
-import type { IKeyValue } from './types';
+import { isLegalUrl, normalizeUrl } from '../common/url';
const rmsPrefix = /^-ms-/;
const rDashAlpha = /-([a-z])/g;
diff --git a/packages/core/src/sheets/span-model.ts b/packages/core/src/sheets/span-model.ts
index 95b50a2048..59e6ba1e22 100644
--- a/packages/core/src/sheets/span-model.ts
+++ b/packages/core/src/sheets/span-model.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
+import type { IRange } from './typedef';
import { LRUMap, Rectangle, Tools } from '../shared';
import { Disposable } from '../shared/lifecycle';
import { RANGE_TYPE } from './typedef';
-import type { IRange } from './typedef';
export class SpanModel extends Disposable {
/**
diff --git a/packages/design/src/components/popup/RectPopup.tsx b/packages/design/src/components/popup/RectPopup.tsx
index f49a3b471d..75a814bddd 100644
--- a/packages/design/src/components/popup/RectPopup.tsx
+++ b/packages/design/src/components/popup/RectPopup.tsx
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import React, { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
import { useEvent } from 'rc-util';
+import React, { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
import styles from './index.module.less';
interface IAbsolutePosition {
@@ -41,8 +41,9 @@ export interface IRectPopupProps {
// #region closing behavior
onClickOutside?: (e: MouseEvent) => void;
excludeOutside?: HTMLElement[];
+ onContextMenu?: () => void;
- onPinterEnter?: (e: React.PointerEvent<HTMLElement>) => void;
+ onPointerEnter?: (e: React.PointerEvent<HTMLElement>) => void;
onPointerLeave?: (e: React.PointerEvent<HTMLElement>) => void;
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
// #endregion
@@ -102,9 +103,10 @@ function calcPopupPosition(layout: IPopupLayoutInfo): { top: number; left: numbe
};
function RectPopup(props: IRectPopupProps) {
- const { children, anchorRect, direction = 'vertical', onClickOutside, excludeOutside, excludeRects, onPinterEnter, onPointerLeave, onClick, hidden } = props;
+ const { children, anchorRect, direction = 'vertical', onClickOutside, excludeOutside, excludeRects, onPointerEnter, onPointerLeave, onClick, hidden, onContextMenu } = props;
const nodeRef = useRef<HTMLElement>(null);
const clickOtherFn = useEvent(onClickOutside ?? (() => { /* empty */ }));
+ const contextMenuFn = useEvent(onContextMenu ?? (() => { /* empty */ }));
const [position, setPosition] = useState<Partial<IAbsolutePosition>>({
top: -9999,
left: -9999,
@@ -166,12 +168,21 @@ function RectPopup(props: IRectPopupProps) {
};
window.addEventListener('pointerdown', handleClickOther);
- return () => window.removeEventListener('pointerdown', handleClickOther);
+ return () => {
+ window.removeEventListener('pointerdown', handleClickOther);
+ };
}, [anchorRect, anchorRect.bottom, anchorRect.left, anchorRect.right, anchorRect.top, clickOtherFn, excludeOutside]);
+ useEffect(() => {
+ window.addEventListener('contextmenu', contextMenuFn);
+ return () => {
+ window.removeEventListener('contextmenu', contextMenuFn);
+ };
+ }, [contextMenuFn]);
+
return (
<section
- onPointerEnter={onPinterEnter}
+ onPointerEnter={onPointerEnter}
onPointerLeave={onPointerLeave}
ref={nodeRef}
style={{ ...style, ...hidden ? { display: 'none' } : null }}
diff --git a/packages/docs-ui/src/basics/custom-range-factory.ts b/packages/docs-ui/src/basics/custom-range-factory.ts
index 59c39f7a14..b7e9378144 100644
--- a/packages/docs-ui/src/basics/custom-range-factory.ts
+++ b/packages/docs-ui/src/basics/custom-range-factory.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import { BuildTextUtils, IUniverInstanceService, JSONX, UniverInstanceType } from '@univerjs/core';
-import { DocSelectionManagerService, RichTextEditingMutation } from '@univerjs/docs';
import type { CustomRangeType, DocumentDataModel, IAccessor, IAddCustomRangeTextXParam, IDocumentBody, IMutationInfo, ITextRangeParam, Nullable, TextX } from '@univerjs/core';
import type { IRichTextEditingMutationParams } from '@univerjs/docs';
+import { BuildTextUtils, IUniverInstanceService, JSONX, UniverInstanceType } from '@univerjs/core';
+import { DocSelectionManagerService, RichTextEditingMutation } from '@univerjs/docs';
import { getRichTextEditPath } from '../commands/util';
interface IAddCustomRangeParam extends IAddCustomRangeTextXParam {
@@ -117,11 +117,14 @@ export interface IDeleteCustomRangeFactoryParams {
export function deleteCustomRangeFactory(accessor: IAccessor, params: IDeleteCustomRangeFactoryParams) {
const { unitId, segmentId, insert } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
+ const docSelectionManagerService = accessor.get(DocSelectionManagerService);
+ const selection = docSelectionManagerService.getTextRanges({ unitId, subUnitId: unitId })?.[0];
const documentDataModel = univerInstanceService.getUnit<DocumentDataModel>(unitId);
if (!documentDataModel) {
return false;
}
+ const textRange = selection ? { startOffset: selection.startOffset, endOffset: selection.endOffset } : undefined;
const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {
id: RichTextEditingMutation.id,
params: {
@@ -138,6 +141,7 @@ export function deleteCustomRangeFactory(accessor: IAccessor, params: IDeleteCus
rangeId: params.rangeId,
insert,
segmentId,
+ textRange,
});
if (!textX) {
@@ -146,5 +150,6 @@ export function deleteCustomRangeFactory(accessor: IAccessor, params: IDeleteCus
const path = getRichTextEditPath(documentDataModel, segmentId);
doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
+ doMutation.params.textRanges = textRange ? [{ startOffset: textRange.startOffset, endOffset: textRange.endOffset, collapsed: textRange.startOffset === textRange.endOffset }] : undefined;
return doMutation;
}
diff --git a/packages/docs-ui/src/commands/commands/replace-content.command.ts b/packages/docs-ui/src/commands/commands/replace-content.command.ts
index c14ee9e35f..f36b6693f1 100644
--- a/packages/docs-ui/src/commands/commands/replace-content.command.ts
+++ b/packages/docs-ui/src/commands/commands/replace-content.command.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import { BuildTextUtils, CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, JSONX, TextX, TextXActionType, Tools, UniverInstanceType } from '@univerjs/core';
-import { DocSelectionManagerService, RichTextEditingMutation } from '@univerjs/docs';
import type { DocumentDataModel, ICommand, IDocumentBody, IDocumentData, IMutationInfo, ITextRange, JSONXActions } from '@univerjs/core';
import type { IRichTextEditingMutationParams } from '@univerjs/docs';
import type { ITextRangeWithStyle } from '@univerjs/engine-render';
+import { BuildTextUtils, CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, JSONX, TextX, TextXActionType, Tools, UniverInstanceType } from '@univerjs/core';
+import { DocSelectionManagerService, RichTextEditingMutation } from '@univerjs/docs';
import { getRichTextEditPath } from '../util';
interface IReplaceSnapshotCommandParams {
diff --git a/packages/docs-ui/src/components/editor/TextEditor.tsx b/packages/docs-ui/src/components/editor/TextEditor.tsx
index 8a171849bc..84250aa4d9 100644
--- a/packages/docs-ui/src/components/editor/TextEditor.tsx
+++ b/packages/docs-ui/src/components/editor/TextEditor.tsx
@@ -14,14 +14,14 @@
* limitations under the License.
*/
+import type { IDocumentData, Nullable } from '@univerjs/core';
+import type { Editor, IEditorCanvasStyle } from '../../services/editor/editor';
import { debounce, isInternalEditorID, LocaleService, useDependency } from '@univerjs/core';
import React, { useEffect, useRef, useState } from 'react';
-import type { IDocumentData, Nullable } from '@univerjs/core';
import { isElementVisible } from '../../basics/editor';
import { IEditorService } from '../../services/editor/editor-manager.service';
import styles from './index.module.less';
import { genSnapShotByValue } from './utils';
-import type { Editor, IEditorCanvasStyle } from '../../services/editor/editor';
type MyComponentProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
diff --git a/packages/docs-ui/src/components/editor/utils.ts b/packages/docs-ui/src/components/editor/utils.ts
index 40f4c4aa5e..f1d97fc609 100644
--- a/packages/docs-ui/src/components/editor/utils.ts
+++ b/packages/docs-ui/src/components/editor/utils.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentFlavor } from '@univerjs/core';
import type { IDocumentData } from '@univerjs/core';
+import { DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentFlavor } from '@univerjs/core';
/**
*
diff --git a/packages/docs-ui/src/components/range-selector/RangeSelector.tsx b/packages/docs-ui/src/components/range-selector/RangeSelector.tsx
index 3aeba59cf6..bb8d89029c 100644
--- a/packages/docs-ui/src/components/range-selector/RangeSelector.tsx
+++ b/packages/docs-ui/src/components/range-selector/RangeSelector.tsx
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-import { IUniverInstanceService, LocaleService, ThemeService, UniverInstanceType, useDependency } from '@univerjs/core';
+import type { IUnitRangeWithName, Nullable, Workbook } from '@univerjs/core';
+import { IUniverInstanceService, LocaleService, UniverInstanceType, useDependency } from '@univerjs/core';
import { Button, Dialog, Input, Tooltip } from '@univerjs/design';
import { getRangeWithRefsString, isReferenceStringWithEffectiveColumn, serializeRange, serializeRangeWithSheet, serializeRangeWithSpreadsheet } from '@univerjs/engine-formula';
import { CloseSingle, DeleteSingle, IncreaseSingle, SelectRangeSingle } from '@univerjs/icons';
-import { useEvent } from '@univerjs/ui';
+import { useEvent } from '@univerjs/ui';
import clsx from 'clsx';
import React, { useEffect, useRef, useState } from 'react';
-import type { IUnitRangeWithName, Nullable, Workbook } from '@univerjs/core';
import { IEditorService } from '../../services/editor/editor-manager.service';
import { IRangeSelectorService } from '../../services/range-selector/range-selector.service';
import { TextEditor } from '../editor/TextEditor';
@@ -44,17 +44,15 @@ export interface IRangeSelectorProps {
className?: string;
textEditorClassName?: string;
onSelectorVisibleChange?: (visible: boolean) => void;
- disableInput?: boolean;
+ dialogOnly?: boolean;
}
-const disableInputStyle: React.CSSProperties = {
+const dialogOnlyInputStyle: React.CSSProperties = {
pointerEvents: 'none',
- cursor: 'not-allowed',
- opacity: 0.5,
};
export function RangeSelector(props: IRangeSelectorProps) {
- const { onChange, id, value = '', width = 220, placeholder = '', size = 'middle', onActive, onValid, isSingleChoice = false, openForSheetUnitId, openForSheetSubUnitId, isReadonly = false, className, textEditorClassName, onSelectorVisibleChange: _onSelectorVisibleChange, disableInput } = props;
+ const { dialogOnly, onChange, id, value = '', width = 220, placeholder = '', size = 'middle', onActive, onValid, isSingleChoice = false, openForSheetUnitId, openForSheetSubUnitId, isReadonly = false, className, textEditorClassName, onSelectorVisibleChange: _onSelectorVisibleChange } = props;
const onSelectorVisibleChange = useEvent(_onSelectorVisibleChange);
const [rangeDataList, setRangeDataList] = useState<string[]>(['']);
@@ -115,7 +113,6 @@ export function RangeSelector(props: IRangeSelectorProps) {
const isSingleChoiceRef = useRef<Nullable<boolean>>(isSingleChoice);
const isReadonlyRef = useRef<Nullable<boolean>>(isReadonly);
- const themeService = useDependency(ThemeService);
useEffect(() => {
const selector = selectorRef.current;
@@ -309,14 +306,24 @@ export function RangeSelector(props: IRangeSelectorProps) {
} else if (size === 'large') {
height = 32;
}
- const theme = themeService.getCurrentTheme();
return (
<>
- <div className={sClassName} ref={selectorRef} style={{ width, height }}>
- <TextEditor style={disableInput ? disableInputStyle : undefined} placeholder={placeholder} value={value} isReadonly={isReadonly} isSingleChoice={isSingleChoice} openForSheetUnitId={openForSheetUnitId} openForSheetSubUnitId={openForSheetSubUnitId} onValid={onEditorValid} onActive={onEditorActive} onChange={handleTextValueChange} id={id} onlyInputRange={true} canvasStyle={{ fontSize: 10 }} className={styles.rangeSelectorEditor} />
+ <div
+ className={sClassName}
+ ref={selectorRef}
+ style={{ width, height, cursor: dialogOnly ? 'pointer' : undefined }}
+ onClickCapture={(event) => {
+ if (dialogOnly) {
+ event.stopPropagation();
+ event.preventDefault();
+ handleOpenModal();
+ }
+ }}
+ >
+ <TextEditor style={dialogOnly ? dialogOnlyInputStyle : undefined} placeholder={placeholder} value={value} isReadonly={isReadonly} isSingleChoice={isSingleChoice} openForSheetUnitId={openForSheetUnitId} openForSheetSubUnitId={openForSheetSubUnitId} onValid={onEditorValid} onActive={onEditorActive} onChange={handleTextValueChange} id={id} onlyInputRange={true} canvasStyle={{ fontSize: 10 }} className={styles.rangeSelectorEditor} />
<Tooltip title={localeService.t('rangeSelector.buttonTooltip')} placement="bottom">
- <button className={styles.rangeSelectorIcon} onClick={handleOpenModal}>
- <SelectRangeSingle style={disableInput ? { color: theme.primaryColor } : undefined} />
+ <button type="button" className={styles.rangeSelectorIcon} onClick={handleOpenModal}>
+ <SelectRangeSingle />
</button>
</Tooltip>
</div>
diff --git a/packages/docs-ui/src/controllers/render-controllers/back-scroll.render-controller.ts b/packages/docs-ui/src/controllers/render-controllers/back-scroll.render-controller.ts
index 7420461a1f..ea9aeba2cd 100644
--- a/packages/docs-ui/src/controllers/render-controllers/back-scroll.render-controller.ts
+++ b/packages/docs-ui/src/controllers/render-controllers/back-scroll.render-controller.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
+import type { DocumentDataModel, ITextRange, Nullable } from '@univerjs/core';
+import type { Documents, INodePosition, IRenderContext, IRenderModule } from '@univerjs/engine-render';
import { Inject, RxDisposable } from '@univerjs/core';
import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs';
import { takeUntil } from 'rxjs';
-import type { DocumentDataModel, ITextRange, Nullable } from '@univerjs/core';
-import type { Documents, INodePosition, IRenderContext, IRenderModule } from '@univerjs/engine-render';
import { VIEWPORT_KEY } from '../../basics/docs-view-key';
import { IEditorService } from '../../services/editor/editor-manager.service';
import { NodePositionConvertToCursor } from '../../services/selection/convert-text-range';
diff --git a/packages/docs-ui/src/controllers/render-controllers/doc-clipboard.controller.ts b/packages/docs-ui/src/controllers/render-controllers/doc-clipboard.controller.ts
index 4e0999a15d..a25fbfb337 100644
--- a/packages/docs-ui/src/controllers/render-controllers/doc-clipboard.controller.ts
+++ b/packages/docs-ui/src/controllers/render-controllers/doc-clipboard.controller.ts
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+import type { DocumentDataModel } from '@univerjs/core';
+import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
+
import {
ICommandService,
IContextService,
@@ -21,9 +24,6 @@ import {
RxDisposable,
} from '@univerjs/core';
import { takeUntil } from 'rxjs';
-
-import type { DocumentDataModel } from '@univerjs/core';
-import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
import { whenDocOrEditor } from '../../commands/commands/clipboard.command';
import { IDocClipboardService } from '../../services/clipboard/clipboard.service';
import { IEditorService } from '../../services/editor/editor-manager.service';
diff --git a/packages/docs-ui/src/controllers/render-controllers/doc-editor-bridge.controller.ts b/packages/docs-ui/src/controllers/render-controllers/doc-editor-bridge.controller.ts
index 696685a032..1081db4cd9 100644
--- a/packages/docs-ui/src/controllers/render-controllers/doc-editor-bridge.controller.ts
+++ b/packages/docs-ui/src/controllers/render-controllers/doc-editor-bridge.controller.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
+import type { DocumentDataModel, ICommandInfo, Nullable, Workbook } from '@univerjs/core';
+import type { IRichTextEditingMutationParams } from '@univerjs/docs';
+import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
import { checkForSubstrings, Disposable, ICommandService, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { DocSkeletonManagerService, RichTextEditingMutation } from '@univerjs/docs';
import { IRenderManagerService, ScrollBar } from '@univerjs/engine-render';
import { SetEditorResizeOperation } from '@univerjs/ui';
import { fromEvent } from 'rxjs';
-import type { DocumentDataModel, ICommandInfo, Nullable, Workbook } from '@univerjs/core';
-import type { IRichTextEditingMutationParams } from '@univerjs/docs';
-import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
import { VIEWPORT_KEY } from '../../basics/docs-view-key';
import { CoverContentCommand } from '../../commands/commands/replace-content.command';
import { IEditorService } from '../../services/editor/editor-manager.service';
diff --git a/packages/docs-ui/src/controllers/render-controllers/doc-resize.render-controller.ts b/packages/docs-ui/src/controllers/render-controllers/doc-resize.render-controller.ts
index 80cab95d3c..b66ddb42db 100644
--- a/packages/docs-ui/src/controllers/render-controllers/doc-resize.render-controller.ts
+++ b/packages/docs-ui/src/controllers/render-controllers/doc-resize.render-controller.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
+import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
import { Disposable, DOCS_ZEN_EDITOR_UNIT_ID_KEY, fromEventSubject, Inject, isInternalEditorID } from '@univerjs/core';
import { DocSelectionManagerService } from '@univerjs/docs';
import { TRANSFORM_CHANGE_OBSERVABLE_TYPE } from '@univerjs/engine-render';
import { animationFrameScheduler, filter, throttleTime } from 'rxjs';
-import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
import { DocPageLayoutService } from '../../services/doc-page-layout.service';
// REFACTOR: @JOCS, move to new-docs package.
diff --git a/packages/docs-ui/src/controllers/render-controllers/doc.render-controller.ts b/packages/docs-ui/src/controllers/render-controllers/doc.render-controller.ts
index 1ea369f399..120974abce 100644
--- a/packages/docs-ui/src/controllers/render-controllers/doc.render-controller.ts
+++ b/packages/docs-ui/src/controllers/render-controllers/doc.render-controller.ts
@@ -14,13 +14,13 @@
* limitations under the License.
*/
+import type { DocumentDataModel, EventState, ICommandInfo, Nullable } from '@univerjs/core';
+import type { IRichTextEditingMutationParams } from '@univerjs/docs';
+import type { DocumentSkeleton, IRenderContext, IRenderModule, IWheelEvent } from '@univerjs/engine-render';
import { ICommandService, IContextService, Inject, IUniverInstanceService, RxDisposable, UniverInstanceType } from '@univerjs/core';
import { DocSkeletonManagerService, RichTextEditingMutation } from '@univerjs/docs';
import { DocBackground, Documents, IRenderManagerService, Layer, PageLayoutType, ScrollBar, Viewport } from '@univerjs/engine-render';
import { takeUntil } from 'rxjs';
-import type { DocumentDataModel, EventState, ICommandInfo, Nullable } from '@univerjs/core';
-import type { IRichTextEditingMutationParams } from '@univerjs/docs';
-import type { DocumentSkeleton, IRenderContext, IRenderModule, IWheelEvent } from '@univerjs/engine-render';
import { DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_VIEW_KEY, VIEWPORT_KEY } from '../../basics/docs-view-key';
import { IEditorService } from '../../services/editor/editor-manager.service';
import { DocSelectionRenderService } from '../../services/selection/doc-selection-render.service';
diff --git a/packages/docs-ui/src/docs-ui-plugin.ts b/packages/docs-ui/src/docs-ui-plugin.ts
index 4c645fb61e..c8de6c00f3 100644
--- a/packages/docs-ui/src/docs-ui-plugin.ts
+++ b/packages/docs-ui/src/docs-ui-plugin.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import type { Dependency } from '@univerjs/core';
+import type { IUniverDocsUIConfig } from './controllers/config.schema';
import { DependentOn, ICommandService,
IConfigService,
ILogService,
@@ -26,7 +28,6 @@ import { DependentOn, ICommandService,
import { DocInterceptorService, DocSkeletonManagerService } from '@univerjs/docs';
import { IRenderManagerService, UniverRenderEnginePlugin } from '@univerjs/engine-render';
import { IShortcutService } from '@univerjs/ui';
-import type { Dependency } from '@univerjs/core';
import { DOC_UI_PLUGIN_NAME } from './basics/const/plugin-name';
import { AfterSpaceCommand, EnterCommand, TabCommand } from './commands/commands/auto-format.command';
import { BreakLineCommand } from './commands/commands/break-line.command';
@@ -92,7 +93,6 @@ import {
SelectAllShortcut,
} from './shortcuts/cursor.shortcut';
import { ShiftTabShortCut } from './shortcuts/format.shortcut';
-import type { IUniverDocsUIConfig } from './controllers/config.schema';
@DependentOn(UniverRenderEnginePlugin)
export class UniverDocsUIPlugin extends Plugin {
diff --git a/packages/docs-ui/src/services/clipboard/clipboard.service.ts b/packages/docs-ui/src/services/clipboard/clipboard.service.ts
index 38fade307c..5f19179b63 100644
--- a/packages/docs-ui/src/services/clipboard/clipboard.service.ts
+++ b/packages/docs-ui/src/services/clipboard/clipboard.service.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+import type { IDisposable, IDocumentBody, IDocumentData, Nullable } from '@univerjs/core';
+import type { IRectRangeWithStyle, ITextRangeWithStyle } from '@univerjs/engine-render';
import { BuildTextUtils, createIdentifier, DataStreamTreeTokenType, Disposable, DOC_RANGE_TYPE, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, getBodySlice, ICommandService, ILogService, Inject, IUniverInstanceService, normalizeBody, SliceBodyType, toDisposable, Tools, UniverInstanceType } from '@univerjs/core';
+
import { DocSelectionManagerService } from '@univerjs/docs';
import { HTML_CLIPBOARD_MIME_TYPE, IClipboardInterfaceService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE } from '@univerjs/ui';
-
-import type { IDisposable, IDocumentBody, IDocumentData, Nullable } from '@univerjs/core';
-import type { IRectRangeWithStyle, ITextRangeWithStyle } from '@univerjs/engine-render';
import { CutContentCommand, InnerPasteCommand } from '../../commands/commands/clipboard.inner.command';
import { getCursorWhenDelete } from '../../commands/commands/delete.command';
import { copyContentCache, extractId, genId } from './copy-content-cache';
diff --git a/packages/docs-ui/src/services/editor/editor-manager.service.ts b/packages/docs-ui/src/services/editor/editor-manager.service.ts
index 7069a17efb..84d07b3ebf 100644
--- a/packages/docs-ui/src/services/editor/editor-manager.service.ts
+++ b/packages/docs-ui/src/services/editor/editor-manager.service.ts
@@ -14,16 +14,16 @@
* limitations under the License.
*/
+import type { DocumentDataModel, IDisposable, IDocumentBody, IDocumentData, Nullable, Workbook } from '@univerjs/core';
+import type { ISuccinctDocRangeParam, Scene } from '@univerjs/engine-render';
+import type { Observable } from 'rxjs';
+import type { IEditorConfigParams, IEditorStateParams } from './editor';
import { createIdentifier, DEFAULT_EMPTY_DOCUMENT_VALUE, Disposable, EDITOR_ACTIVATED, FOCUSING_EDITOR_INPUT_FORMULA, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, HorizontalAlign, ICommandService, IContextService, Inject, IUndoRedoService, IUniverInstanceService, toDisposable, UniverInstanceType, VerticalAlign } from '@univerjs/core';
import { DocSelectionManagerService } from '@univerjs/docs';
import { isReferenceStrings, LexerTreeBuilder, operatorToken } from '@univerjs/engine-formula';
import { IRenderManagerService } from '@univerjs/engine-render';
import { fromEvent, Subject } from 'rxjs';
-import type { DocumentDataModel, IDisposable, IDocumentBody, IDocumentData, Nullable, Workbook } from '@univerjs/core';
-import type { ISuccinctDocRangeParam, Scene } from '@univerjs/engine-render';
-import type { Observable } from 'rxjs';
import { Editor } from './editor';
-import type { IEditorConfigParams, IEditorStateParams } from './editor';
/**
* Not these elements will be considered as editor blur.
diff --git a/packages/docs-ui/src/services/editor/editor.ts b/packages/docs-ui/src/services/editor/editor.ts
index 1056dd56fe..88036203dc 100644
--- a/packages/docs-ui/src/services/editor/editor.ts
+++ b/packages/docs-ui/src/services/editor/editor.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import { DEFAULT_STYLES, Disposable, UniverInstanceType } from '@univerjs/core';
-import { merge, type Observable, Subject } from 'rxjs';
import type { DocumentDataModel, ICommandService, IDocumentData, IDocumentStyle, IPosition, IUndoRedoService, IUniverInstanceService, Nullable } from '@univerjs/core';
import type { DocSelectionManagerService } from '@univerjs/docs';
import type { IDocSelectionInnerParam, IRender, ISuccinctDocRangeParam, ITextRangeWithStyle } from '@univerjs/engine-render';
+import { DEFAULT_STYLES, Disposable, UniverInstanceType } from '@univerjs/core';
+import { merge, type Observable, Subject } from 'rxjs';
import { ReplaceSnapshotCommand } from '../../commands/commands/replace-content.command';
import { DocSelectionRenderService, type IEditorInputConfig } from '../selection/doc-selection-render.service';
diff --git a/packages/docs-ui/src/services/selection/doc-selection-render.service.ts b/packages/docs-ui/src/services/selection/doc-selection-render.service.ts
index e54ae281c0..1655f61d6c 100644
--- a/packages/docs-ui/src/services/selection/doc-selection-render.service.ts
+++ b/packages/docs-ui/src/services/selection/doc-selection-render.service.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
+import type { DocumentDataModel, Nullable } from '@univerjs/core';
+import type { Documents, Engine, IDocSelectionInnerParam, IFindNodeRestrictions, IMouseEvent, INodeInfo, INodePosition, IPointerEvent, IRenderContext, IRenderModule, IScrollObserverParam, ISuccinctDocRangeParam, ITextRangeWithStyle, ITextSelectionStyle } from '@univerjs/engine-render';
+import type { Subscription } from 'rxjs';
import { DataStreamTreeTokenType, DOC_RANGE_TYPE, ILogService, Inject, IUniverInstanceService, RxDisposable, UniverInstanceType } from '@univerjs/core';
import { DocSkeletonManagerService } from '@univerjs/docs';
import { CURSOR_TYPE, getSystemHighlightColor, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, PageLayoutType, ScrollTimer, Vector2 } from '@univerjs/engine-render';
import { ILayoutService } from '@univerjs/ui';
import { BehaviorSubject, fromEvent, Subject, takeUntil } from 'rxjs';
-import type { DocumentDataModel, Nullable } from '@univerjs/core';
-import type { Documents, Engine, IDocSelectionInnerParam, IFindNodeRestrictions, IMouseEvent, INodeInfo, INodePosition, IPointerEvent, IRenderContext, IRenderModule, IScrollObserverParam, ISuccinctDocRangeParam, ITextRangeWithStyle, ITextSelectionStyle } from '@univerjs/engine-render';
-import type { Subscription } from 'rxjs';
import { RectRange } from './rect-range';
import { getCanvasOffsetByEngine, getParagraphInfoByGlyph, getRangeListFromCharIndex, getRangeListFromSelection, getRectRangeFromCharIndex, getTextRangeFromCharIndex, serializeRectRange, serializeTextRange } from './selection-utils';
import { TextRange } from './text-range';
@@ -286,7 +286,7 @@ export class DocSelectionRenderService extends RxDisposable implements IRenderMo
* @deprecated
*/
activate(x: number, y: number, force = false) {
- const isFocusing = this._input === document.activeElement;
+ const isFocusing = this._input === document.activeElement || document.activeElement === document.body || document.activeElement === null;
this._container.style.left = `${x}px`;
this._container.style.top = `${y}px`;
this._container.style.zIndex = '1000';
diff --git a/packages/engine-render/src/engine.ts b/packages/engine-render/src/engine.ts
index 2aa5e9aa16..d28c97f34b 100644
--- a/packages/engine-render/src/engine.ts
+++ b/packages/engine-render/src/engine.ts
@@ -14,10 +14,15 @@
* limitations under the License.
*/
+import type { Nullable } from '@univerjs/core';
+import type { CURSOR_TYPE } from './basics/const';
+
+import type { IKeyboardEvent, IPointerEvent } from './basics/i-events';
+import type { ITimeMetric } from './basics/interfaces';
+import type { IBasicFrameInfo } from './basics/performance-monitor';
+import type { Scene } from './scene';
import { toDisposable, Tools } from '@univerjs/core';
import { Observable, shareReplay, Subject } from 'rxjs';
-
-import type { Nullable } from '@univerjs/core';
import { DeviceType, PointerInput } from './basics/i-events';
import { TRANSFORM_CHANGE_OBSERVABLE_TYPE } from './basics/interfaces';
import { PerformanceMonitor } from './basics/performance-monitor';
@@ -25,11 +30,6 @@ import { getPointerPrefix, getSizeForDom, IsSafari, requestNewFrame } from './ba
import { Canvas, CanvasRenderMode } from './canvas';
import { observeClientRect } from './floating/util';
import { ThinEngine } from './thin-engine';
-import type { CURSOR_TYPE } from './basics/const';
-import type { IKeyboardEvent, IPointerEvent } from './basics/i-events';
-import type { ITimeMetric } from './basics/interfaces';
-import type { IBasicFrameInfo } from './basics/performance-monitor';
-import type { Scene } from './scene';
export class Engine extends ThinEngine<Scene> {
renderEvenInBackground = true;
diff --git a/packages/engine-render/src/thin-engine.ts b/packages/engine-render/src/thin-engine.ts
index 7bf8c85476..fe6e0508a3 100644
--- a/packages/engine-render/src/thin-engine.ts
+++ b/packages/engine-render/src/thin-engine.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-import { Disposable, EventSubject } from '@univerjs/core';
import type { IDisposable } from '@univerjs/core';
-
-import { RENDER_CLASS_TYPE } from './basics/const';
import type { CURSOR_TYPE } from './basics/const';
+
import type { IEvent } from './basics/i-events';
import type { ITransformChangeState } from './basics/interfaces';
import type { Canvas } from './canvas';
+import { Disposable, EventSubject } from '@univerjs/core';
+import { RENDER_CLASS_TYPE } from './basics/const';
// FIXME: ThinEngine and ThinScene should be removed
diff --git a/packages/engine-render/src/viewport.ts b/packages/engine-render/src/viewport.ts
index 312ebf547b..77d47cc2a9 100644
--- a/packages/engine-render/src/viewport.ts
+++ b/packages/engine-render/src/viewport.ts
@@ -14,9 +14,15 @@
* limitations under the License.
*/
-import { EventSubject, Tools } from '@univerjs/core';
import type { EventState, IPosition, IRange, Nullable } from '@univerjs/core';
+import type { BaseObject } from './base-object';
+import type { IWheelEvent } from './basics/i-events';
+import type { IBoundRectNoAngle, IViewportInfo } from './basics/vector2';
+import type { UniverRenderingContext } from './context';
+import type { BaseScrollBar } from './shape/base-scroll-bar';
+import type { ThinScene } from './thin-scene';
+import { EventSubject, Tools } from '@univerjs/core';
import { RENDER_CLASS_TYPE } from './basics/const';
import { PointerInput } from './basics/i-events';
import { fixLineWidthByScale, toPx } from './basics/tools';
@@ -24,12 +30,6 @@ import { Transform } from './basics/transform';
import { Vector2 } from './basics/vector2';
import { subtractViewportRange } from './basics/viewport-subtract';
import { Canvas as UniverCanvas } from './canvas';
-import type { BaseObject } from './base-object';
-import type { IWheelEvent } from './basics/i-events';
-import type { IBoundRectNoAngle, IViewportInfo } from './basics/vector2';
-import type { UniverRenderingContext } from './context';
-import type { BaseScrollBar } from './shape/base-scroll-bar';
-import type { ThinScene } from './thin-scene';
interface IViewPosition {
top?: number;
diff --git a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
index f2415e4e59..a814387b3f 100644
--- a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
+++ b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
@@ -14,13 +14,13 @@
* limitations under the License.
*/
+import type { IWorkbookData } from '@univerjs/core';
+import type { ISetSheetsFilterCriteriaMutationParams, ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';
import { AuthzIoLocalService, DisposableCollection, IAuthzIoService, ICommandService, Inject, Injector, LocaleType, Plugin, Univer, UniverInstanceType } from '@univerjs/core';
import { ExclusiveRangeService, IExclusiveRangeService, RangeProtectionRuleModel, RefRangeService, SetWorksheetActiveOperation, SheetInterceptorService, SheetsSelectionsService, WorkbookPermissionService, WorksheetPermissionService, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';
import { RemoveSheetsFilterMutation, SetSheetsFilterCriteriaMutation, SetSheetsFilterRangeMutation, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { IMenuManagerService, IPlatformService, IShortcutService, MenuManagerService, PlatformService, ShortcutService } from '@univerjs/ui';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import type { IWorkbookData } from '@univerjs/core';
-import type { ISetSheetsFilterCriteriaMutationParams, ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SmartToggleSheetsFilterCommand } from '../../commands/commands/sheets-filter.command';
import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
import { ClearFilterCriteriaMenuItemFactory, ReCalcFilterMenuItemFactory, SmartToggleFilterMenuItemFactory } from '../sheets-filter.menu';
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx
index 983280eb12..3f73a50ec9 100644
--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx
+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx
@@ -14,17 +14,17 @@
* limitations under the License.
*/
+import type { ISelectProps } from '@univerjs/design';
+import type { FilterOperator, IFilterConditionFormParams } from '../../models/conditions';
+import type { ByConditionsModel } from '../../services/sheets-filter-panel.service';
import { LocaleService, useDependency } from '@univerjs/core';
import { Input, Radio, RadioGroup, Select } from '@univerjs/design';
+
import { useObservable } from '@univerjs/ui';
import React, { useCallback, useMemo } from 'react';
-import type { ISelectProps } from '@univerjs/design';
-
import { FilterConditionItems } from '../../models/conditions';
-import styles from './index.module.less';
-import type { FilterOperator, IFilterConditionFormParams } from '../../models/conditions';
-import type { ByConditionsModel } from '../../services/sheets-filter-panel.service';
+import styles from './index.module.less';
/**
* Filter by conditions.
diff --git a/packages/sheets-filter/src/utils.ts b/packages/sheets-filter/src/utils.ts
index 14d8afc131..94964a59bc 100644
--- a/packages/sheets-filter/src/utils.ts
+++ b/packages/sheets-filter/src/utils.ts
@@ -15,8 +15,8 @@
*/
import type { IMutationInfo, Nullable } from '@univerjs/core';
-import { SetSheetsFilterCriteriaMutation } from './commands/mutations/sheets-filter.mutation';
import type { ISetSheetsFilterCriteriaMutationParams } from './commands/mutations/sheets-filter.mutation';
+import { SetSheetsFilterCriteriaMutation } from './commands/mutations/sheets-filter.mutation';
interface ILine {
start: number;
diff --git a/packages/sheets-formula/src/controllers/prompt.controller.ts b/packages/sheets-formula/src/controllers/prompt.controller.ts
index 9354987981..800df076ce 100644
--- a/packages/sheets-formula/src/controllers/prompt.controller.ts
+++ b/packages/sheets-formula/src/controllers/prompt.controller.ts
@@ -16,6 +16,23 @@
// FIXME: why so many calling to close the editor here?
+import type {
+ DocumentDataModel,
+ ICommandInfo,
+ IDisposable,
+ IRange,
+ IRangeWithCoord,
+ ITextRun,
+ Nullable,
+ Workbook,
+} from '@univerjs/core';
+import type { Editor } from '@univerjs/docs-ui';
+import type { IAbsoluteRefTypeForRange, ISequenceNode } from '@univerjs/engine-formula';
+import type {
+ ISelectionWithStyle,
+} from '@univerjs/sheets';
+import type { EditorBridgeService, SelectionShape } from '@univerjs/sheets-ui';
+import type { ISelectEditorFormulaOperationParam } from '../commands/operations/editor-formula.operation';
import {
AbsoluteRefType,
Direction,
@@ -77,25 +94,9 @@ import {
MoveSelectionCommand,
SheetSkeletonManagerService,
} from '@univerjs/sheets-ui';
+
import { IContextMenuService, ILayoutService, KeyCode, MetaKeys, SetEditorResizeOperation, UNI_DISABLE_CHANGING_FOCUS_KEY } from '@univerjs/ui';
import { distinctUntilChanged, distinctUntilKeyChanged } from 'rxjs';
-import type {
- DocumentDataModel,
- ICommandInfo,
- IDisposable,
- IRange,
- IRangeWithCoord,
- ITextRun,
- Nullable,
- Workbook,
-} from '@univerjs/core';
-import type { Editor } from '@univerjs/docs-ui';
-import type { IAbsoluteRefTypeForRange, ISequenceNode } from '@univerjs/engine-formula';
-import type {
- ISelectionWithStyle,
-} from '@univerjs/sheets';
-
-import type { EditorBridgeService, SelectionShape } from '@univerjs/sheets-ui';
import { SelectEditorFormulaOperation } from '../commands/operations/editor-formula.operation';
import { HelpFunctionOperation } from '../commands/operations/help-function.operation';
import { ReferenceAbsoluteOperation } from '../commands/operations/reference-absolute.operation';
@@ -105,7 +106,6 @@ import { getFormulaRefSelectionStyle } from '../common/selection';
import { IDescriptionService } from '../services/description.service';
import { IFormulaPromptService } from '../services/prompt.service';
import { RefSelectionsRenderService } from '../services/render-services/ref-selections.render-service';
-import type { ISelectEditorFormulaOperationParam } from '../commands/operations/editor-formula.operation';
interface IRefSelection {
refIndex: number;
diff --git a/packages/sheets-formula/src/services/render-services/ref-selections.render-service.ts b/packages/sheets-formula/src/services/render-services/ref-selections.render-service.ts
index 285dfcde59..eff94312a4 100644
--- a/packages/sheets-formula/src/services/render-services/ref-selections.render-service.ts
+++ b/packages/sheets-formula/src/services/render-services/ref-selections.render-service.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
+import type { IDisposable, Nullable, Workbook } from '@univerjs/core';
+import type { IMouseEvent, IPointerEvent, IRenderContext, IRenderModule, Viewport } from '@univerjs/engine-render';
+import type { ISelectionStyle, ISelectionWithCoordAndStyle, ISelectionWithStyle, SheetsSelectionsService, WorkbookSelections } from '@univerjs/sheets';
import { DisposableCollection, Inject, Injector, RANGE_TYPE, ThemeService, toDisposable } from '@univerjs/core';
import { ScrollTimerType, SHEET_VIEWPORT_KEY, Vector2 } from '@univerjs/engine-render';
import { convertSelectionDataToRange, getNormalSelectionStyle, IRefSelectionsService, SelectionMoveType } from '@univerjs/sheets';
import { attachSelectionWithCoord, BaseSelectionRenderService, checkInHeaderRanges, getAllSelection, getCoordByOffset, getSheetObject, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
import { IShortcutService } from '@univerjs/ui';
-import type { IDisposable, Nullable, Workbook } from '@univerjs/core';
-import type { IMouseEvent, IPointerEvent, IRenderContext, IRenderModule, Viewport } from '@univerjs/engine-render';
-import type { ISelectionStyle, ISelectionWithCoordAndStyle, ISelectionWithStyle, SheetsSelectionsService, WorkbookSelections } from '@univerjs/sheets';
/**
* This service extends the existing `SelectionRenderService` to provide the rendering of prompt selections
diff --git a/packages/sheets-hyper-link-ui/src/services/popup.service.ts b/packages/sheets-hyper-link-ui/src/services/popup.service.ts
index ec16912cc8..a470de0793 100644
--- a/packages/sheets-hyper-link-ui/src/services/popup.service.ts
+++ b/packages/sheets-hyper-link-ui/src/services/popup.service.ts
@@ -14,16 +14,16 @@
* limitations under the License.
*/
+import type { DocumentDataModel, ICustomRange, IDisposable, INeedCheckDisposable, ITextRange, Nullable, Workbook } from '@univerjs/core';
+import type { IBoundRectNoAngle } from '@univerjs/engine-render';
+import type { ISheetLocationBase } from '@univerjs/sheets';
+import type { ICanvasPopup } from '@univerjs/sheets-ui';
import { BuildTextUtils, createInternalEditorID, CustomRangeType, Disposable, DOCS_ZEN_EDITOR_UNIT_ID_KEY, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { DocSelectionManagerService } from '@univerjs/docs';
import { DocCanvasPopManagerService, IEditorService, IRangeSelectorService } from '@univerjs/docs-ui';
import { getCustomRangePosition, getEditingCustomRangePosition, IEditorBridgeService, SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
import { IZenZoneService } from '@univerjs/ui';
import { BehaviorSubject, Subject } from 'rxjs';
-import type { DocumentDataModel, ICustomRange, IDisposable, INeedCheckDisposable, ITextRange, Nullable, Workbook } from '@univerjs/core';
-import type { IBoundRectNoAngle } from '@univerjs/engine-render';
-import type { ISheetLocationBase } from '@univerjs/sheets';
-import type { ICanvasPopup } from '@univerjs/sheets-ui';
import { HyperLinkEditSourceType } from '../types/enums/edit-source';
import { CellLinkEdit } from '../views/CellLinkEdit';
import { CellLinkPopup } from '../views/CellLinkPopup';
@@ -235,6 +235,9 @@ export class SheetsHyperLinkPopupService extends Disposable {
}
this.endEditing();
},
+ onContextMenu: () => {
+ this.endEditing();
+ },
hiddenType: 'hide',
};
return popup;
diff --git a/packages/sheets-hyper-link-ui/src/views/CellLinkEdit/index.tsx b/packages/sheets-hyper-link-ui/src/views/CellLinkEdit/index.tsx
index 0d60773e13..46c55d284e 100644
--- a/packages/sheets-hyper-link-ui/src/views/CellLinkEdit/index.tsx
+++ b/packages/sheets-hyper-link-ui/src/views/CellLinkEdit/index.tsx
@@ -16,7 +16,7 @@
import type { DocumentDataModel, IUnitRangeWithName, Nullable, Workbook } from '@univerjs/core';
import type { ISetSelectionsOperationParams } from '@univerjs/sheets';
-import { BuildTextUtils, createInternalEditorID, CustomRangeType, DisposableCollection, DOCS_ZEN_EDITOR_UNIT_ID_KEY, FOCUSING_SHEET, generateRandomId, getOriginCellValue, ICommandService, IContextService, isValidRange, IUniverInstanceService, LocaleService, Tools, UniverInstanceType, useDependency } from '@univerjs/core';
+import { BuildTextUtils, ColorKit, createInternalEditorID, CustomRangeType, DisposableCollection, DOCS_ZEN_EDITOR_UNIT_ID_KEY, FOCUSING_SHEET, generateRandomId, ICommandService, IContextService, isValidRange, IUniverInstanceService, LocaleService, ThemeService, Tools, UniverInstanceType, useDependency } from '@univerjs/core';
import { Button, FormLayout, Input, Select } from '@univerjs/design';
import { DocSelectionManagerService } from '@univerjs/docs';
import { DocBackScrollRenderController, DocSelectionRenderService, RangeSelector } from '@univerjs/docs-ui';
@@ -59,6 +59,7 @@ export const CellLinkEdit = () => {
const markSelectionService = useDependency(IMarkSelectionService);
const textSelectionService = useDependency(DocSelectionManagerService);
const contextService = useDependency(IContextService);
+ const themeService = useDependency(ThemeService);
const docSelectionManagerService = useDependency(DocSelectionManagerService);
const customHyperLinkSidePanel = useMemo(() => {
@@ -90,8 +91,8 @@ export const CellLinkEdit = () => {
const worksheet = workbook?.getSheetBySheetId(editing.subUnitId);
const cell = worksheet?.getCellRaw(editing.row, editing.col);
const range = cell?.p?.body?.customRanges?.find((range) => range.rangeType === CustomRangeType.HYPERLINK && range.properties?.url);
- const cellValue = `${getOriginCellValue(cell) ?? ''}`;
- if (cell && (cell.p || cellValue)) {
+ const cellValue = cell?.v;
+ if (cell && (!BuildTextUtils.transform.isEmptyDocument(cell.p?.body?.dataStream) || cellValue)) {
setShowLabel(false);
}
link = {
@@ -172,9 +173,11 @@ export const CellLinkEdit = () => {
useEffect(() => {
let id: Nullable<string> = null;
- if (editing && editing.type === HyperLinkEditSourceType.VIEWING && Tools.isDefine(editing.row) && Tools.isDefine(editing.col)) {
- const worksheet = univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)?.getSheetBySheetId(editing.subUnitId);
+ if (editing && !editing.customRangeId && editing.type === HyperLinkEditSourceType.VIEWING && Tools.isDefine(editing.row) && Tools.isDefine(editing.col)) {
+ const workbook = univerInstanceService.getUnit<Workbook>(editing.unitId, UniverInstanceType.UNIVER_SHEET);
+ const worksheet = workbook?.getSheetBySheetId(editing.subUnitId);
const mergeInfo = worksheet?.getMergedCell(editing.row, editing.col);
+ const color = new ColorKit(themeService.getCurrentTheme().hyacinth500).toRgb();
id = markSelectionService.addShape(
{
range: mergeInfo ?? {
@@ -185,7 +188,7 @@ export const CellLinkEdit = () => {
},
style: {
hasAutoFill: false,
- fill: 'rgb(255, 189, 55, 0.35)',
+ fill: `rgb(${color.r}, ${color.g}, ${color.b}, 0.12)`,
strokeWidth: 1,
stroke: '#FFBD37',
widgets: {},
@@ -201,7 +204,7 @@ export const CellLinkEdit = () => {
markSelectionService.removeShape(id);
}
};
- }, [editing, markSelectionService]);
+ }, [editing, markSelectionService, themeService, univerInstanceService]);
const payloadInitial = useMemo(() => payload, [type]);
@@ -420,7 +423,7 @@ export const CellLinkEdit = () => {
isSingleChoice
value={payloadInitial}
onChange={handleRangeChange}
- disableInput={editing.type === HyperLinkEditSourceType.ZEN_EDITOR}
+ dialogOnly
onSelectorVisibleChange={async (visible) => {
if (visible) {
if (editing.type === HyperLinkEditSourceType.ZEN_EDITOR) {
diff --git a/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.tsx b/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.tsx
index f16ef6cd92..729d0fb6f0 100644
--- a/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.tsx
+++ b/packages/sheets-hyper-link-ui/src/views/CellLinkPopup/index.tsx
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import type { IHyperLinkPopup } from '../../services/popup.service';
import { DOCS_ZEN_EDITOR_UNIT_ID_KEY, ICommandService, LocaleService, useDependency, useObservable } from '@univerjs/core';
import { MessageType, Tooltip } from '@univerjs/design';
import { AllBorderSingle, CopySingle, LinkSingle, UnlinkSingle, WriteSingle, Xlsx } from '@univerjs/icons';
@@ -28,7 +29,6 @@ import { SheetsHyperLinkPopupService } from '../../services/popup.service';
import { SheetsHyperLinkResolverService } from '../../services/resolver.service';
import { HyperLinkEditSourceType } from '../../types/enums/edit-source';
import styles from './index.module.less';
-import type { IHyperLinkPopup } from '../../services/popup.service';
const iconsMap = {
[SheetHyperLinkType.URL]: <LinkSingle />,
diff --git a/packages/sheets-ui/src/common/utils.ts b/packages/sheets-ui/src/common/utils.ts
index 6c041ab7a5..55aa9cbd2b 100644
--- a/packages/sheets-ui/src/common/utils.ts
+++ b/packages/sheets-ui/src/common/utils.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-import { ObjectMatrix } from '@univerjs/core';
-import { SHEET_VIEWPORT_KEY, Vector2 } from '@univerjs/engine-render';
-import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '@univerjs/sheets';
import type { IAccessor, ICellData, IMutationInfo, IPosition, IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';
import type { IBoundRectNoAngle, IRender, Scene, SpreadsheetSkeleton } from '@univerjs/engine-render';
import type { ICollaborator } from '@univerjs/protocol';
import type { ISetRangeValuesMutationParams, ISheetLocation } from '@univerjs/sheets';
import type { ISheetSkeletonManagerParam } from '../services/sheet-skeleton-manager.service';
+import { ObjectMatrix } from '@univerjs/core';
+import { SHEET_VIEWPORT_KEY, Vector2 } from '@univerjs/engine-render';
+import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '@univerjs/sheets';
export function getUserListEqual(userList1: ICollaborator[], userList2: ICollaborator[]) {
if (userList1.length !== userList2.length) return false;
@@ -218,7 +218,31 @@ export function transformPosition2Offset(x: number, y: number, scene: Scene, ske
};
}
-// eslint-disable-next-line max-lines-per-function
+export function getCellRealRange(workbook: Workbook, worksheet: Worksheet, skeleton: SpreadsheetSkeleton, row: number, col: number) {
+ let actualRow = row;
+ let actualCol = col;
+
+ skeleton.overflowCache.forValue((r, c, range) => {
+ if (range.startRow <= actualRow && range.endRow >= actualRow && range.startColumn <= actualCol && range.endColumn >= actualCol) {
+ actualCol = c;
+ actualRow = r;
+ }
+ });
+
+ const actualCell = skeleton.getCellByIndex(actualRow, actualCol);
+
+ const location: ISheetLocation = {
+ unitId: workbook.getUnitId(),
+ subUnitId: worksheet.getSheetId(),
+ workbook,
+ worksheet,
+ row: actualCell.actualRow,
+ col: actualCell.actualColumn,
+ };
+
+ return location;
+}
+
export function getHoverCellPosition(currentRender: IRender, workbook: Workbook, worksheet: Worksheet, skeletonParam: ISheetSkeletonManagerParam, offsetX: number, offsetY: number) {
const { scene } = currentRender;
@@ -251,15 +275,7 @@ export function getHoverCellPosition(currentRender: IRender, workbook: Workbook,
col: originCell.actualColumn,
};
- const location: ISheetLocation = {
- unitId,
- subUnitId: sheetId,
- workbook,
- worksheet,
- row: actualCell.actualRow,
- col: actualCell.actualColumn,
- };
-
+ const location: ISheetLocation = getCellRealRange(workbook, worksheet, skeleton, actualRow, actualCol);
let anchorCell: IRange;
if (actualCell.mergeInfo) {
anchorCell = actualCell.mergeInfo;
diff --git a/packages/sheets-ui/src/controllers/editor/__tests__/end-edit.controller.spec.ts b/packages/sheets-ui/src/controllers/editor/__tests__/end-edit.controller.spec.ts
index 2cc356c500..9faa717b3a 100644
--- a/packages/sheets-ui/src/controllers/editor/__tests__/end-edit.controller.spec.ts
+++ b/packages/sheets-ui/src/controllers/editor/__tests__/end-edit.controller.spec.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
+import type { ICellData, IDocumentData, Injector, Univer, Workbook } from '@univerjs/core';
import { CellValueType, IContextService, IResourceLoaderService, LocaleService, LocaleType, Tools } from '@univerjs/core';
import { LexerTreeBuilder } from '@univerjs/engine-formula';
import { SpreadsheetSkeleton } from '@univerjs/engine-render';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import type { ICellData, IDocumentData, Injector, Univer, Workbook } from '@univerjs/core';
import { normalizeString } from '../../utils/char-tools';
import { getCellDataByInput, isRichText } from '../editing.render-controller';
import { createTestBed } from './create-test-bed';
diff --git a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
index 2e5c618451..762c10265c 100644
--- a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
@@ -16,6 +16,12 @@
/* eslint-disable max-lines-per-function */
+import type { DocumentDataModel, ICellData, ICommandInfo, IDisposable, IDocumentBody, IDocumentData, IPosition, IStyleData, Nullable, UnitModel, Workbook } from '@univerjs/core';
+import type { IRichTextEditingMutationParams } from '@univerjs/docs';
+import type { IEditorInputConfig } from '@univerjs/docs-ui';
+import type { DocumentSkeleton, IDocumentLayoutObject, IRenderContext, IRenderModule, Scene } from '@univerjs/engine-render';
+import type { WorkbookSelections } from '@univerjs/sheets';
+import type { IEditorBridgeServiceVisibleParam } from '../../services/editor-bridge.service';
import {
CellValueType, DEFAULT_EMPTY_DOCUMENT_VALUE, Direction, Disposable, DisposableCollection, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, EDITOR_ACTIVATED,
FOCUSING_EDITOR_BUT_HIDDEN,
@@ -55,15 +61,10 @@ import {
Rect,
ScrollBar,
} from '@univerjs/engine-render';
+
import { ClearSelectionFormatCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetActivateCommand, SheetsSelectionsService } from '@univerjs/sheets';
import { ILayoutService, KeyCode, SetEditorResizeOperation } from '@univerjs/ui';
import { distinctUntilChanged, filter } from 'rxjs';
-import type { DocumentDataModel, ICellData, ICommandInfo, IDisposable, IDocumentBody, IDocumentData, IPosition, IStyleData, Nullable, UnitModel, Workbook } from '@univerjs/core';
-import type { IRichTextEditingMutationParams } from '@univerjs/docs';
-import type { IEditorInputConfig } from '@univerjs/docs-ui';
-
-import type { DocumentSkeleton, IDocumentLayoutObject, IRenderContext, IRenderModule, Scene } from '@univerjs/engine-render';
-import type { WorkbookSelections } from '@univerjs/sheets';
import { getEditorObject } from '../../basics/editor/get-editor-object';
import { MoveSelectionCommand, MoveSelectionEnterAndTabCommand } from '../../commands/commands/set-selection.command';
import { SetCellEditVisibleArrowOperation, SetCellEditVisibleOperation, SetCellEditVisibleWithF2Operation } from '../../commands/operations/cell-edit.operation';
@@ -73,7 +74,6 @@ import styles from '../../views/sheet-container/index.module.less';
import { MOVE_SELECTION_KEYCODE_LIST } from '../shortcuts/editor.shortcut';
import { extractStringFromForceString, isForceString } from '../utils/cell-tools';
import { normalizeString } from '../utils/char-tools';
-import type { IEditorBridgeServiceVisibleParam } from '../../services/editor-bridge.service';
const HIDDEN_EDITOR_POSITION = -1000;
diff --git a/packages/sheets-ui/src/controllers/render-controllers/scroll.render-controller.ts b/packages/sheets-ui/src/controllers/render-controllers/scroll.render-controller.ts
index 74b4bde9f5..b885907242 100644
--- a/packages/sheets-ui/src/controllers/render-controllers/scroll.render-controller.ts
+++ b/packages/sheets-ui/src/controllers/render-controllers/scroll.render-controller.ts
@@ -14,6 +14,13 @@
* limitations under the License.
*/
+import type { IFreeze, IRange, IWorksheetData, Nullable, Workbook } from '@univerjs/core';
+import type { IRenderContext, IRenderModule, IScrollObserverParam, IWheelEvent } from '@univerjs/engine-render';
+import type { ISetSelectionsOperationParams, SheetsSelectionsService } from '@univerjs/sheets';
+import type { IExpandSelectionCommandParams } from '../../commands/commands/set-selection.command';
+import type { IScrollState, IScrollStateSearchParam, IViewportScrollState } from '../../services/scroll-manager.service';
+import type { ISheetSkeletonManagerParam } from '../../services/sheet-skeleton-manager.service';
+
import {
Direction,
Disposable,
@@ -25,18 +32,11 @@ import {
RANGE_TYPE, toDisposable } from '@univerjs/core';
import { IRenderManagerService, PointerInput, RENDER_CLASS_TYPE, SHEET_VIEWPORT_KEY } from '@univerjs/engine-render';
import { getSelectionsService, ScrollToCellOperation, SetSelectionsOperation } from '@univerjs/sheets';
-import type { IFreeze, IRange, IWorksheetData, Nullable, Workbook } from '@univerjs/core';
-import type { IRenderContext, IRenderModule, IScrollObserverParam, IWheelEvent } from '@univerjs/engine-render';
-import type { ISetSelectionsOperationParams, SheetsSelectionsService } from '@univerjs/sheets';
-
import { ScrollCommand, SetScrollRelativeCommand } from '../../commands/commands/set-scroll.command';
import { ExpandSelectionCommand, MoveSelectionCommand, MoveSelectionEnterAndTabCommand } from '../../commands/commands/set-selection.command';
import { SheetScrollManagerService } from '../../services/scroll-manager.service';
import { SheetSkeletonManagerService } from '../../services/sheet-skeleton-manager.service';
import { getSheetObject } from '../utils/component-tools';
-import type { IExpandSelectionCommandParams } from '../../commands/commands/set-selection.command';
-import type { IScrollState, IScrollStateSearchParam, IViewportScrollState } from '../../services/scroll-manager.service';
-import type { ISheetSkeletonManagerParam } from '../../services/sheet-skeleton-manager.service';
const SHEET_NAVIGATION_COMMANDS = [MoveSelectionCommand.id, MoveSelectionEnterAndTabCommand.id];
@@ -475,7 +475,7 @@ export class SheetsScrollRenderController extends Disposable implements IRenderM
}
const bounds = viewport.getBounding();
- return skeleton.getRowColumnSegment(bounds);
+ return skeleton.getRowColumnSegmentByViewBound(bounds.viewBound);
}
// eslint-disable-next-line max-lines-per-function, complexity
diff --git a/packages/sheets-ui/src/controllers/render-controllers/sheet.render-controller.ts b/packages/sheets-ui/src/controllers/render-controllers/sheet.render-controller.ts
index d52a814421..d81e37dad5 100644
--- a/packages/sheets-ui/src/controllers/render-controllers/sheet.render-controller.ts
+++ b/packages/sheets-ui/src/controllers/render-controllers/sheet.render-controller.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import type { ICommandInfo, IExecutionOptions, IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';
+import type { IAfterRender$Info, IBasicFrameInfo, IExtendFrameInfo, IRenderContext, IRenderModule, ISummaryFrameInfo, ITimeMetric, IViewportInfos, Scene } from '@univerjs/engine-render';
import { CommandType, ICommandService, IContextService, Inject, Optional, Rectangle, RxDisposable } from '@univerjs/core';
import {
Rect,
@@ -28,8 +30,6 @@ import {
import { COMMAND_LISTENER_SKELETON_CHANGE, COMMAND_LISTENER_VALUE_CHANGE, MoveRangeMutation, SetRangeValuesMutation, SetWorksheetActiveOperation } from '@univerjs/sheets';
import { ITelemetryService } from '@univerjs/telemetry';
import { Subject, withLatestFrom } from 'rxjs';
-import type { ICommandInfo, IExecutionOptions, IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';
-import type { IAfterRender$Info, IBasicFrameInfo, IExtendFrameInfo, IRenderContext, IRenderModule, ISummaryFrameInfo, ITimeMetric, IViewportInfos, Scene } from '@univerjs/engine-render';
import {
SHEET_COMPONENT_HEADER_LAYER_INDEX,
diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.ts
index 4ae2e1c39e..8677e5ef1d 100644
--- a/packages/sheets-ui/src/index.ts
+++ b/packages/sheets-ui/src/index.ts
@@ -107,6 +107,7 @@ export { attachPrimaryWithCoord, attachSelectionWithCoord } from './services/sel
export { SELECTION_SHAPE_DEPTH } from './services/selection/const';
export { menuSchema } from './controllers/menu.schema';
+export { getCellRealRange } from './common/utils';
// #region - all commands
export { AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeVerticalCommand } from './commands/commands/add-worksheet-merge.command';
diff --git a/packages/sheets-ui/src/services/canvas-pop-manager.service.ts b/packages/sheets-ui/src/services/canvas-pop-manager.service.ts
index 40398b3e52..64ea5592a7 100644
--- a/packages/sheets-ui/src/services/canvas-pop-manager.service.ts
+++ b/packages/sheets-ui/src/services/canvas-pop-manager.service.ts
@@ -29,7 +29,7 @@ import { getViewportByCell, transformBound2OffsetBound } from '../common/utils';
import { ISheetSelectionRenderService } from './selection/base-selection-render.service';
import { SheetSkeletonManagerService } from './sheet-skeleton-manager.service';
-export interface ICanvasPopup extends Pick<IPopup, 'direction' | 'excludeOutside' | 'componentKey' | 'offset' | 'onClickOutside' | 'hideOnInvisible' | 'hiddenType' | 'onClick'> {
+export interface ICanvasPopup extends Omit<IPopup, 'anchorRect' | 'anchorRect$' | 'unitId' | 'subUnitId' | 'canvasElement'> {
mask?: boolean;
extraProps?: Record<string, any>;
}
diff --git a/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts b/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts
index e854b3c0f4..48b980dd4f 100644
--- a/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts
+++ b/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import { createIdentifier, Disposable, Inject, IUniverInstanceService, ThemeService, Tools, UniverInstanceType } from '@univerjs/core';
-import { IRenderManagerService } from '@univerjs/engine-render';
import type { Workbook } from '@univerjs/core';
import type { ISelectionWithStyle } from '@univerjs/sheets';
+import { createIdentifier, Disposable, Inject, IUniverInstanceService, ThemeService, Tools, UniverInstanceType } from '@univerjs/core';
+import { IRenderManagerService } from '@univerjs/engine-render';
import { ISheetSelectionRenderService } from '../selection/base-selection-render.service';
import { SELECTION_SHAPE_DEPTH } from '../selection/const';
diff --git a/packages/sheets-ui/src/services/selection/selection-control.ts b/packages/sheets-ui/src/services/selection/selection-control.ts
index 698edda214..17ad954e47 100644
--- a/packages/sheets-ui/src/services/selection/selection-control.ts
+++ b/packages/sheets-ui/src/services/selection/selection-control.ts
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+import type { IRangeWithCoord, ISelectionCellWithMergeInfo, Nullable, ThemeService } from '@univerjs/core';
+import type { IObjectFullState, IRectProps, Scene } from '@univerjs/engine-render';
+import type { ISelectionStyle, ISelectionWidgetConfig, ISelectionWithCoordAndStyle } from '@univerjs/sheets';
import { ColorKit, Disposable, RANGE_TYPE, toDisposable } from '@univerjs/core';
import { cancelRequestFrame, DashedRect, FIX_ONE_PIXEL_BLUR_OFFSET, Group, Rect, requestNewFrame, TRANSFORM_CHANGE_OBSERVABLE_TYPE } from '@univerjs/engine-render';
import {
@@ -22,9 +25,6 @@ import {
SELECTION_CONTROL_BORDER_BUFFER_WIDTH,
} from '@univerjs/sheets';
import { BehaviorSubject, Subject } from 'rxjs';
-import type { IRangeWithCoord, ISelectionCellWithMergeInfo, Nullable, ThemeService } from '@univerjs/core';
-import type { IObjectFullState, IRectProps, Scene } from '@univerjs/engine-render';
-import type { ISelectionStyle, ISelectionWidgetConfig, ISelectionWithCoordAndStyle } from '@univerjs/sheets';
import { SHEET_COMPONENT_HEADER_SELECTION_LAYER_INDEX, SHEET_COMPONENT_SELECTION_LAYER_INDEX } from '../../common/keys';
import { SelectionRenderModel } from './selection-render-model';
diff --git a/packages/sheets-zen-editor/src/commands/commands/zen-editor.command.ts b/packages/sheets-zen-editor/src/commands/commands/zen-editor.command.ts
index 873c7be27a..bdd50a2e00 100644
--- a/packages/sheets-zen-editor/src/commands/commands/zen-editor.command.ts
+++ b/packages/sheets-zen-editor/src/commands/commands/zen-editor.command.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+import type { ICommand, Workbook } from '@univerjs/core';
import { CommandType, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DocumentDataModel, IUniverInstanceService, Tools, UniverInstanceType } from '@univerjs/core';
import { IEditorService } from '@univerjs/docs-ui';
import { IRenderManagerService } from '@univerjs/engine-render';
import { EditingRenderController, IEditorBridgeService } from '@univerjs/sheets-ui';
import { IZenZoneService } from '@univerjs/ui';
-import type { ICommand, Workbook } from '@univerjs/core';
export const OpenZenEditorCommand: ICommand = {
id: 'zen-editor.command.open-zen-editor',
diff --git a/packages/sheets-zen-editor/src/controllers/menu.schema.ts b/packages/sheets-zen-editor/src/controllers/menu.schema.ts
index 33446dc18c..5e72fe921c 100644
--- a/packages/sheets-zen-editor/src/controllers/menu.schema.ts
+++ b/packages/sheets-zen-editor/src/controllers/menu.schema.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { ContextMenuGroup, ContextMenuPosition } from '@univerjs/ui';
import type { MenuSchemaType } from '@univerjs/ui';
+import { ContextMenuGroup, ContextMenuPosition } from '@univerjs/ui';
import { OpenZenEditorCommand } from '../commands/commands/zen-editor.command';
import { ZenEditorMenuItemFactory } from '../views/menu';
diff --git a/packages/sheets-zen-editor/src/controllers/shortcuts/zen-editor.shortcut.ts b/packages/sheets-zen-editor/src/controllers/shortcuts/zen-editor.shortcut.ts
index c921f20c0c..1102a5a249 100644
--- a/packages/sheets-zen-editor/src/controllers/shortcuts/zen-editor.shortcut.ts
+++ b/packages/sheets-zen-editor/src/controllers/shortcuts/zen-editor.shortcut.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
+import type { IContextService } from '@univerjs/core';
import { EDITOR_ACTIVATED, FOCUSING_DOC, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR } from '@univerjs/core';
import { type IShortcutItem, KeyCode, MetaKeys } from '@univerjs/ui';
-import type { IContextService } from '@univerjs/core';
import { CancelZenEditCommand, ConfirmZenEditCommand } from '../../commands/commands/zen-editor.command';
diff --git a/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts b/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts
index 33feafa0f6..9a8d0d16cf 100644
--- a/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts
+++ b/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+import type { ITextRange } from '@univerjs/core';
+import type { IDocObjectParam } from '@univerjs/docs-ui';
+import type { Viewport } from '@univerjs/engine-render';
import {
DOCS_ZEN_EDITOR_UNIT_ID_KEY,
LifecycleStages,
@@ -23,11 +26,8 @@ import {
import { VIEWPORT_KEY as DOC_VIEWPORT_KEY, DocBackScrollRenderController } from '@univerjs/docs-ui';
import { IRenderManagerService } from '@univerjs/engine-render';
import { getEditorObject } from '@univerjs/sheets-ui';
-import { takeUntil } from 'rxjs';
-import type { ITextRange } from '@univerjs/core';
-import type { IDocObjectParam } from '@univerjs/docs-ui';
-import type { Viewport } from '@univerjs/engine-render';
+import { takeUntil } from 'rxjs';
import { IZenEditorManagerService } from '../services/zen-editor.service';
@OnLifecycle(LifecycleStages.Steady, ZenEditorController)
diff --git a/packages/sheets-zen-editor/src/plugin.ts b/packages/sheets-zen-editor/src/plugin.ts
index 256e86ef1b..a616da9513 100644
--- a/packages/sheets-zen-editor/src/plugin.ts
+++ b/packages/sheets-zen-editor/src/plugin.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
import type { Dependency } from '@univerjs/core';
+import type { IUniverSheetsZenEditorConfig } from './controllers/config.schema';
+import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';
import { ZenEditorController } from './controllers/zen-editor.controller';
import { ZenEditorUIController } from './controllers/zen-editor-ui.controller';
import { IZenEditorManagerService, ZenEditorManagerService } from './services/zen-editor.service';
-import type { IUniverSheetsZenEditorConfig } from './controllers/config.schema';
export class UniverSheetsZenEditorPlugin extends Plugin {
static override pluginName = 'SHEET_ZEN_EDITOR_PLUGIN';
diff --git a/packages/sheets-zen-editor/src/views/menu.ts b/packages/sheets-zen-editor/src/views/menu.ts
index 0625101720..055a04399d 100644
--- a/packages/sheets-zen-editor/src/views/menu.ts
+++ b/packages/sheets-zen-editor/src/views/menu.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission } from '@univerjs/sheets';
+import type { IAccessor } from '@univerjs/core';
+import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission } from '@univerjs/sheets';
import { getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
import { type IMenuButtonItem, MenuItemType } from '@univerjs/ui';
-import type { IAccessor } from '@univerjs/core';
import { OpenZenEditorCommand } from '../commands/commands/zen-editor.command';
export function ZenEditorMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
diff --git a/packages/sheets-zen-editor/src/views/zen-editor/ZenEditor.tsx b/packages/sheets-zen-editor/src/views/zen-editor/ZenEditor.tsx
index b62cc47551..7311b60942 100644
--- a/packages/sheets-zen-editor/src/views/zen-editor/ZenEditor.tsx
+++ b/packages/sheets-zen-editor/src/views/zen-editor/ZenEditor.tsx
@@ -14,13 +14,13 @@
* limitations under the License.
*/
+import type { IDocumentData } from '@univerjs/core';
import { DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DocumentFlavor, ICommandService, useDependency } from '@univerjs/core';
import { IEditorService } from '@univerjs/docs-ui';
import { CheckMarkSingle, CloseSingle } from '@univerjs/icons';
import clsx from 'clsx';
-import React, { useEffect, useRef } from 'react';
-import type { IDocumentData } from '@univerjs/core';
+import React, { useEffect, useRef } from 'react';
import { CancelZenEditCommand, ConfirmZenEditCommand } from '../../commands/commands/zen-editor.command';
import { IZenEditorManagerService } from '../../services/zen-editor.service';
diff --git a/packages/ui/src/services/message/desktop-message.service.ts b/packages/ui/src/services/message/desktop-message.service.ts
index c29f650967..1206f826ba 100644
--- a/packages/ui/src/services/message/desktop-message.service.ts
+++ b/packages/ui/src/services/message/desktop-message.service.ts
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-import { Message } from '@univerjs/design';
-import canUseDom from 'rc-util/lib/Dom/canUseDom';
import type { IDisposable } from '@univerjs/core';
-
import type { IMessageOptions, IMessageProps } from '@univerjs/design';
import type { IMessageService } from './message.service';
+import { Message } from '@univerjs/design';
+import canUseDom from 'rc-util/lib/Dom/canUseDom';
+
export class DesktopMessageService implements IMessageService, IDisposable {
// in node environment, document is undefined
protected _portalContainer: HTMLElement | undefined = canUseDom() ? document.body : undefined;
diff --git a/packages/ui/src/services/popup/canvas-popup.service.ts b/packages/ui/src/services/popup/canvas-popup.service.ts
index 1d9f8e879f..42fb7e011a 100644
--- a/packages/ui/src/services/popup/canvas-popup.service.ts
+++ b/packages/ui/src/services/popup/canvas-popup.service.ts
@@ -15,16 +15,14 @@
*/
import type { Nullable } from '@univerjs/core';
-import { createIdentifier, Disposable, Tools } from '@univerjs/core';
import type { IRectPopupProps } from '@univerjs/design';
import type { IBoundRectNoAngle } from '@univerjs/engine-render';
import type { Observable } from 'rxjs';
+import { createIdentifier, Disposable, Tools } from '@univerjs/core';
import { BehaviorSubject } from 'rxjs';
-export interface IPopup extends Pick<IRectPopupProps, 'direction' | 'excludeOutside' | 'onClickOutside' > {
- anchorRect: Nullable<IBoundRectNoAngle>;
+export interface IPopup extends Omit<IRectPopupProps, 'children' | 'hidden'> {
anchorRect$: Observable<IBoundRectNoAngle>;
- excludeRects?: IBoundRectNoAngle[];
excludeRects$?: Observable<IBoundRectNoAngle[]>;
componentKey: string;
@@ -35,9 +33,6 @@ export interface IPopup extends Pick<IRectPopupProps, 'direction' | 'excludeOuts
canvasElement: HTMLCanvasElement;
hideOnInvisible?: boolean;
hiddenType?: 'hide' | 'destroy';
- onPointerEnter?: () => void;
- onPointerLeave?: () => void;
- onClick?: () => void;
}
export interface ICanvasPopupService {
diff --git a/packages/ui/src/views/components/popup/CanvasPopup.tsx b/packages/ui/src/views/components/popup/CanvasPopup.tsx
index 30917be45c..1085ea156e 100644
--- a/packages/ui/src/views/components/popup/CanvasPopup.tsx
+++ b/packages/ui/src/views/components/popup/CanvasPopup.tsx
@@ -14,14 +14,14 @@
* limitations under the License.
*/
+import type { IPopup } from '../../../services/popup/canvas-popup.service';
import { useDependency } from '@univerjs/core';
-import React, { useEffect, useMemo, useState } from 'react';
import { RectPopup } from '@univerjs/design';
+import React, { useEffect, useMemo, useState } from 'react';
import { animationFrameScheduler, throttleTime } from 'rxjs';
-import { ICanvasPopupService } from '../../../services/popup/canvas-popup.service';
-import { useObservable } from '../../../components/hooks/observable';
import { ComponentManager } from '../../../common';
-import type { IPopup } from '../../../services/popup/canvas-popup.service';
+import { useObservable } from '../../../components/hooks/observable';
+import { ICanvasPopupService } from '../../../services/popup/canvas-popup.service';
interface ISingleCanvasPopupProps {
popup: IPopup;
@@ -77,9 +77,10 @@ const SingleCanvasPopup = ({ popup, children }: ISingleCanvasPopupProps) => {
onClickOutside={popup.onClickOutside}
excludeOutside={popup.excludeOutside}
excludeRects={excludeRects}
- onPinterEnter={popup.onPointerEnter}
+ onPointerEnter={popup.onPointerEnter}
onPointerLeave={popup.onPointerLeave}
onClick={popup.onClick}
+ onContextMenu={popup.onContextMenu}
>
{children}
</RectPopup>