@univerjs-pro/shape-editor-ui 1.0.0-alpha.1 → 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.
Files changed (109) hide show
  1. package/README.md +14 -2
  2. package/lib/cjs/index.js +1 -1
  3. package/lib/cjs/locale/ar-SA.js +1 -1
  4. package/lib/cjs/locale/ca-ES.js +1 -1
  5. package/lib/cjs/locale/de-DE.js +1 -1
  6. package/lib/cjs/locale/en-US.js +1 -1
  7. package/lib/cjs/locale/es-ES.js +1 -1
  8. package/lib/cjs/locale/fa-IR.js +1 -1
  9. package/lib/cjs/locale/fr-FR.js +1 -1
  10. package/lib/cjs/locale/id-ID.js +1 -1
  11. package/lib/cjs/locale/it-IT.js +1 -1
  12. package/lib/cjs/locale/ja-JP.js +1 -1
  13. package/lib/cjs/locale/ko-KR.js +1 -1
  14. package/lib/cjs/locale/pl-PL.js +1 -1
  15. package/lib/cjs/locale/pt-BR.js +1 -1
  16. package/lib/cjs/locale/ru-RU.js +1 -1
  17. package/lib/cjs/locale/sk-SK.js +1 -1
  18. package/lib/cjs/locale/vi-VN.js +1 -1
  19. package/lib/cjs/locale/zh-CN.js +1 -1
  20. package/lib/cjs/locale/zh-HK.js +1 -1
  21. package/lib/cjs/locale/zh-TW.js +1 -1
  22. package/lib/es/index.js +1 -1
  23. package/lib/es/locale/ar-SA.js +1 -1
  24. package/lib/es/locale/ca-ES.js +1 -1
  25. package/lib/es/locale/de-DE.js +1 -1
  26. package/lib/es/locale/en-US.js +1 -1
  27. package/lib/es/locale/es-ES.js +1 -1
  28. package/lib/es/locale/fa-IR.js +1 -1
  29. package/lib/es/locale/fr-FR.js +1 -1
  30. package/lib/es/locale/id-ID.js +1 -1
  31. package/lib/es/locale/it-IT.js +1 -1
  32. package/lib/es/locale/ja-JP.js +1 -1
  33. package/lib/es/locale/ko-KR.js +1 -1
  34. package/lib/es/locale/pl-PL.js +1 -1
  35. package/lib/es/locale/pt-BR.js +1 -1
  36. package/lib/es/locale/ru-RU.js +1 -1
  37. package/lib/es/locale/sk-SK.js +1 -1
  38. package/lib/es/locale/vi-VN.js +1 -1
  39. package/lib/es/locale/zh-CN.js +1 -1
  40. package/lib/es/locale/zh-HK.js +1 -1
  41. package/lib/es/locale/zh-TW.js +1 -1
  42. package/lib/index.css +159 -12
  43. package/lib/index.js +1 -1
  44. package/lib/locale/ar-SA.js +1 -1
  45. package/lib/locale/ca-ES.js +1 -1
  46. package/lib/locale/de-DE.js +1 -1
  47. package/lib/locale/en-US.js +1 -1
  48. package/lib/locale/es-ES.js +1 -1
  49. package/lib/locale/fa-IR.js +1 -1
  50. package/lib/locale/fr-FR.js +1 -1
  51. package/lib/locale/id-ID.js +1 -1
  52. package/lib/locale/it-IT.js +1 -1
  53. package/lib/locale/ja-JP.js +1 -1
  54. package/lib/locale/ko-KR.js +1 -1
  55. package/lib/locale/pl-PL.js +1 -1
  56. package/lib/locale/pt-BR.js +1 -1
  57. package/lib/locale/ru-RU.js +1 -1
  58. package/lib/locale/sk-SK.js +1 -1
  59. package/lib/locale/vi-VN.js +1 -1
  60. package/lib/locale/zh-CN.js +1 -1
  61. package/lib/locale/zh-HK.js +1 -1
  62. package/lib/locale/zh-TW.js +1 -1
  63. package/lib/types/components/fill-style-tabs-editor/FillStyleTabsEditor.d.ts +2 -1
  64. package/lib/types/config/config.d.ts +5 -0
  65. package/lib/types/controllers/components.controller.d.ts +7 -0
  66. package/lib/types/index.d.ts +25 -20
  67. package/lib/types/locale/en-US.d.ts +2 -0
  68. package/lib/types/plugin.d.ts +13 -0
  69. package/lib/types/utils/activate-drawing-object.d.ts +23 -0
  70. package/lib/types/utils/shape-floating-toolbar-config.d.ts +5 -0
  71. package/lib/types/utils/shape-transformer-config.d.ts +31 -0
  72. package/lib/types/views/shape-floating-toolbar/ShapeFloatingToolbar.d.ts +131 -10
  73. package/lib/types/views/shape-floating-toolbar/shape-floating-toolbar-utils.d.ts +2 -5
  74. package/lib/types/views/shape-picker/ShapePickerGrid.d.ts +22 -0
  75. package/lib/types/views/shape-picker/index.d.ts +4 -0
  76. package/lib/types/views/shape-picker/shapes.d.ts +25 -0
  77. package/lib/types/views/shape-text-editor/ShapeTextEditor.d.ts +105 -9
  78. package/lib/types/views/shape-text-editor/ShapeTextEditorContainer.d.ts +2 -2
  79. package/lib/types/views/shape-text-editor/ShapeTextPositionWrapper.d.ts +29 -0
  80. package/lib/types/views/shape-text-editor/hooks/use-shape-position.d.ts +3 -1
  81. package/lib/types/views/shape-text-editor/shape-text-behavior.d.ts +15 -0
  82. package/lib/types/views/shape-text-editor/shape-text-document.d.ts +8 -3
  83. package/lib/types/views/shape-text-editor/shape-text-editor-commands.d.ts +4 -0
  84. package/lib/types/views/shape-text-editor/shape-text-layout.d.ts +24 -0
  85. package/lib/types/views/shape-text-editor/shape-text-no-wrap-layout.d.ts +24 -0
  86. package/lib/types/views/shape-text-editor/shape-text-placeholder.d.ts +8 -0
  87. package/lib/types/views/shape-text-editor/shape-text-resize-policy.d.ts +17 -0
  88. package/lib/types/views/shape-text-editor/types.d.ts +25 -6
  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 +13 -13
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shared modern selection affordances for shape surfaces that use the engine transformer.
3
+ * Per-object transformer settings still take precedence for special cases such as connectors.
4
+ */
5
+ export declare const SHAPE_EDITOR_TRANSFORMER_CONFIG: {
6
+ readonly borderEnabled: true;
7
+ readonly borderStroke: "#4086f4";
8
+ readonly borderStrokeWidth: 1;
9
+ readonly borderSpacing: 2;
10
+ readonly anchorFill: "#ffffff";
11
+ readonly anchorStroke: "#4086f4";
12
+ readonly anchorStrokeWidth: 1.5;
13
+ readonly anchorSize: 8;
14
+ readonly anchorCornerRadius: 2;
15
+ readonly anchorStyle: "canva";
16
+ readonly rotateEnabled: true;
17
+ readonly rotateSize: 18;
18
+ readonly rotateCornerRadius: 9;
19
+ readonly rotateAnchorOffset: 28;
20
+ readonly rotateAnchorPosition: "bottom";
21
+ readonly rotateLineEnabled: false;
22
+ readonly rotateFill: "#ffffff";
23
+ readonly rotateStroke: "#4086f4";
24
+ readonly rotateStrokeWidth: 1;
25
+ readonly rotateIconEnabled: true;
26
+ readonly rotateIconStroke: "#4086f4";
27
+ readonly rotateIconStrokeWidth: 1.25;
28
+ readonly resizeEnabled: true;
29
+ readonly keepRatio: false;
30
+ readonly moveBoundaryEnabled: false;
31
+ };
@@ -1,8 +1,12 @@
1
1
  import type { IShapeData, ShapeTypeEnum } from '@univerjs-pro/engine-shape';
