@univerjs-pro/shape-editor-ui 1.0.0-alpha.7 → 1.0.0-beta.0

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.
Files changed (115) hide show
  1. package/lib/cjs/index.js +1 -1
  2. package/lib/cjs/locale/ar-SA.js +1 -1
  3. package/lib/cjs/locale/ca-ES.js +1 -1
  4. package/lib/cjs/locale/de-DE.js +1 -1
  5. package/lib/cjs/locale/en-US.js +1 -1
  6. package/lib/cjs/locale/es-ES.js +1 -1
  7. package/lib/cjs/locale/fa-IR.js +1 -1
  8. package/lib/cjs/locale/fr-FR.js +1 -1
  9. package/lib/cjs/locale/id-ID.js +1 -1
  10. package/lib/cjs/locale/it-IT.js +1 -1
  11. package/lib/cjs/locale/ja-JP.js +1 -1
  12. package/lib/cjs/locale/ko-KR.js +1 -1
  13. package/lib/cjs/locale/pl-PL.js +1 -1
  14. package/lib/cjs/locale/pt-BR.js +1 -1
  15. package/lib/cjs/locale/ru-RU.js +1 -1
  16. package/lib/cjs/locale/sk-SK.js +1 -1
  17. package/lib/cjs/locale/vi-VN.js +1 -1
  18. package/lib/cjs/locale/zh-CN.js +1 -1
  19. package/lib/cjs/locale/zh-HK.js +1 -1
  20. package/lib/cjs/locale/zh-TW.js +1 -1
  21. package/lib/es/index.js +1 -1
  22. package/lib/es/locale/ar-SA.js +1 -1
  23. package/lib/es/locale/ca-ES.js +1 -1
  24. package/lib/es/locale/de-DE.js +1 -1
  25. package/lib/es/locale/en-US.js +1 -1
  26. package/lib/es/locale/es-ES.js +1 -1
  27. package/lib/es/locale/fa-IR.js +1 -1
  28. package/lib/es/locale/fr-FR.js +1 -1
  29. package/lib/es/locale/id-ID.js +1 -1
  30. package/lib/es/locale/it-IT.js +1 -1
  31. package/lib/es/locale/ja-JP.js +1 -1
  32. package/lib/es/locale/ko-KR.js +1 -1
  33. package/lib/es/locale/pl-PL.js +1 -1
  34. package/lib/es/locale/pt-BR.js +1 -1
  35. package/lib/es/locale/ru-RU.js +1 -1
  36. package/lib/es/locale/sk-SK.js +1 -1
  37. package/lib/es/locale/vi-VN.js +1 -1
  38. package/lib/es/locale/zh-CN.js +1 -1
  39. package/lib/es/locale/zh-HK.js +1 -1
  40. package/lib/es/locale/zh-TW.js +1 -1
  41. package/lib/index.css +79 -56
  42. package/lib/index.js +1 -1
  43. package/lib/locale/ar-SA.js +1 -1
  44. package/lib/locale/ca-ES.js +1 -1
  45. package/lib/locale/de-DE.js +1 -1
  46. package/lib/locale/en-US.js +1 -1
  47. package/lib/locale/es-ES.js +1 -1
  48. package/lib/locale/fa-IR.js +1 -1
  49. package/lib/locale/fr-FR.js +1 -1
  50. package/lib/locale/id-ID.js +1 -1
  51. package/lib/locale/it-IT.js +1 -1
  52. package/lib/locale/ja-JP.js +1 -1
  53. package/lib/locale/ko-KR.js +1 -1
  54. package/lib/locale/pl-PL.js +1 -1
  55. package/lib/locale/pt-BR.js +1 -1
  56. package/lib/locale/ru-RU.js +1 -1
  57. package/lib/locale/sk-SK.js +1 -1
  58. package/lib/locale/vi-VN.js +1 -1
  59. package/lib/locale/zh-CN.js +1 -1
  60. package/lib/locale/zh-HK.js +1 -1
  61. package/lib/locale/zh-TW.js +1 -1
  62. package/lib/types/components/fill-style-tabs-editor/FillStyleTabsEditor.d.ts +2 -0
  63. package/lib/types/config/config.d.ts +26 -7
  64. package/lib/types/index.d.ts +22 -6
  65. package/lib/types/locale/en-US.d.ts +34 -1
  66. package/lib/types/services/formula-binding-editor.d.ts +23 -0
  67. package/lib/types/services/{shape-formula-reference.d.ts → formula-binding-reference.d.ts} +4 -4
  68. package/lib/types/services/{shape-formula-unit-viewer.service.d.ts → formula-binding-unit-viewer.service.d.ts} +10 -10
  69. package/lib/types/utils/activate-drawing-object.d.ts +1 -1
  70. package/lib/types/utils/drawing-type-name.d.ts +3 -0
  71. package/lib/types/views/FormulaBindingEditorDialog.d.ts +11 -0
  72. package/lib/types/views/FormulaBindingNumberFormat.d.ts +23 -0
  73. package/lib/types/views/formula-binding-number-format-utils.d.ts +17 -0
  74. package/lib/types/views/shape-floating-toolbar/ShapeFillControls.d.ts +12 -0
  75. package/lib/types/views/shape-floating-toolbar/ShapeFloatingToolbar.d.ts +6 -131
  76. package/lib/types/views/shape-floating-toolbar/ShapeFloatingToolbarPrimitives.d.ts +39 -0
  77. package/lib/types/views/shape-floating-toolbar/ShapeStrokeControls.d.ts +36 -0
  78. package/lib/types/views/shape-floating-toolbar/ShapeTextControls.d.ts +30 -0
  79. package/lib/types/views/shape-floating-toolbar/floating-toolbar-interaction.d.ts +4 -0
  80. package/lib/types/views/shape-floating-toolbar/shape-floating-toolbar-constants.d.ts +11 -0
  81. package/lib/types/views/shape-floating-toolbar/shape-floating-toolbar-types.d.ts +12 -0
  82. package/lib/types/views/shape-text-editor/ShapeTextEditor.d.ts +2 -193
  83. package/lib/types/views/shape-text-editor/ShapeTextEditorSurface.d.ts +16 -0
  84. package/lib/types/views/shape-text-editor/ShapeTextPositionWrapper.d.ts +2 -1
  85. package/lib/types/views/shape-text-editor/shape-text-document.d.ts +17 -2
  86. package/lib/types/views/shape-text-editor/shape-text-keyboard.d.ts +27 -0
  87. package/lib/types/views/shape-text-editor/shape-text-layout.d.ts +190 -1
  88. package/lib/types/views/shape-text-editor/types.d.ts +1 -1
  89. package/lib/umd/index.js +1 -1
  90. package/lib/umd/locale/ar-SA.js +1 -1
  91. package/lib/umd/locale/ca-ES.js +1 -1
  92. package/lib/umd/locale/de-DE.js +1 -1
  93. package/lib/umd/locale/en-US.js +1 -1
  94. package/lib/umd/locale/es-ES.js +1 -1
  95. package/lib/umd/locale/fa-IR.js +1 -1
  96. package/lib/umd/locale/fr-FR.js +1 -1
  97. package/lib/umd/locale/id-ID.js +1 -1
  98. package/lib/umd/locale/it-IT.js +1 -1
  99. package/lib/umd/locale/ja-JP.js +1 -1
  100. package/lib/umd/locale/ko-KR.js +1 -1
  101. package/lib/umd/locale/pl-PL.js +1 -1
  102. package/lib/umd/locale/pt-BR.js +1 -1
  103. package/lib/umd/locale/ru-RU.js +1 -1
  104. package/lib/umd/locale/sk-SK.js +1 -1
  105. package/lib/umd/locale/vi-VN.js +1 -1
  106. package/lib/umd/locale/zh-CN.js +1 -1
  107. package/lib/umd/locale/zh-HK.js +1 -1
  108. package/lib/umd/locale/zh-TW.js +1 -1
  109. package/package.json +25 -26
  110. package/lib/cjs/formula-shape-en-us-B0fVf3OO.js +0 -1
  111. package/lib/es/formula-shape-en-us-BbvC914f.js +0 -1
  112. package/lib/formula-shape-en-us-BbvC914f.js +0 -1
  113. package/lib/types/services/shape-formula-editor.d.ts +0 -20
  114. package/lib/types/views/formula-shape/FormulaShapeNumberFormat.d.ts +0 -23
  115. package/lib/types/views/formula-shape/formula-shape-number-format-utils.d.ts +0 -17
