@univerjs/sheets-formula-ui 1.0.0-alpha.2 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +843 -383
- package/lib/es/index.js +845 -386
- package/lib/index.js +845 -386
- package/lib/types/index.d.ts +1 -0
- package/lib/types/views/formula-editor/formula-embed-integration.service.d.ts +59 -0
- package/lib/types/views/formula-editor/hooks/use-focus.d.ts +11 -0
- package/lib/types/views/formula-editor/hooks/use-formula-selection.d.ts +22 -0
- package/lib/types/views/formula-editor/hooks/use-highlight.d.ts +10 -3
- package/lib/types/views/formula-editor/hooks/use-left-and-right-arrow.d.ts +8 -1
- package/lib/types/views/formula-editor/hooks/use-refactor-effect.d.ts +1 -1
- package/lib/types/views/formula-editor/hooks/use-sheet-selection-change.d.ts +33 -0
- package/lib/types/views/formula-editor/index.d.ts +2 -1
- package/lib/umd/index.js +4 -3
- package/package.json +14 -14
package/lib/types/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { ReferenceAbsoluteOperation } from './commands/operations/reference-abso
|
|
|
22
22
|
export { SearchFunctionOperation } from './commands/operations/search-function.operation';
|
|
23
23
|
export type { IUniverSheetsFormulaUIConfig } from './config/config';
|
|
24
24
|
export { FormulaReorderController } from './controllers/formula-reorder.controller';
|
|
25
|
+
export { menuSchema as SheetsFormulaUIMenuSchema } from './menu/schema';
|
|
25
26
|
export { UniverSheetsFormulaUIPlugin } from './plugin';
|
|
26
27
|
export { FORMULA_PROMPT_ACTIVATED } from './services/prompt.service';
|
|
27
28
|
export { GlobalRangeSelectorService } from './services/range-selector.service';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IDisposable } from '@univerjs/core';
|
|
17
|
+
export declare const FORMULA_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
|
|
18
|
+
export declare const FORMULA_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE = "data-embed-runtime-focus-role";
|
|
19
|
+
export declare const FORMULA_EMBED_ID_ATTRIBUTE = "data-embed-id";
|
|
20
|
+
export declare const FORMULA_EMBED_HOST_UNIT_ID_ATTRIBUTE = "data-embed-host-unit-id";
|
|
21
|
+
export declare const FORMULA_EMBED_CHILD_UNIT_ID_ATTRIBUTE = "data-embed-child-unit-id";
|
|
22
|
+
export interface IFormulaEmbedRuntimeDomScope {
|
|
23
|
+
embedId: string;
|
|
24
|
+
hostUnitId?: string;
|
|
25
|
+
childUnitId?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface IFormulaEmbedRuntimeFocusCoordinator {
|
|
28
|
+
resolveRuntimeScopeByChildUnitId(childUnitId: string): IFormulaEmbedRuntimeDomScope | undefined;
|
|
29
|
+
acquireLease(options: {
|
|
30
|
+
embedId: string;
|
|
31
|
+
role: string;
|
|
32
|
+
owner: string;
|
|
33
|
+
hostUnitId?: string;
|
|
34
|
+
childUnitId?: string;
|
|
35
|
+
associatedChildUnitIds?: string[];
|
|
36
|
+
}): IDisposable;
|
|
37
|
+
registerElement(options: {
|
|
38
|
+
embedId: string;
|
|
39
|
+
role: string;
|
|
40
|
+
element: HTMLElement;
|
|
41
|
+
}): IDisposable;
|
|
42
|
+
}
|
|
43
|
+
export declare const IFormulaEmbedRuntimeFocusCoordinator: import("@wendellhu/redi").IdentifierDecorator<IFormulaEmbedRuntimeFocusCoordinator>;
|
|
44
|
+
export interface IFormulaEmbedInteractionBoundaryService {
|
|
45
|
+
registerOwnedElement(embedId: string, element: Element): IDisposable;
|
|
46
|
+
}
|
|
47
|
+
export declare const IFormulaEmbedInteractionBoundaryService: import("@wendellhu/redi").IdentifierDecorator<IFormulaEmbedInteractionBoundaryService>;
|
|
48
|
+
interface IRegisterFormulaEditorRuntimePortalOptions {
|
|
49
|
+
embedId: string;
|
|
50
|
+
editorId: string;
|
|
51
|
+
ownerDocument?: Document;
|
|
52
|
+
interactionBoundaryService?: IFormulaEmbedInteractionBoundaryService;
|
|
53
|
+
focusCoordinator?: IFormulaEmbedRuntimeFocusCoordinator;
|
|
54
|
+
}
|
|
55
|
+
export declare function registerFormulaEditorRuntimePortal(options: IRegisterFormulaEditorRuntimePortalOptions): IDisposable;
|
|
56
|
+
export declare function resolveFormulaEmbedRuntimeDomScope(root: HTMLElement | null | undefined): IFormulaEmbedRuntimeDomScope | undefined;
|
|
57
|
+
export declare function resolveActiveFormulaEmbedRuntimeDomScope(ownerDocument: Document | undefined): IFormulaEmbedRuntimeDomScope | undefined;
|
|
58
|
+
export declare function isEventTargetInSameFormulaEmbedInteractionBoundary(left: EventTarget | null | undefined, right: EventTarget | null | undefined): boolean;
|
|
59
|
+
export {};
|
|
@@ -14,4 +14,15 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Editor } from '@univerjs/docs-ui';
|
|
17
|
+
import { IEditorService } from '@univerjs/docs-ui';
|
|
18
|
+
export declare function focusFormulaEditor(editorService: Pick<IEditorService, 'focus'>, editor?: Pick<Editor, 'getEditorId' | 'getSelectionRanges' | 'setSelectionRanges' | 'getDocumentData' | 'docSelectionRenderService'> & {
|
|
19
|
+
editorDOM?: HTMLElement;
|
|
20
|
+
}, offset?: number): void;
|
|
21
|
+
export declare function shouldSkipFormulaEditorMouseUpFocus(_target: EventTarget | null): boolean;
|
|
22
|
+
export declare function shouldRefocusFormulaEditorOnMouseUp(options: {
|
|
23
|
+
target: EventTarget | null;
|
|
24
|
+
isFocusing: boolean | undefined;
|
|
25
|
+
isPointerSelecting: boolean | undefined;
|
|
26
|
+
}): boolean;
|
|
27
|
+
export declare function hasActiveFormulaEmbedInteraction(scopeElement: HTMLElement | null | undefined): boolean;
|
|
17
28
|
export declare const useFocus: (editor?: Editor) => (offset?: number) => void;
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import type { IAccessor } from '@univerjs/core';
|
|
17
|
+
import type { Editor } from '@univerjs/docs-ui';
|
|
18
|
+
export declare function resolveFormulaSelectionDataStream(accssor: IAccessor, editor?: Pick<Editor, 'getDocumentData'>, editorId?: string): {
|
|
19
|
+
dataStream: string;
|
|
20
|
+
offset: number;
|
|
21
|
+
} | undefined;
|
|
16
22
|
export declare enum FormulaSelectingType {
|
|
17
23
|
NOT_SELECT = 0,
|
|
18
24
|
NEED_ADD = 1,
|
|
@@ -21,7 +27,23 @@ export declare enum FormulaSelectingType {
|
|
|
21
27
|
EDIT_OTHER_WORKBOOK_REFERENCE = 4
|
|
22
28
|
}
|
|
23
29
|
export declare function shouldSkipReferenceEditingByPointer(isDisabledByPointer: boolean, disableOnClick?: boolean): boolean;
|
|
30
|
+
export declare function resolveFormulaSelectionWorkbook<TWorkbook>(currentWorkbook: TWorkbook | null | undefined, fallbackWorkbook: TWorkbook | null | undefined): TWorkbook | undefined;
|
|
31
|
+
export declare function resolveFormulaSelectionCursorIndex(activeRange: {
|
|
32
|
+
collapsed?: boolean;
|
|
33
|
+
startOffset?: number;
|
|
34
|
+
} | undefined, dataStream: string): number;
|
|
35
|
+
export declare function getSelectionAfterLaggingFormulaInput(dataStream: string, selection: {
|
|
36
|
+
collapsed?: boolean;
|
|
37
|
+
startOffset?: number;
|
|
38
|
+
endOffset?: number;
|
|
39
|
+
} | undefined, content: string): {
|
|
40
|
+
startOffset: number;
|
|
41
|
+
endOffset: number;
|
|
42
|
+
collapsed: true;
|
|
43
|
+
} | undefined;
|
|
44
|
+
export declare function resolveFormulaSelectingIntent(adding: boolean, editing: boolean): FormulaSelectingType;
|
|
24
45
|
export declare function useFormulaSelecting(opts: {
|
|
46
|
+
editor?: Editor;
|
|
25
47
|
editorId: string;
|
|
26
48
|
isFocus: boolean;
|
|
27
49
|
disableOnClick?: boolean;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { ITextRange, ITextRun, Workbook } from '@univerjs/core';
|
|
16
|
+
import type { IDocumentBody, ITextRange, ITextRun, Workbook } from '@univerjs/core';
|
|
17
17
|
import type { Editor } from '@univerjs/docs-ui';
|
|
18
18
|
import type { ISequenceNode } from '@univerjs/engine-formula';
|
|
19
19
|
import type { ISelectionWithStyle, SheetsSelectionsService } from '@univerjs/sheets';
|
|
@@ -47,8 +47,15 @@ export declare function calcHighlightRanges(opts: {
|
|
|
47
47
|
* @param {string} subUnitId 打开面板的时候传入的 sheetId
|
|
48
48
|
* @param {IRefSelection[]} refSelections
|
|
49
49
|
*/
|
|
50
|
-
export declare function useSheetHighlight(unitId: string, subUnitId: string): (refSelections: IRefSelection[], editor?: Editor) => void;
|
|
51
|
-
export declare function useDocHight(_leadingCharacter?: string): (editor: Editor, sequenceNodes: INode[], isNeedResetSelection?: any, newSelections?: ITextRange[]) => IRefSelection[];
|
|
50
|
+
export declare function useSheetHighlight(unitId: string, subUnitId: string): (refSelections: IRefSelection[], editor?: Editor, isEnd?: any) => void;
|
|
51
|
+
export declare function useDocHight(_leadingCharacter?: string): (editor: Editor, sequenceNodes: INode[], isNeedResetSelection?: any, newSelections?: ITextRange[], sourceText?: string) => IRefSelection[];
|
|
52
|
+
/**
|
|
53
|
+
* ReplaceTextRunsCommand shifts the editor's existing structural metadata when text changes.
|
|
54
|
+
* Its replacement body must therefore contain only inline formula data; carrying paragraphs
|
|
55
|
+
* or section breaks copied from the old snapshot would leave their indexes stale.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createFormulaHighlightBody(dataStream: string, textRuns: ITextRun[]): IDocumentBody;
|
|
58
|
+
export declare function getFormulaHighlightDataStream(leadingCharacter: string, sequenceNodes: Array<ISequenceNode | string>, sourceText?: string): string;
|
|
52
59
|
interface IColorMap {
|
|
53
60
|
formulaRefColors: string[];
|
|
54
61
|
numberColor: string;
|
|
@@ -16,4 +16,11 @@
|
|
|
16
16
|
import type { Editor } from '@univerjs/docs-ui';
|
|
17
17
|
import { KeyCode, MetaKeys } from '@univerjs/ui';
|
|
18
18
|
import { FormulaSelectingType } from './use-formula-selection';
|
|
19
|
-
export declare
|
|
19
|
+
export declare function shouldMoveFormulaSelectionFromCurrentSelection(selectingType: FormulaSelectingType, refSelectionCount: number): boolean;
|
|
20
|
+
export interface IFormulaEditorInteractionOwnerOptions {
|
|
21
|
+
fxBarFocused?: boolean;
|
|
22
|
+
formulaBarEditorId?: string;
|
|
23
|
+
normalEditorId?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function isFormulaEditorInteractionOwner(focusEditorId: string | null | undefined | void, editorId: string, options?: IFormulaEditorInteractionOwnerOptions): boolean;
|
|
26
|
+
export declare const useLeftAndRightArrow: (isNeed: boolean, shouldMoveSelection: FormulaSelectingType, editor?: Editor, onMoveInEditor?: (keyCode: KeyCode, metaKey?: MetaKeys) => void, getRefSelectionCount?: () => number) => void;
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export declare const useRefactorEffect: (isNeed: boolean, selecting: boolean, unitId: string, editorId: string, disableContextMenu?: boolean) => void;
|
|
16
|
+
export declare const useRefactorEffect: (isNeed: boolean, selecting: boolean | number, unitId: string, editorId: string, disableContextMenu?: boolean) => void;
|
|
@@ -17,15 +17,48 @@ import type { IRange } from '@univerjs/core';
|
|
|
17
17
|
import type { Editor } from '@univerjs/docs-ui';
|
|
18
18
|
import type { RefObject } from 'react';
|
|
19
19
|
import type { IRefSelection } from './use-highlight';
|
|
20
|
+
import { LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
20
21
|
import { FormulaSelectingType } from './use-formula-selection';
|
|
22
|
+
export declare const prepareSelectionChangeContext: (opts: {
|
|
23
|
+
editor?: Editor;
|
|
24
|
+
lexerTreeBuilder: LexerTreeBuilder;
|
|
25
|
+
}) => {
|
|
26
|
+
nodeIndex: number;
|
|
27
|
+
updatingRefIndex: number;
|
|
28
|
+
formulaText: string;
|
|
29
|
+
sequenceNodes: (string | import("@univerjs/engine-formula").ISequenceNode)[];
|
|
30
|
+
offset: number;
|
|
31
|
+
} | undefined;
|
|
32
|
+
export declare function getSequenceNodeCharAtOffset(sequenceNodes: (string | {
|
|
33
|
+
token: string;
|
|
34
|
+
})[], offset: number): string | undefined;
|
|
35
|
+
export declare function isFormulaReferenceAddingContext(sequenceNodes: (string | {
|
|
36
|
+
token: string;
|
|
37
|
+
})[], offset: number): boolean;
|
|
38
|
+
export declare function isFormulaReferenceAddingTextContext(formulaText: string, offset: number): boolean;
|
|
39
|
+
export declare function insertFormulaReferenceText(formulaText: string, refText: string, offset: number): string;
|
|
40
|
+
export declare function shouldSkipFormulaReferenceUpdate(isAdd: boolean, selectionCount: number): boolean;
|
|
21
41
|
export declare function getSelectionsForFormulaRefUpdate(selections: IRange[], updatingRefIndex: number, isCtrlAddMode?: boolean): {
|
|
22
42
|
orderedSelections: IRange[];
|
|
23
43
|
insertedSelection?: IRange;
|
|
24
44
|
};
|
|
45
|
+
export declare function getLastFormulaSelection(selections: IRange[]): IRange | undefined;
|
|
46
|
+
export interface ISelectionChangeDuplicateEndGuard<TSelection> {
|
|
47
|
+
shouldSkip(selections: TSelection[], isEnd: boolean): boolean;
|
|
48
|
+
reset(): void;
|
|
49
|
+
}
|
|
50
|
+
export declare function getFormulaSelectionIdentityKey(selection: unknown): string;
|
|
51
|
+
export declare function isSameFormulaSelection(first: unknown, second: unknown): boolean;
|
|
52
|
+
export declare function getSharedSelectionChangeDuplicateEndGuard(key: string): ISelectionChangeDuplicateEndGuard<IRange>;
|
|
53
|
+
export declare function createSelectionChangeDuplicateEndGuard<TSelection>(): ISelectionChangeDuplicateEndGuard<TSelection>;
|
|
25
54
|
export declare function createSelectionChangeHandler<TSelection>(opts: {
|
|
26
55
|
initialSelectionsCount: number;
|
|
27
56
|
onSelectionsChange: (selections: TSelection[], isEnd: boolean, isCtrlAddMode?: boolean) => void;
|
|
57
|
+
onDuplicateEnd?: (selections: TSelection[]) => void;
|
|
58
|
+
duplicateEndGuard?: ISelectionChangeDuplicateEndGuard<TSelection>;
|
|
28
59
|
}): (selections: TSelection[], isEnd: boolean, options?: {
|
|
29
60
|
initial?: boolean;
|
|
30
61
|
}) => void;
|
|
62
|
+
export declare function replaceFormulaControlSelection(selections: IRange[], index: number, newRange: IRange): IRange[] | undefined;
|
|
63
|
+
export declare function getInitialFormulaReferenceSelectionCount(renderSelectionCount: number, formulaReferenceCount: number, selectingType?: FormulaSelectingType): number;
|
|
31
64
|
export declare const useSheetSelectionChange: (isNeed: boolean, isFocus: boolean, isSelectingRef: RefObject<FormulaSelectingType>, unitId: string, subUnitId: string, getRefSelections: () => IRefSelection[], isSupportAcrossSheet: boolean, listenSelectionSet: boolean, editor?: Editor, handleRangeChange?: ((refString: string, offset: number, isEnd: boolean, isModify?: boolean) => void)) => void;
|
|
@@ -54,9 +54,10 @@ export interface IFormulaEditorProps {
|
|
|
54
54
|
export interface IFormulaEditorRef {
|
|
55
55
|
isClickOutSide: (e: MouseEvent) => boolean;
|
|
56
56
|
}
|
|
57
|
+
export declare function shouldApplyFormulaSelectionChange(selectingMode: FormulaSelectingType | number, isFocusing: boolean | undefined, hasActiveInteraction: boolean): boolean;
|
|
57
58
|
interface IFormulaEditorSelectionSyncService {
|
|
58
59
|
getEditor: (editorId: string) => Pick<Editor, 'setSelectionRanges'> | null | undefined | void;
|
|
59
60
|
}
|
|
60
61
|
export declare function syncCounterpartFormulaEditorSelection(editorService: IFormulaEditorSelectionSyncService, editorId: string, selections: ITextRange[] | undefined): void;
|
|
62
|
+
export { getSelectionAfterLaggingFormulaInput } from './hooks/use-formula-selection';
|
|
61
63
|
export declare const FormulaEditor: import("react").ForwardRefExoticComponent<IFormulaEditorProps & import("react").RefAttributes<IFormulaEditorRef>>;
|
|
62
|
-
export {};
|