2
2
  import type { ITextStyle } from '@univerjs/core';
3
- import type { ReactNode } from 'react';
3
+ import type { MouseEvent, PointerEvent, ReactNode } from 'react';
4
4
  import type { IShapeTextUpdateOptions } from './shape-floating-toolbar-utils';
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";
6
10
  export type IShapeFloatingToolbarWrappingStyle = string | number;
7
11
  export interface IShapeFloatingToolbarTextModel {
8
12
  ha?: HorizontalAlign;
@@ -29,21 +33,36 @@ export interface IShapeFloatingToolbarLayerActions {
29
33
  onBackward: () => void;
30
34
  onBack: () => void;
31
35
  }
36
+ export interface IShapeFloatingToolbarExtensionAction {
37
+ key: string;
38
+ label: string;
39
+ icon: ReactNode;
40
+ render?: ReactNode;
41
+ active?: boolean;
42
+ disabled?: boolean;
43
+ visible?: boolean;
44
+ onClick?: () => void;
45
+ }
46
+ export interface IShapeFloatingToolbarExtensionGroup {
47
+ key: string;
48
+ visible?: boolean;
49
+ actions: IShapeFloatingToolbarExtensionAction[];
50
+ }
32
51
  export interface IShapeFloatingToolbarProps {
33
52
  shapeData?: IShapeData;
34
53
  shapeType?: ShapeTypeEnum;
35
54
  textStyle: ITextStyle;
36
55
  textModel?: IShapeFloatingToolbarTextModel | null;
37
- fontOptions: Array<{
38
- label: string;
39
- value: string;
40
- }>;
41
56
  wrappingStyle?: IShapeFloatingToolbarWrappingStyle;
42
57
  wrappingStyleOptions?: Array<IToolbarDropdownOption<IShapeFloatingToolbarWrappingStyle>>;
43
58
  enableShapeFillReset?: boolean;
44
59
  enableShapeStrokeReset?: boolean;
45
60
  enableTextBackgroundReset?: boolean;
61
+ enableTextControls?: boolean;
46
62
  deferUntilCollapsedStateLoaded?: boolean;
63
+ defaultFillColor?: string;
64
+ defaultGradientEndColor?: string;
65
+ defaultStrokeColor?: string;
47
66
  onUpdateShapeData: (oldShapeJSON: {
48
67
  oldShapeData?: IShapeData;
49
68
  }, shapeData?: IShapeData) => void;
@@ -51,23 +70,125 @@ export interface IShapeFloatingToolbarProps {
51
70
  onUpdateWrappingStyle?: (value: IShapeFloatingToolbarWrappingStyle) => void;
52
71
  groupAction?: IShapeFloatingToolbarGroupAction;
53
72
  layerActions?: IShapeFloatingToolbarLayerActions;
73
+ extensionGroups?: IShapeFloatingToolbarExtensionGroup[];
54
74
  onOpenPanel?: () => void;
55
75
  onDelete?: () => void;
56
76
  }
57
- declare function TextWrapShapeIcon(): import("react").JSX.Element;
77
+ export declare function ShapeFloatingToolbarIcon(props: {
78
+ children: ReactNode;
79
+ className?: string;
80
+ }): import("react").JSX.Element;
81
+ export declare function ShapeFloatingToolbarContent(props: {
82
+ children: ReactNode;
83
+ className?: string;
84
+ maxWidthClassName?: string;
85
+ dataAttributes?: Record<`data-${string}`, string>;
86
+ onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;
87
+ }): import("react").JSX.Element;
88
+ export declare function ShapeFloatingToolbarButton(props: {
89
+ title?: string;
90
+ titleKey?: string;
91
+ active?: boolean;
92
+ disabled?: boolean;
93
+ children: ReactNode;
94
+ className?: string;
95
+ sizeClassName?: string;
96
+ ariaExpanded?: boolean;
97
+ onClick?: () => void;
98
+ onMouseDown?: (event: MouseEvent<HTMLButtonElement>) => void;
99
+ onPointerDown?: (event: PointerEvent<HTMLButtonElement>) => void;
100
+ }): import("react").JSX.Element;
101
+ export declare function ShapeFloatingToolbarDropdownTrigger(props: {
102
+ title?: string;
103
+ titleKey?: string;
104
+ icon: ReactNode;
105
+ active?: boolean;
106
+ className?: string;
107
+ sizeClassName?: string;
108
+ onMouseDown?: (event: MouseEvent<HTMLButtonElement>) => void;
109
+ onPointerDown?: (event: PointerEvent<HTMLButtonElement>) => void;
110
+ }): import("react").JSX.Element;
111
+ export declare function ShapeFloatingToolbarFontSizeSelect(props: {
112
+ value: string | number;
113
+ className?: string;
114
+ onChange: (fontSize: number) => void;
115
+ onAfterChange?: () => void;
116
+ }): import("react").JSX.Element;
117
+ export type ShapeStrokePanelMode = 'none' | 'solid' | 'dash' | 'dot';
118
+ export interface IShapeStrokePanelContentProps {
119
+ titleKey: string;
120
+ shapeData: IShapeData;
121
+ disabled?: boolean;
122
+ resetLabelKey?: string;
123
+ modeOptions?: ShapeStrokePanelMode[];
124
+ showDashDropdown?: boolean;
125
+ fallbackColor?: string;
126
+ widthRange?: {
127
+ min: number;
128
+ max: number;
129
+ step: number;
130
+ };
131
+ onReset?: () => void;
132
+ onRequestClose?: () => void;
133
+ onUpdateShapeData: IShapeFloatingToolbarProps['onUpdateShapeData'];
134
+ }
135
+ export declare function ShapeStrokePanelContent(props: IShapeStrokePanelContentProps): import("react").JSX.Element;
136
+ export declare function ShapeStrokePanelButton(props: {
137
+ titleKey: string;
138
+ shapeData: IShapeData;
139
+ disabled?: boolean;
140
+ resetLabelKey?: string;
141
+ fallbackColor?: string;
142
+ onReset?: () => void;
143
+ onUpdateShapeData: IShapeFloatingToolbarProps['onUpdateShapeData'];
144
+ }): import("react").JSX.Element;
145
+ export declare function ShapeFillButton(props: {
146
+ titleKey: string;
147
+ shapeData: IShapeData;
148
+ disabled?: boolean;
149
+ fallbackColor?: string;
150
+ fallbackGradientEndColor?: string;
151
+ onUpdateShapeData: IShapeFloatingToolbarProps['onUpdateShapeData'];
152
+ }): import("react").JSX.Element;
58
153
  export declare function TextFillButton(props: {
59
- title: string;
154
+ titleKey: string;
60
155
  textStyle: ITextStyle;
61
156
  fallbackColor: string;
62
157
  onChange: (textStyle: ITextStyle) => void;
63
158
  }): import("react").JSX.Element;
64
159
  export declare function TextBackgroundColorButton(props: {
65
- title: string;
160
+ titleKey: string;
66
161
  color: string;
67
- resetLabel?: string;
68
162
  onApply: () => void;
69
163
  onReset?: () => void;
70
164
  onChange: (color: string) => void;
71
165
  }): import("react").JSX.Element;
166
+ export declare function TypographyPanelButton(props: {
167
+ titleKey: string;
168
+ textStyle: {
169
+ isBold: boolean;
170
+ isItalic: boolean;
171
+ isUnderline: boolean;
172
+ isStrike: boolean;
173
+ };
174
+ horizontalAlign: HorizontalAlign;
175
+ verticalAlign: VerticalAlign;
176
+ horizontalAlignOptions: Array<IToolbarDropdownOption<HorizontalAlign>>;
177
+ verticalAlignOptions: Array<IToolbarDropdownOption<VerticalAlign>>;
178
+ onUpdateText: IShapeFloatingToolbarProps['onUpdateText'];
179
+ }): import("react").JSX.Element;
180
+ export declare function ShapeFloatingToolbarMenuPanel(props: {
181
+ title?: string;
182
+ titleKey?: string;
183
+ children: ReactNode;
184
+ className?: string;
185
+ minWidthClassName?: string;
186
+ }): import("react").JSX.Element;
187
+ export declare function ShapeFloatingToolbarMenuItem(props: {
188
+ label?: string;
189
+ labelKey?: string;
190
+ shortcut?: string;
191
+ disabled?: boolean;
192
+ onClick: () => void;
193
+ }): import("react").JSX.Element;
72
194
  export declare function ShapeFloatingToolbar(props: IShapeFloatingToolbarProps): import("react").JSX.Element | null;
73
- export { TextWrapShapeIcon };
@@ -1,11 +1,8 @@
1
1
  import type { IShapeData } from '@univerjs-pro/engine-shape';
2
2
  import type { IDocumentData, ITextStyle } from '@univerjs/core';
3
+ import type { IShapeTextModel } from '../shape-text-editor/types';
3
4
  import { HorizontalAlign, VerticalAlign } from '@univerjs/core';
4
- export interface IShapeTextModel {
5
- va?: VerticalAlign;
6
- ha?: HorizontalAlign;
7
- doc: IDocumentData;
8
- }
5
+ export type { IShapeTextModel };
9
6
  export interface IShapeTextUpdateOptions {
10
7
  textStyle?: ITextStyle;
11
8
  verticalAlign?: VerticalAlign;
@@ -0,0 +1,22 @@
1
+ import type { ShapeGroupEnum, ShapeTypeOption } from './shapes';
2
+ export interface IShapePickerGridProps {
3
+ onShapeClick: (shape: ShapeTypeOption) => void;
4
+ excludeGroups?: ShapeGroupEnum[];
5
+ options?: readonly ShapeTypeOption[];
6
+ scrollContainer?: 'self' | 'parent';
7
+ variant?: 'plain' | 'card';
8
+ }
9
+ export declare function ShapePickerGrid(props: IShapePickerGridProps): import("react").JSX.Element;
10
+ export interface IShapePickerPanelProps {
11
+ onShapeClick: (shape: ShapeTypeOption) => void;
12
+ excludeGroups?: ShapeGroupEnum[];
13
+ options?: readonly ShapeTypeOption[];
14
+ scrollContainer?: 'self' | 'parent';
15
+ variant?: 'plain' | 'card';
16
+ }
17
+ export declare function ShapePickerPanel(props: IShapePickerPanelProps): import("react").JSX.Element;
18
+ export interface IShapePickerDropdownProps extends IShapePickerPanelProps {
19
+ buttonLabel: string;
20
+ side?: 'top' | 'right' | 'bottom' | 'left';
21
+ }
22
+ export declare function ShapePickerDropdown(props: IShapePickerDropdownProps): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export { ShapePickerDropdown, ShapePickerGrid, ShapePickerPanel, } from './ShapePickerGrid';
2
+ export type { IShapePickerDropdownProps, IShapePickerGridProps, IShapePickerPanelProps, } from './ShapePickerGrid';
3
+ export { groupShapeOptions, ShapeGroupEnum, shapeTypeOptions, } from './shapes';
4
+ export type { ShapeLocaleKey, ShapeTypeOption, } from './shapes';
@@ -0,0 +1,25 @@
1
+ import { ShapeTypeEnum } from '@univerjs-pro/engine-shape';
2
+ export type ShapeLocaleKey = `shape.${string}`;
3
+ export declare enum ShapeGroupEnum {
4
+ Line = "line",
5
+ Rectangle = "rectangle",
6
+ BasicShape = "basicShape",
7
+ BlockArrow = "blockArrow",
8
+ EquationShape = "equationShape",
9
+ Flowchart = "flowchart",
10
+ StarAndBanner = "starAndBanner",
11
+ Callout = "callout",
12
+ Other = "other"
13
+ }
14
+ export declare const shapeTypeOptions: Array<{
15
+ group: ShapeGroupEnum;
16
+ type: ShapeTypeEnum;
17
+ icon: string;
18
+ name: ShapeLocaleKey;
19
+ endArrow?: boolean;
20
+ startArrow?: boolean;
21
+ horizontal?: boolean;
22
+ vertical?: boolean;
23
+ }>;
24
+ export type ShapeTypeOption = typeof shapeTypeOptions[number];
25
+ export declare function groupShapeOptions(options?: readonly ShapeTypeOption[], excludeGroups?: readonly ShapeGroupEnum[]): Partial<Record<ShapeGroupEnum, ShapeTypeOption[]>>;
@@ -1,29 +1,39 @@
1
- import type { Nullable } from '@univerjs/core';
1
+ import type { ICustomShapeTextData, IShapeRect } from '@univerjs-pro/engine-shape';
2
+ import type { IDocumentData, Nullable } from '@univerjs/core';
2
3
  import type { Editor, IKeyboardEventConfig } from '@univerjs/docs-ui';
3
- import type { DocumentSkeleton } from '@univerjs/engine-render';
4
4
  import type { CSSProperties } from 'react';
5
- import type { IShapeTextEditingParams, IShapeTextEditingServiceLike, IShapeTextEditorAdapter } from './types';
6
- import { ICommandService, VerticalAlign, WrapStrategy } from '@univerjs/core';
5
+ import type { IShapeTextEditingParams, IShapeTextEditingService, IShapeTextEditorAdapter, IShapeTextModel, IShapeTextModelLike } from './types';
6
+ import { HorizontalAlign, ICommandService, VerticalAlign } from '@univerjs/core';
7
+ export { resolveShapeTextEditorBehaviorShapeData, resolveShapeTextEditorWrapStrategy, shouldAllowShapeTextEditorHostSizeShrink, shouldAutoFitShapeTextEditorNoWrap, } from './shape-text-behavior';
7
8
  export interface IShapeTextEditorProps {
8
9
  adapter: IShapeTextEditorAdapter;
9
10
  containerWidth: number;
10
11
  containerHeight: number;
11
12
  editingParams: Nullable<IShapeTextEditingParams>;
12
- editingService: IShapeTextEditingServiceLike;
13
+ editingService: IShapeTextEditingService;
13
14
  editorUnitId: string;
14
15
  scaleX: number;
15
16
  scaleY: number;
16
17
  verticalAlignCommandId?: string;
17
18
  }
18
19
  interface IContentLayout {
20
+ documentMarginTop: number;
19
21
  editorLeft: number;
20
22
  editorTop: number;
21
23
  editorWidth: number;
22
24
  editorHeight: number;
25
+ editorSurfaceWidth?: number;
23
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;
24
33
  export declare function areShapeTextEditorLayoutsEqual(a: IContentLayout, b: IContentLayout): boolean;
25
34
  interface IShapeTextEditorLayoutOptions {
26
35
  actualHeight: number;
36
+ contentWidth?: number;
27
37
  scaleX: number;
28
38
  scaleY: number;
29
39
  textRect: {
@@ -43,6 +53,12 @@ interface IShapeTextEditorLayout {
43
53
  editorHeight: number;
44
54
  pageHeight: number;
45
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;
46
62
  interface IShapeTextEditorHostHeightOptions {
47
63
  hostHeight: number;
48
64
  textRect: {
@@ -73,38 +89,118 @@ interface IShapeTextEditorHostSizeChangeOptions {
73
89
  baselineHeight: number;
74
90
  tolerance?: number;
75
91
  }
76
- export declare function getShapeTextEditorOpticalVerticalOffset(skeleton: DocumentSkeleton, targetHeight: number, verticalAlign?: VerticalAlign): number;
92
+ interface IShapeTextEditorKeyboardOptions {
93
+ commitOnEnter?: boolean;
94
+ cancel?: () => void;
95
+ commit?: () => void;
96
+ currentFontSize?: number;
97
+ }
77
98
  export declare function getShapeTextEditorFocusSessionKey(options: {
78
99
  editorUnitId: string;
79
100
  editingParams: Nullable<IShapeTextEditingParams>;
80
101
  }): string | null;
81
- export declare function resolveShapeTextEditorWrapStrategy(shapeTextData: unknown): WrapStrategy;
102
+ export declare function shouldCompleteShapeTextEditingOnPointerDown(target: EventTarget | null, editorElement: HTMLElement | null): boolean;
103
+ export declare function resolveShapeTextEditorTextRect(options: {
104
+ shapeModel: Pick<IShapeTextModelLike, 'getShapeTextRect'>;
105
+ hostRect: IShapeRect;
106
+ }): IShapeRect;
107
+ export declare function buildShapeTextEditorCommitShapeText(options: {
108
+ dataModel?: IShapeTextModel;
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;
82
153
  export declare function hasShapeTextEditorHostSizeChanged(options: IShapeTextEditorHostSizeChangeOptions): boolean;
83
154
  export declare function resolveShapeTextEditorShouldShrinkHostSize(options: {
84
155
  adapter: Pick<IShapeTextEditorAdapter, 'allowHostSizeShrink' | 'updateHostSize'>;
85
156
  editingParams: Nullable<IShapeTextEditingParams>;
86
157
  }): boolean;
158
+ export declare function shouldDeferShapeTextEditorHostSizeUpdateDuringEditing(options: {
159
+ adapter: Pick<IShapeTextEditorAdapter, 'deferHostSizeUpdateDuringEditing'>;
160
+ editingParams: Nullable<IShapeTextEditingParams>;
161
+ }): boolean;
87
162
  export declare function resolveShapeTextEditorDocumentVerticalAlign(options: {
88
163
  opticalVerticalAlign: boolean;
89
164
  verticalAlign: VerticalAlign;
90
165
  }): VerticalAlign;
91
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
+ };
92
180
  export declare function resolveShapeTextEditorHostHeight(options: IShapeTextEditorHostHeightOptions): number;
93
181
  export declare function resolveShapeTextEditorHostSize(options: IShapeTextEditorHostSizeOptions): {
94
182
  width: number;
95
183
  height: number;
96
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
+ };
97
193
  export declare function getShapeTextEditorContentStyle(leftOrWidth: number, topOrHeight: number, width?: number, height?: number): CSSProperties;
98
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;
99
196
  export declare function applyShapeTextEditorCanvasTransparency(renderer: {
100
197
  engine?: {
101
198
  getCanvasElement?: () => HTMLElement | null;
102
199
  };
103
200
  } | null | undefined | void): void;
104
- export declare function getShapeTextEditorKeyboardConfig(commandService: Pick<ICommandService, 'executeCommand'>, executeUndoRedoCommand?: (commandId: string) => void): IKeyboardEventConfig;
201
+ export declare function getShapeTextEditorKeyboardConfig(commandService: Pick<ICommandService, 'executeCommand'>, executeUndoRedoCommand?: (commandId: string) => void, options?: IShapeTextEditorKeyboardOptions): IKeyboardEventConfig;
105
202
  /**
106
203
  * Shape editor component - second layer DOM.
107
204
  * Handles document editing, content height tracking, and vertical alignment.
108
205
  */
109
206
  export declare const ShapeTextEditor: (props: IShapeTextEditorProps) => import("react").JSX.Element;
110
- export {};
@@ -1,4 +1,4 @@
1
- import type { IShapeTextEditingServiceLike, IShapeTextEditorAdapter, IShapeTextEditorPositionOptions } from './types';
1
+ import type { IShapeTextEditingService, IShapeTextEditorAdapter, IShapeTextEditorPositionOptions } from './types';
2
2
  interface IContainerSize {
3
3
  width: number;
4
4
  height: number;
@@ -9,7 +9,7 @@ export declare function areShapeTextEditorContainerSizesEqual(a: IContainerSize,
9
9
  export interface IShapeTextEditorContainerProps {
10
10
  adapter: IShapeTextEditorAdapter;
11
11
  editorUnitId: string;
12
- editingService: IShapeTextEditingServiceLike;
12
+ editingService: IShapeTextEditingService;
13
13
  positionOptions: IShapeTextEditorPositionOptions;
14
14
  verticalAlignCommandId?: string;
15
15
  }
@@ -1,6 +1,8 @@
1
1
  import type { Nullable } from '@univerjs/core';
2
+ import type { Scene } from '@univerjs/engine-render';
2
3
  import type { ReactNode } from 'react';
3
4
  import type { IShapeTextEditingParams, IShapeTextEditorPositionOptions } from './types';
5
+ import { IRenderManagerService } from '@univerjs/engine-render';
4
6
  export interface IShapePositionWrapperProps {
5
7
  children: ReactNode;
6
8
  editingParams: Nullable<IShapeTextEditingParams>;
@@ -12,6 +14,24 @@ export interface IShapePositionWrapperProps {
12
14
  scaleY: number;
13
15
  }) => void;
14
16
  }
17
+ interface IShapeObjectLike {
18
+ left: number;
19
+ top: number;
20
+ width: number;
21
+ height: number;
22
+ angle?: number;
23
+ onTransformChange$?: {
24
+ subscribeEvent: (listener: () => void) => {
25
+ unsubscribe: () => void;
26
+ };
27
+ };
28
+ }
29
+ interface IShapeTextEditorPointerBounds {
30
+ left: number;
31
+ top: number;
32
+ right: number;
33
+ bottom: number;
34
+ }
15
35
  export declare function isShapeTextEditorPositionReady(editingParams: Nullable<IShapeTextEditingParams>, position: {
16
36
  left: number;
17
37
  top: number;
@@ -21,8 +41,17 @@ export declare function isShapeTextEditorPositionReady(editingParams: Nullable<I
21
41
  scaleX?: number;
22
42
  scaleY?: number;
23
43
  }): boolean;
44
+ export declare function isShapeTextEditorPointerInsidePositionBounds(event: Pick<MouseEvent | PointerEvent, 'clientX' | 'clientY'>, rect: IShapeTextEditorPointerBounds): boolean;
45
+ export declare function isShapeTextEditorPointerInsideContent(target: EventTarget | null, editorElement: HTMLElement | null): boolean;
46
+ export declare function resolveShapeTextEditorPositionTransform(options: {
47
+ editingParams: Nullable<IShapeTextEditingParams>;
48
+ positionOptions: IShapeTextEditorPositionOptions;
49
+ renderUnit: Nullable<ReturnType<IRenderManagerService['getRenderById']>>;
50
+ scene: Nullable<Scene>;
51
+ }): Nullable<IShapeObjectLike>;
24
52
  /**
25
53
  * Position wrapper component that handles shape positioning in DOM.
26
54
  * This is the first layer DOM that tracks shape position with scroll.
27
55
  */
28
56
  export declare const ShapeTextPositionWrapper: import("react").MemoExoticComponent<(props: IShapePositionWrapperProps) => import("react").JSX.Element>;
57
+ export {};
@@ -1,6 +1,6 @@
1
1
  import type { Nullable } from '@univerjs/core';
2
2
  import type { Scene, SpreadsheetSkeleton } from '@univerjs/engine-render';
3
- import type { IShapeTextEditingParams, IShapeTextEditorViewportKeys } from '../types';
3
+ import type { IShapeTextEditingParams, IShapeTextEditorPositionOffset, IShapeTextEditorViewportKeys } from '../types';
4
4
  export interface IShapePosition {
5
5
  left: number;
6
6
  top: number;
@@ -15,6 +15,7 @@ export interface IShapePositionResult {
15
15
  updatePosition: () => void;
16
16
  }
17
17
  export declare function areShapePositionsEqual(a: IShapePosition, b: IShapePosition): boolean;
18
+ export declare function offsetShapePosition(position: IShapePosition, offset: Nullable<IShapeTextEditorPositionOffset>): IShapePosition;
18
19
  /**
19
20
  * Calculate shape position in DOM coordinates.
20
21
  */
@@ -31,6 +32,7 @@ export interface IUseShapePositionOptions {
31
32
  height: number;
32
33
  angle: number;
33
34
  }>;
35
+ getPositionOffset?: () => Nullable<IShapeTextEditorPositionOffset>;
34
36
  }
35
37
  /**
36
38
  * Hook to calculate and track shape position in DOM coordinates.
@@ -0,0 +1,15 @@
1
+ import type { IShapeData, IShapeTextData } from '@univerjs-pro/engine-shape';
2
+ import type { Nullable, WrapStrategy as WrapStrategyType } from '@univerjs/core';
3
+ export declare function createShapeTextBoxShapeData(options: Pick<IShapeData, 'fill' | 'stroke'> & {
4
+ isHorizontal: boolean;
5
+ }): IShapeData;
6
+ export declare function resolveShapeTextEditorBehaviorShapeData(shapeData: Nullable<IShapeData> | undefined, shapeTextData: IShapeTextData): IShapeData;
7
+ export declare function resolveShapeTextEditorWrapStrategy(shapeData: IShapeData, fallbackWrapStrategy?: WrapStrategyType): WrapStrategyType;
8
+ export declare function shouldClipShapeTextDocument(shapeData: IShapeData, wrapStrategy?: WrapStrategyType): boolean;
9
+ export declare function shouldAutoFitShapeTextEditorNoWrap(shapeData: IShapeData): boolean;
10
+ export type ShapeTextFlowAxis = 'width' | 'height';
11
+ /** Text layout is horizontal internally; vertical text rotates it onto height. */
12
+ export declare function resolveShapeTextEditorFlowAxis(shapeData: IShapeData): ShapeTextFlowAxis;
13
+ export declare function shouldAllowShapeTextEditorHostSizeShrink(shapeData: Nullable<IShapeData> | undefined, options?: {
14
+ textLike?: boolean;
15
+ }): boolean;
@@ -1,7 +1,8 @@
1
- import type { IShapeRect } from '@univerjs-pro/engine-shape';
2
- import type { HorizontalAlign, IDocumentData, VerticalAlign } from '@univerjs/core';
3
- import { WrapStrategy } from '@univerjs/core';
1
+ import type { IShapeRect, IShapeText, IShapeTextBodyBehavior } from '@univerjs-pro/engine-shape';
2
+ import type { IDocumentData } from '@univerjs/core';
3
+ import { HorizontalAlign, VerticalAlign, WrapStrategy } from '@univerjs/core';
4
4
  interface IPrepareShapeTextDocumentOptions {
5
+ bodyBehavior?: IShapeTextBodyBehavior;
5
6
  isHorizontal: boolean;
6
7
  textRect: IShapeRect;
7
8
  verticalAlign?: VerticalAlign;
@@ -9,10 +10,14 @@ interface IPrepareShapeTextDocumentOptions {
9
10
  wrapStrategy?: WrapStrategy;
10
11
  }
11
12
  interface IShapeTextDocumentAlignmentOptions {
13
+ bodyBehavior?: IShapeTextBodyBehavior;
12
14
  verticalAlign?: VerticalAlign;
13
15
  horizontalAlign?: HorizontalAlign;
14
16
  }
17
+ export declare function plainShapeTextToDocumentData(shapeText: IShapeText, id?: string): IDocumentData;
15
18
  export declare function resolveShapeTextDocumentAlignment(documentData: IDocumentData, fallback?: IShapeTextDocumentAlignmentOptions): IShapeTextDocumentAlignmentOptions;
16
19
  export declare function prepareShapeTextDocumentData(documentData: IDocumentData, options: IPrepareShapeTextDocumentOptions): IDocumentData;
20
+ export declare function resolveShapeTextDocumentPageHeight(documentData: IDocumentData, viewportHeight: number): number;
17
21
  export declare function stripShapeTextDocumentLayout(documentData: IDocumentData, options?: IShapeTextDocumentAlignmentOptions): IDocumentData;
22
+ export declare function createEditableShapeTextDocumentDataCopy(documentData: IDocumentData): IDocumentData;
18
23
  export {};
@@ -0,0 +1,4 @@
1
+ export declare const SHAPE_TEXT_EDITOR_HYPERLINK_EDIT_OPERATION_ID = "doc.operation.show-hyper-link-edit-popup";
2
+ export declare const SHAPE_TEXT_EDITOR_CALLOUT_COMMAND_ID = "docs-callout.command.insert";
3
+ export declare const SHAPE_TEXT_EDITOR_CODE_COMMAND_ID = "docs-code.command.insert";
4
+ export declare const SHAPE_TEXT_EDITOR_QUOTE_COMMAND_ID = "docs-quote.command.insert";
@@ -0,0 +1,24 @@
1
+ import type { DocumentSkeleton } from '@univerjs/engine-render';
2
+ import { VerticalAlign } from '@univerjs/core';
3
+ export interface IResolveShapeTextVerticalOffsetOptions {
4
+ contentHeight: number;
5
+ verticalAlign?: VerticalAlign;
6
+ viewportHeight: number;
7
+ }
8
+ export interface IShapeTextDocumentRenderLayout {
9
+ clipHeight: number;
10
+ clipTop: number;
11
+ contentHeight: number;
12
+ contentVerticalOffset: number;
13
+ marginTop: number;
14
+ verticalOffset: number;
15
+ }
16
+ export interface IResolveShapeTextDocumentRenderLayoutOptions extends IResolveShapeTextVerticalOffsetOptions {
17
+ opticalVerticalOffset?: number;
18
+ verticalOffset?: number;
19
+ }
20
+ export declare function isShapeTextOpticalVerticalAlignEnabled(value: unknown): boolean;
21
+ export declare function resolveShapeTextVerticalOffset(options: IResolveShapeTextVerticalOffsetOptions): number;
22
+ export declare function resolveShapeTextDocumentRenderLayout(options: IResolveShapeTextDocumentRenderLayoutOptions): IShapeTextDocumentRenderLayout;
23
+ export declare function getShapeTextContentHeight(skeleton: DocumentSkeleton, fallbackHeight?: number): number;
24
+ export declare function getShapeTextOpticalVerticalOffset(skeleton: DocumentSkeleton, targetHeight: number, verticalAlign?: VerticalAlign): number;
@@ -0,0 +1,24 @@
1
+ import type { ShapeTextHorizontalAnchor, ShapeTextWrapType } from '@univerjs-pro/engine-shape';
2
+ import type { IDocumentData } from '@univerjs/core';
3
+ import { HorizontalAlign } from '@univerjs/core';
4
+ export interface IShapeTextNoWrapRect {
5
+ left: number;
6
+ top: number;
7
+ width: number;
8
+ height: number;
9
+ }
10
+ export interface IShapeTextNoWrapLayout {
11
+ contentWidth: number;
12
+ measureAsNoWrap: boolean;
13
+ textRect: IShapeTextNoWrapRect;
14
+ }
15
+ export interface IResolveShapeTextNoWrapLayoutOptions {
16
+ documentData?: IDocumentData;
17
+ horizontalAlign?: HorizontalAlign;
18
+ horizontalAnchor?: ShapeTextHorizontalAnchor;
19
+ isHorizontal?: boolean;
20
+ textRect: IShapeTextNoWrapRect;
21
+ textWrap?: ShapeTextWrapType;
22
+ widthBuffer?: number;
23
+ }
24
+ export declare function resolveShapeTextNoWrapLayout(options: IResolveShapeTextNoWrapLayoutOptions): IShapeTextNoWrapLayout;