@@ -1,11 +1,10 @@
1
- import type { IShapeFormulaIdentity } from '@univerjs-pro/shape-editor';
2
1
  import type { BaseDataModel } from '@univerjs/core';
3
- import type { FormulaSequenceNode, IFormulaRefSelection } from '@univerjs/formula-ui';
4
- import type { IShapeFormulaUnitResource } from '../config/config';
5
- import type { IShapeFormulaReferenceSelectionChange } from './shape-formula-editor';
2
+ import type { FormulaSequenceNode, IFormulaRefSelection } from '@univerjs/engine-formula';
3
+ import type { IFormulaBindingHost, IFormulaBindingUnitResource } from '../config/config';
4
+ import type { IFormulaBindingReferenceSelectionChange } from './formula-binding-editor';
6
5
  import { Disposable, IConfigService, IUniverInstanceService, LocaleService, ThemeService, Workbook } from '@univerjs/core';
7
- export type ShapeFormulaViewerUnit = Workbook | BaseDataModel;
8
- export interface IShapeFormulaViewerFormulaContext {
6
+ export type FormulaBindingViewerUnit = Workbook | BaseDataModel;
7
+ export interface IFormulaBindingViewerFormulaContext {
9
8
  formula: string;
10
9
  sequenceNodes: FormulaSequenceNode[];
11
10
  refSelections: IFormulaRefSelection[];
@@ -13,7 +12,7 @@ export interface IShapeFormulaViewerFormulaContext {
13
12
  selectionEnd: number;
14
13
  }
15
14
  /** Owns the real, isolated Univer rendered inside the cross-unit formula editor. */
16
- export declare class ShapeFormulaUnitViewerService extends Disposable {
15
+ export declare class FormulaBindingUnitViewerService extends Disposable {
17
16
  private readonly _configService;
18
17
  private readonly _instanceService;
19
18
  private readonly _localeService;
@@ -38,12 +37,12 @@ export declare class ShapeFormulaUnitViewerService extends Disposable {
38
37
  private _isDraggingFormulaSelection;
39
38
  private _closeRequest;
40
39
  constructor(_configService: IConfigService, _instanceService: IUniverInstanceService, _localeService: LocaleService, _themeService: ThemeService);
41
- listUnits(): Promise<IShapeFormulaUnitResource[]>;
40
+ listUnits(): Promise<IFormulaBindingUnitResource[]>;
42
41
  mount(container: HTMLElement): void;
43
- switchUnit(resource: IShapeFormulaUnitResource, host: IShapeFormulaIdentity, onSelectReferences: (change: IShapeFormulaReferenceSelectionChange) => void): Promise<ShapeFormulaViewerUnit | null>;
42
+ switchUnit(resource: IFormulaBindingUnitResource, host: IFormulaBindingHost, onSelectReferences: (change: IFormulaBindingReferenceSelectionChange) => void): Promise<FormulaBindingViewerUnit | null>;
44
43
  private _makeBaseSnapshotReadOnly;
45
44
  private _setBasePermissionsReadOnly;
46
- updateFormulaContext(context: IShapeFormulaViewerFormulaContext): void;
45
+ updateFormulaContext(context: IFormulaBindingViewerFormulaContext): void;
47
46
  close(): void;
48
47
  /** Defers nested Univer disposal until the owning React tree has finished unmounting. */
49
48
  scheduleClose(): void;
@@ -63,5 +62,6 @@ export declare class ShapeFormulaUnitViewerService extends Disposable {
63
62
  private _canSelectFormulaReference;
64
63
  private _matchesSheetReference;
65
64
  private _matchesUnitQualifier;
65
+ private _createExternalReference;
66
66
  private _listLoadedUnits;
67
67
  }
@@ -14,7 +14,7 @@ interface ISceneLike {
14
14
  };
15
15
  }
16
16
  interface IRenderManagerLike {
17
- getRenderById: (unitId: string) => {
17
+ getRenderUnitById: (unitId: string) => {
18
18
  scene?: ISceneLike;
19
19
  } | undefined;
20
20
  }
@@ -0,0 +1,3 @@
1
+ import { DrawingTypeEnum } from '@univerjs/core';
2
+ export type DrawingTypeNameKey = 'chart' | 'dom' | 'group' | 'image' | 'object' | 'shape' | 'smartArt' | 'table' | 'unit' | 'video';
3
+ export declare function getDrawingTypeNameKey(drawingType: DrawingTypeEnum): DrawingTypeNameKey;
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { IFormulaBindingEditorResult, IFormulaBindingEditorValue, IFormulaBindingHost } from '../config/config';
3
+ export interface IFormulaBindingEditorDialogProps {
4
+ open: boolean;
5
+ host: IFormulaBindingHost;
6
+ value: IFormulaBindingEditorValue;
7
+ footerLeading?: ReactNode;
8
+ onClose: () => void;
9
+ onConfirm: (result: IFormulaBindingEditorResult) => void;
10
+ }
11
+ export declare function FormulaBindingEditorDialog(props: IFormulaBindingEditorDialogProps): import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ export type FormulaBindingNumberFormatType = 'general' | 'accounting' | 'currency' | 'date' | 'number' | 'custom';
2
+ export type FormulaBindingNumberFormatMenuEntry = {
3
+ kind: 'format';
4
+ key: string;
5
+ pattern: string;
6
+ } | {
7
+ kind: 'separator';
8
+ key: string;
9
+ } | {
10
+ kind: 'more';
11
+ };
12
+ export declare function createFormulaBindingNumberFormatMenuEntries(currencySymbol: string): FormulaBindingNumberFormatMenuEntry[];
13
+ export declare function resolveFormulaBindingNumberFormatType(pattern: string): FormulaBindingNumberFormatType;
14
+ export declare function FormulaBindingNumberFormatMenu(props: {
15
+ onSelect: (pattern: string) => void;
16
+ onMore: () => void;
17
+ }): import("react").JSX.Element;
18
+ export declare function FormulaBindingNumberFormatDialog(props: {
19
+ open: boolean;
20
+ pattern: string;
21
+ onClose: () => void;
22
+ onConfirm: (pattern: string) => void;
23
+ }): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ export declare function getFormulaBindingCurrencyType(pattern: string): string | undefined;
2
+ export declare function getFormulaBindingDecimalFromPattern(pattern: string, defaultValue?: number): number;
3
+ export declare function setFormulaBindingPatternDecimal(patterns: string, decimalLength: number): string;
4
+ export declare function getFormulaBindingCurrencyFormatOptions(symbol: string): {
5
+ label: string;
6
+ value: string;
7
+ color: string | undefined;
8
+ }[];
9
+ export declare function getFormulaBindingDateFormatOptions(): {
10
+ label: string;
11
+ value: string;
12
+ }[];
13
+ export declare function getFormulaBindingNumberFormatOptions(): {
14
+ label: string;
15
+ value: string;
16
+ color: string | undefined;
17
+ }[];
@@ -0,0 +1,12 @@
1
+ import type { IShapeData } from '@univerjs-pro/engine-shape';
2
+ import type { ShapeDataUpdateHandler } from './shape-floating-toolbar-types';
3
+ export declare function ShapeFillButton(props: {
4
+ title: string;
5
+ shapeData: IShapeData;
6
+ open?: boolean;
7
+ disabled?: boolean;
8
+ fallbackColor?: string;
9
+ fallbackGradientEndColor?: string;
10
+ onOpenChange?: (open: boolean) => void;
11
+ onUpdateShapeData: ShapeDataUpdateHandler;
12
+ }): import("react").JSX.Element;
@@ -1,22 +1,13 @@
1
1
  import type { IShapeData, ShapeTypeEnum } from '@univerjs-pro/engine-shape';
2
2
  import type { ITextStyle } from '@univerjs/core';
3
- import type { MouseEvent, PointerEvent, ReactNode } from 'react';
4
- import type { IShapeTextUpdateOptions } from './shape-floating-toolbar-utils';
3
+ import type { ReactNode } from 'react';
4
+ import type { IToolbarDropdownOption, ShapeDataUpdateHandler, ShapeTextUpdateHandler } from './shape-floating-toolbar-types';
5
5
  import { HorizontalAlign, VerticalAlign } from '@univerjs/core';
6
- export declare const SHAPE_FLOATING_TOOLBAR_DEFAULT_FILL_COLOR = "#3B82F6";
7
- export declare const SHAPE_FLOATING_TOOLBAR_DEFAULT_STROKE_COLOR = "#2563EB";
8
- export declare const SHAPE_FLOATING_TOOLBAR_DEFAULT_TEXT_COLOR = "#111827";
9
- export declare const SHAPE_FLOATING_TOOLBAR_DEFAULT_TEXT_BACKGROUND_COLOR = "#ffffff";
10
6
  export type IShapeFloatingToolbarWrappingStyle = string | number;
11
7
  export interface IShapeFloatingToolbarTextModel {
12
8
  ha?: HorizontalAlign;
13
9
  va?: VerticalAlign;
14
10
  }
15
- export interface IToolbarDropdownOption<T extends string | number> {
16
- label: string;
17
- value: T;
18
- icon: ReactNode;
19
- }
20
11
  export interface IShapeFloatingToolbarGroupAction {
21
12
  type: 'group' | 'ungroup';
22
13
  label: string;
@@ -59,14 +50,11 @@ export interface IShapeFloatingToolbarProps {
59
50
  enableShapeStrokeReset?: boolean;
60
51
  enableTextBackgroundReset?: boolean;
61
52
  enableTextControls?: boolean;
62
- deferUntilCollapsedStateLoaded?: boolean;
63
53
  defaultFillColor?: string;
64
54
  defaultGradientEndColor?: string;
65
55
  defaultStrokeColor?: string;
66
- onUpdateShapeData: (oldShapeJSON: {
67
- oldShapeData?: IShapeData;
68
- }, shapeData?: IShapeData, patch?: IShapeData) => void;
69
- onUpdateText: (params: IShapeTextUpdateOptions) => void;
56
+ onUpdateShapeData: ShapeDataUpdateHandler;
57
+ onUpdateText: ShapeTextUpdateHandler;
70
58
  onUpdateWrappingStyle?: (value: IShapeFloatingToolbarWrappingStyle) => void;
71
59
  groupAction?: IShapeFloatingToolbarGroupAction;
72
60
  layerActions?: IShapeFloatingToolbarLayerActions;
@@ -77,130 +65,17 @@ export interface IShapeFloatingToolbarProps {
77
65
  onOpenPanel?: () => void;
78
66
  onDelete?: () => void;
79
67
  }
80
- export declare function ShapeFloatingToolbarIcon(props: {
81
- children: ReactNode;
82
- className?: string;
83
- }): import("react").JSX.Element;
84
- export declare function ShapeFloatingToolbarContent(props: {
85
- children: ReactNode;
86
- className?: string;
87
- maxWidthClassName?: string;
88
- dataAttributes?: Record<`data-${string}`, string>;
89
- onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;
90
- }): import("react").JSX.Element;
91
- export declare function ShapeFloatingToolbarButton(props: {
92
- title?: string;
93
- titleKey?: string;
94
- active?: boolean;
95
- disabled?: boolean;
96
- children: ReactNode;
97
- className?: string;
98
- sizeClassName?: string;
99
- tooltipVisible?: boolean;
100
- ariaExpanded?: boolean;
101
- onClick?: () => void;
102
- onMouseDown?: (event: MouseEvent<HTMLButtonElement>) => void;
103
- onPointerDown?: (event: PointerEvent<HTMLButtonElement>) => void;
104
- }): import("react").JSX.Element;
105
- export declare function ShapeFloatingToolbarDropdownTrigger(props: {
106
- title?: string;
107
- titleKey?: string;
108
- icon: ReactNode;
109
- active?: boolean;
110
- className?: string;
111
- sizeClassName?: string;
112
- onMouseDown?: (event: MouseEvent<HTMLButtonElement>) => void;
113
- onPointerDown?: (event: PointerEvent<HTMLButtonElement>) => void;
114
- }): import("react").JSX.Element;
115
- export declare function ShapeFloatingToolbarFontSizeSelect(props: {
116
- value: string | number;
117
- className?: string;
118
- onChange: (fontSize: number) => void;
119
- onAfterChange?: () => void;
120
- }): import("react").JSX.Element;
121
- export type ShapeStrokePanelMode = 'none' | 'solid' | 'dash' | 'dot';
122
- export declare function buildShapeStrokeDataUpdate(currentStroke: IShapeData['stroke'], resolvedStroke: NonNullable<IShapeData['stroke']>, partial: Partial<NonNullable<IShapeData['stroke']>>): {
123
- nextShapeData: IShapeData;
124
- patch: IShapeData;
125
- };
126
- export interface IShapeStrokePanelContentProps {
127
- titleKey: string;
128
- shapeData: IShapeData;
129
- disabled?: boolean;
130
- resetLabelKey?: string;
131
- modeOptions?: ShapeStrokePanelMode[];
132
- showDashDropdown?: boolean;
133
- fallbackColor?: string;
134
- widthRange?: {
135
- min: number;
136
- max: number;
137
- step: number;
138
- };
139
- onReset?: () => void;
140
- onRequestClose?: () => void;
141
- onUpdateShapeData: IShapeFloatingToolbarProps['onUpdateShapeData'];
142
- }
143
- export declare function ShapeStrokePanelContent(props: IShapeStrokePanelContentProps): import("react").JSX.Element;
144
- export declare function ShapeStrokePanelButton(props: {
145
- titleKey: string;
146
- shapeData: IShapeData;
147
- open?: boolean;
148
- disabled?: boolean;
149
- resetLabelKey?: string;
150
- fallbackColor?: string;
151
- onReset?: () => void;
152
- onOpenChange?: (open: boolean) => void;
153
- onUpdateShapeData: IShapeFloatingToolbarProps['onUpdateShapeData'];
154
- }): import("react").JSX.Element;
155
- export declare function ShapeFillButton(props: {
156
- titleKey: string;
157
- shapeData: IShapeData;
158
- open?: boolean;
159
- disabled?: boolean;
160
- fallbackColor?: string;
161
- fallbackGradientEndColor?: string;
162
- onOpenChange?: (open: boolean) => void;
163
- onUpdateShapeData: IShapeFloatingToolbarProps['onUpdateShapeData'];
164
- }): import("react").JSX.Element;
165
- export declare function TextFillButton(props: {
166
- titleKey: string;
167
- textStyle: ITextStyle;
168
- fallbackColor: string;
169
- onChange: (textStyle: ITextStyle) => void;
170
- }): import("react").JSX.Element;
171
- export declare function TextBackgroundColorButton(props: {
172
- titleKey: string;
173
- color: string;
174
- onApply: () => void;
175
- onReset?: () => void;
176
- onChange: (color: string) => void;
177
- }): import("react").JSX.Element;
178
- export declare function TypographyPanelButton(props: {
179
- titleKey: string;
180
- textStyle: {
181
- isBold: boolean;
182
- isItalic: boolean;
183
- isUnderline: boolean;
184
- isStrike: boolean;
185
- };
186
- horizontalAlign: HorizontalAlign;
187
- verticalAlign: VerticalAlign;
188
- horizontalAlignOptions: Array<IToolbarDropdownOption<HorizontalAlign>>;
189
- verticalAlignOptions: Array<IToolbarDropdownOption<VerticalAlign>>;
190
- onUpdateText: IShapeFloatingToolbarProps['onUpdateText'];
191
- }): import("react").JSX.Element;
192
68
  export declare function ShapeFloatingToolbarMenuPanel(props: {
193
69
  title?: string;
194
- titleKey?: string;
195
70
  children: ReactNode;
196
71
  className?: string;
197
72
  minWidthClassName?: string;
198
73
  }): import("react").JSX.Element;
199
74
  export declare function ShapeFloatingToolbarMenuItem(props: {
200
- label?: string;
201
- labelKey?: string;
75
+ label: string;
202
76
  shortcut?: string;
203
77
  disabled?: boolean;
78
+ danger?: boolean;
204
79
  onClick: () => void;
205
80
  }): import("react").JSX.Element;
206
81
  export declare function ShapeFloatingToolbar(props: IShapeFloatingToolbarProps): import("react").JSX.Element | null;
@@ -0,0 +1,39 @@
1
+ import type { MouseEvent, PointerEvent, ReactNode } from 'react';
2
+ export declare function ShapeFloatingToolbarIcon(props: {
3
+ children: ReactNode;
4
+ className?: string;
5
+ }): import("react").JSX.Element;
6
+ export declare function ShapeFloatingToolbarContent(props: {
7
+ children: ReactNode;
8
+ className?: string;
9
+ maxWidthClassName?: string;
10
+ onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;
11
+ }): import("react").JSX.Element;
12
+ export declare function ShapeFloatingToolbarButton(props: {
13
+ title?: string;
14
+ active?: boolean;
15
+ disabled?: boolean;
16
+ children: ReactNode;
17
+ className?: string;
18
+ sizeClassName?: string;
19
+ tooltipVisible?: boolean;
20
+ ariaExpanded?: boolean;
21
+ onClick?: () => void;
22
+ onMouseDown?: (event: MouseEvent<HTMLButtonElement>) => void;
23
+ onPointerDown?: (event: PointerEvent<HTMLButtonElement>) => void;
24
+ }): import("react").JSX.Element;
25
+ export declare function ShapeFloatingToolbarDropdownTrigger(props: {
26
+ title?: string;
27
+ icon: ReactNode;
28
+ active?: boolean;
29
+ className?: string;
30
+ sizeClassName?: string;
31
+ onMouseDown?: (event: MouseEvent<HTMLButtonElement>) => void;
32
+ onPointerDown?: (event: PointerEvent<HTMLButtonElement>) => void;
33
+ }): import("react").JSX.Element;
34
+ export declare function ShapeFloatingToolbarFontSizeSelect(props: {
35
+ value: string | number;
36
+ className?: string;
37
+ onChange: (fontSize: number) => void;
38
+ onAfterChange?: () => void;
39
+ }): import("react").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import type { IShapeData } from '@univerjs-pro/engine-shape';
2
+ import type { ShapeDataUpdateHandler } from './shape-floating-toolbar-types';
3
+ export type ShapeStrokePanelMode = 'none' | 'solid' | 'dash' | 'dot';
4
+ export declare function buildShapeStrokeDataUpdate(currentStroke: IShapeData['stroke'], resolvedStroke: NonNullable<IShapeData['stroke']>, partial: Partial<NonNullable<IShapeData['stroke']>>): {
5
+ nextShapeData: IShapeData;
6
+ patch: IShapeData;
7
+ };
8
+ export interface IShapeStrokePanelContentProps {
9
+ title: string;
10
+ shapeData: IShapeData;
11
+ disabled?: boolean;
12
+ resetLabel?: string;
13
+ modeOptions?: ShapeStrokePanelMode[];
14
+ showDashDropdown?: boolean;
15
+ fallbackColor?: string;
16
+ widthRange?: {
17
+ min: number;
18
+ max: number;
19
+ step: number;
20
+ };
21
+ onReset?: () => void;
22
+ onRequestClose?: () => void;
23
+ onUpdateShapeData: ShapeDataUpdateHandler;
24
+ }
25
+ export declare function ShapeStrokePanelContent(props: IShapeStrokePanelContentProps): import("react").JSX.Element;
26
+ export declare function ShapeStrokePanelButton(props: {
27
+ title: string;
28
+ shapeData: IShapeData;
29
+ open?: boolean;
30
+ disabled?: boolean;
31
+ resetLabel?: string;
32
+ fallbackColor?: string;
33
+ onReset?: () => void;
34
+ onOpenChange?: (open: boolean) => void;
35
+ onUpdateShapeData: ShapeDataUpdateHandler;
36
+ }): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import type { HorizontalAlign, ITextStyle, VerticalAlign } from '@univerjs/core';
2
+ import type { IToolbarDropdownOption, ShapeTextUpdateHandler } from './shape-floating-toolbar-types';
3
+ export declare function TextFillButton(props: {
4
+ title: string;
5
+ textStyle: ITextStyle;
6
+ fallbackColor: string;
7
+ onChange: (textStyle: ITextStyle) => void;
8
+ }): import("react").JSX.Element;
9
+ export declare function TextBackgroundColorButton(props: {
10
+ title: string;
11
+ color: string;
12
+ onApply: () => void;
13
+ onReset?: () => void;
14
+ onChange: (color: string) => void;
15
+ }): import("react").JSX.Element;
16
+ export declare function TypographyPanelButton(props: {
17
+ title: string;
18
+ fontFamily: string;
19
+ textStyle: {
20
+ isBold: boolean;
21
+ isItalic: boolean;
22
+ isUnderline: boolean;
23
+ isStrike: boolean;
24
+ };
25
+ horizontalAlign: HorizontalAlign;
26
+ verticalAlign: VerticalAlign;
27
+ horizontalAlignOptions: Array<IToolbarDropdownOption<HorizontalAlign>>;
28
+ verticalAlignOptions: Array<IToolbarDropdownOption<VerticalAlign>>;
29
+ onUpdateText: ShapeTextUpdateHandler;
30
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import type { MouseEvent, PointerEvent } from 'react';
2
+ export declare function shouldKeepFloatingToolbarMouseDownDefault(target: EventTarget | null): boolean;
3
+ export declare function preventFloatingToolbarPanelBlur(event: MouseEvent<HTMLElement> | PointerEvent<HTMLElement>): void;
4
+ export declare function keepFloatingToolbarPanelInteraction(event: MouseEvent<HTMLElement> | PointerEvent<HTMLElement>): void;
@@ -0,0 +1,11 @@
1
+ import { ShapeFillEnum } from '@univerjs-pro/engine-shape';
2
+ export declare const SHAPE_FLOATING_TOOLBAR_DEFAULT_FILL_COLOR = "#3B82F6";
3
+ export declare const SHAPE_FLOATING_TOOLBAR_DEFAULT_STROKE_COLOR = "#2563EB";
4
+ export declare const SHAPE_FLOATING_TOOLBAR_DEFAULT_TEXT_COLOR = "#111827";
5
+ export declare const SHAPE_FLOATING_TOOLBAR_DEFAULT_TEXT_BACKGROUND_COLOR = "#ffffff";
6
+ export declare const SHAPE_FILL_TYPE_VALUES: {
7
+ none: ShapeFillEnum;
8
+ solid: ShapeFillEnum;
9
+ gradient: ShapeFillEnum;
10
+ picture: ShapeFillEnum;
11
+ };
@@ -0,0 +1,12 @@
1
+ import type { IShapeData } from '@univerjs-pro/engine-shape';
2
+ import type { ReactNode } from 'react';
3
+ import type { IShapeTextUpdateOptions } from './shape-floating-toolbar-utils';
4
+ export interface IToolbarDropdownOption<T extends string | number> {
5
+ label: string;
6
+ value: T;
7
+ icon: ReactNode;
8
+ }
9
+ export type ShapeDataUpdateHandler = (oldShapeJSON: {
10
+ oldShapeData?: IShapeData;
11
+ }, shapeData?: IShapeData, patch?: IShapeData) => void;
12
+ export type ShapeTextUpdateHandler = (params: IShapeTextUpdateOptions) => void;
@@ -1,9 +1,5 @@
1
- import type { ICustomShapeTextData, IShapeRect, IShapeTextDataModel } from '@univerjs-pro/engine-shape';
2
- import type { IDocumentData, Nullable } from '@univerjs/core';
3
- import type { Editor, IKeyboardEventConfig } from '@univerjs/docs-ui';
4
- import type { CSSProperties } from 'react';
5
- import type { IShapeTextEditingParams, IShapeTextEditingService, IShapeTextEditorAdapter, IShapeTextEditorModel } from './types';
6
- import { HorizontalAlign, ICommandService, VerticalAlign } from '@univerjs/core';
1
+ import type { Nullable } from '@univerjs/core';
2
+ import type { IShapeTextEditingParams, IShapeTextEditingService, IShapeTextEditorAdapter } from './types';
7
3
  export { resolveShapeTextEditorBehaviorShapeData, resolveShapeTextEditorWrapStrategy, shouldAllowShapeTextEditorHostSizeShrink, shouldAutoFitShapeTextEditorNoWrap, } from './shape-text-behavior';
8
4
  export interface IShapeTextEditorProps {
9
5
  adapter: IShapeTextEditorAdapter;
@@ -16,191 +12,4 @@ export interface IShapeTextEditorProps {
16
12
  scaleY: number;
17
13
  verticalAlignCommandId?: string;
18
14
  }
19
- interface IContentLayout {
20
- documentMarginTop: number;
21
- editorLeft: number;
22
- editorTop: number;
23
- editorWidth: number;
24
- editorHeight: number;
25
- editorSurfaceWidth?: number;
26
- }
27
- export declare function resolveShapeTextEditingContentHeight(measuredContentHeight: number, caretHeight?: number): number;
28
- export declare function getShapeTextEditingCaretHeight(activeRange?: {
29
- getAbsolutePosition(): Nullable<{
30
- height?: number;
31
- }>;
32
- }): number | undefined;
33
- export declare function areShapeTextEditorLayoutsEqual(a: IContentLayout, b: IContentLayout): boolean;
34
- interface IShapeTextEditorLayoutOptions {
35
- actualHeight: number;
36
- contentWidth?: number;
37
- scaleX: number;
38
- scaleY: number;
39
- textRect: {
40
- left: number;
41
- top: number;
42
- width: number;
43
- height: number;
44
- };
45
- verticalAlign: VerticalAlign;
46
- opticalVerticalOffset?: number;
47
- }
48
- interface IShapeTextEditorLayout {
49
- documentMarginTop: number;
50
- editorLeft: number;
51
- editorTop: number;
52
- editorWidth: number;
53
- editorHeight: number;
54
- pageHeight: number;
55
- }
56
- interface IShapeTextEditorKeyboardRange {
57
- startOffset?: number;
58
- endOffset?: number;
59
- collapsed?: boolean;
60
- }
61
- export declare function isShapeTextEditorKeyboardFocusActive(isInputFocusing: boolean, textRanges: readonly IShapeTextEditorKeyboardRange[] | null | undefined): boolean;
62
- interface IShapeTextEditorHostHeightOptions {
63
- hostHeight: number;
64
- textRect: {
65
- left: number;
66
- top: number;
67
- width: number;
68
- height: number;
69
- };
70
- contentHeight: number;
71
- }
72
- interface IShapeTextEditorHostSizeOptions {
73
- hostWidth: number;
74
- hostHeight: number;
75
- textRect: {
76
- left: number;
77
- top: number;
78
- width: number;
79
- height: number;
80
- };
81
- contentWidth: number;
82
- contentHeight: number;
83
- allowShrink?: boolean;
84
- }
85
- interface IShapeTextEditorHostSizeChangeOptions {
86
- nextWidth: number;
87
- nextHeight: number;
88
- baselineWidth: number;
89
- baselineHeight: number;
90
- tolerance?: number;
91
- }
92
- interface IShapeTextEditorKeyboardOptions {
93
- commitOnEnter?: boolean;
94
- cancel?: () => void;
95
- commit?: () => void;
96
- currentFontSize?: number;
97
- }
98
- export declare function getShapeTextEditorFocusSessionKey(options: {
99
- editorUnitId: string;
100
- editingParams: Nullable<IShapeTextEditingParams>;
101
- }): string | null;
102
- export declare function shouldCompleteShapeTextEditingOnPointerDown(target: EventTarget | null, editorElement: HTMLElement | null): boolean;
103
- export declare function resolveShapeTextEditorTextRect(options: {
104
- shapeModel: Pick<IShapeTextEditorModel, 'getShapeTextRect'>;
105
- hostRect: IShapeRect;
106
- }): IShapeRect;
107
- export declare function buildShapeTextEditorCommitShapeText(options: {
108
- dataModel?: IShapeTextDataModel;
109
- isHorizontal?: boolean;
110
- shapeText?: ICustomShapeTextData | null;
111
- }): ICustomShapeTextData;
112
- export declare function createEmptyShapeTextEditorDocument(editorUnitId: string, pageWidth: number): IDocumentData;
113
- export declare function resolveShapeTextEditorEmptyTextBoxMinSize(options: {
114
- isHorizontal: boolean;
115
- placeholderWidth: number;
116
- }): {
117
- width: number;
118
- height: number;
119
- };
120
- export declare function measureShapeTextEditorPlaceholderWidth(documentData: IDocumentData, placeholder: string): number;
121
- export declare function resolveShapeTextEditorMeasurePageWidth(options: {
122
- autoFitNoWrap: boolean;
123
- maxAutoFitWidth?: number;
124
- textRectWidth: number;
125
- }): number;
126
- export declare function measureShapeTextEditorNoWrapContentWidth(documentData: IDocumentData | null | undefined): number;
127
- export declare function resolveShapeTextEditorRenderedContentWidth(options: {
128
- actualWidth: number;
129
- autoFitNoWrap: boolean;
130
- measuredContentWidth?: number;
131
- textRectWidth: number;
132
- }): number;
133
- export declare function resolveShapeTextEditorHostContentWidth(options: {
134
- actualWidth: number;
135
- allowShrink: boolean;
136
- autoFitNoWrap: boolean;
137
- measuredContentWidth?: number;
138
- renderedContentWidth: number;
139
- }): number;
140
- export declare function resolveShapeTextEditorFinalPageWidth(options: {
141
- autoFitNoWrap: boolean;
142
- measurePageWidth?: number;
143
- renderedContentWidth: number;
144
- textRectWidth: number;
145
- }): number;
146
- export declare function resolveShapeTextEditorRenderSurfaceWidth(options: {
147
- autoFitNoWrap: boolean;
148
- editorWidth: number;
149
- measurePageWidth: number;
150
- renderedContentWidth?: number;
151
- scaleX: number;
152
- }): number;
153
- export declare function hasShapeTextEditorHostSizeChanged(options: IShapeTextEditorHostSizeChangeOptions): boolean;
154
- export declare function resolveShapeTextEditorShouldShrinkHostSize(options: {
155
- adapter: Pick<IShapeTextEditorAdapter, 'allowHostSizeShrink' | 'updateHostSize'>;
156
- editingParams: Nullable<IShapeTextEditingParams>;
157
- }): boolean;
158
- export declare function shouldDeferShapeTextEditorHostSizeUpdateDuringEditing(options: {
159
- adapter: Pick<IShapeTextEditorAdapter, 'deferHostSizeUpdateDuringEditing'>;
160
- editingParams: Nullable<IShapeTextEditingParams>;
161
- }): boolean;
162
- export declare function resolveShapeTextEditorDocumentVerticalAlign(options: {
163
- opticalVerticalAlign: boolean;
164
- verticalAlign: VerticalAlign;
165
- }): VerticalAlign;
166
- export declare function resolveShapeTextEditorLayout(options: IShapeTextEditorLayoutOptions): IShapeTextEditorLayout;
167
- export declare function resolveShapeTextEditorPlaceholderLayout(options: {
168
- documentMarginTop: number;
169
- editorLeft: number;
170
- editorSurfaceWidth?: number;
171
- editorTop: number;
172
- editorWidth: number;
173
- horizontalAlign: HorizontalAlign;
174
- }): {
175
- left: number;
176
- textAlign: 'center' | 'left' | 'right';
177
- top: number;
178
- width: number;
179
- };
180
- export declare function resolveShapeTextEditorHostHeight(options: IShapeTextEditorHostHeightOptions): number;
181
- export declare function resolveShapeTextEditorHostSize(options: IShapeTextEditorHostSizeOptions): {
182
- width: number;
183
- height: number;
184
- };
185
- export declare function resolveShapeTextEditorPhysicalContentSize(options: {
186
- crossAxisLength: number;
187
- flowAxis: 'width' | 'height';
188
- flowAxisLength: number;
189
- }): {
190
- height: number;
191
- width: number;
192
- };
193
- export declare function getShapeTextEditorContentStyle(leftOrWidth: number, topOrHeight: number, width?: number, height?: number): CSSProperties;
194
- export declare function setShapeTextEditorDocumentData(editor: Pick<Editor, 'setDocumentData' | 'clearUndoRedoHistory'>, ...params: Parameters<Editor['setDocumentData']>): void;
195
- export declare function getShapeTextEditorDocumentData(editor: Pick<Editor, 'getDocumentData' | 'getDocumentDataModel'>): IDocumentData | null;
196
- export declare function applyShapeTextEditorCanvasTransparency(renderer: {
197
- engine?: {
198
- getCanvasElement?: () => HTMLElement | null;
199
- };
200
- } | null | undefined | void): void;
201
- export declare function getShapeTextEditorKeyboardConfig(commandService: Pick<ICommandService, 'executeCommand'>, executeUndoRedoCommand?: (commandId: string) => void, options?: IShapeTextEditorKeyboardOptions): IKeyboardEventConfig;
202
- /**
203
- * Shape editor component - second layer DOM.
204
- * Handles document editing, content height tracking, and vertical alignment.
205
- */
206
15
  export declare const ShapeTextEditor: (props: IShapeTextEditorProps) => import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import type { HorizontalAlign, ITransformState } from '@univerjs/core';
2
+ import type { CSSProperties, RefObject } from 'react';
3
+ import type { IContentLayout } from './shape-text-layout';
4
+ export interface IShapeTextEditorSurfaceProps {
5
+ containerRef: RefObject<HTMLDivElement | null>;
6
+ editingContentStyle?: CSSProperties;
7
+ editorContainerRef: RefObject<HTMLDivElement | null>;
8
+ editorUnitId: string;
9
+ fontSize: number;
10
+ horizontalAlign: HorizontalAlign;
11
+ layout: IContentLayout;
12
+ placeholder: string;
13
+ showPlaceholder: boolean;
14
+ transform: ITransformState;
15
+ }
16
+ export declare function ShapeTextEditorSurface(props: IShapeTextEditorSurfaceProps): import("react").JSX.Element;