@univerjs/docs-ui 1.0.0-alpha.8 → 1.0.0-beta.1

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/lib/cjs/index.js +1660 -1123
  2. package/lib/cjs/locale/ar-SA.js +17 -8
  3. package/lib/cjs/locale/ca-ES.js +17 -8
  4. package/lib/cjs/locale/de-DE.js +17 -8
  5. package/lib/cjs/locale/en-US.js +17 -8
  6. package/lib/cjs/locale/es-ES.js +17 -8
  7. package/lib/cjs/locale/fa-IR.js +17 -8
  8. package/lib/cjs/locale/fr-FR.js +17 -8
  9. package/lib/cjs/locale/id-ID.js +17 -8
  10. package/lib/cjs/locale/it-IT.js +17 -8
  11. package/lib/cjs/locale/ja-JP.js +17 -8
  12. package/lib/cjs/locale/ko-KR.js +17 -8
  13. package/lib/cjs/locale/pl-PL.js +17 -8
  14. package/lib/cjs/locale/pt-BR.js +17 -8
  15. package/lib/cjs/locale/ru-RU.js +17 -8
  16. package/lib/cjs/locale/sk-SK.js +17 -8
  17. package/lib/cjs/locale/vi-VN.js +17 -8
  18. package/lib/cjs/locale/zh-CN.js +17 -8
  19. package/lib/cjs/locale/zh-HK.js +18 -9
  20. package/lib/cjs/locale/zh-TW.js +18 -9
  21. package/lib/es/index.js +1662 -1127
  22. package/lib/es/locale/ar-SA.js +17 -8
  23. package/lib/es/locale/ca-ES.js +17 -8
  24. package/lib/es/locale/de-DE.js +17 -8
  25. package/lib/es/locale/en-US.js +17 -8
  26. package/lib/es/locale/es-ES.js +17 -8
  27. package/lib/es/locale/fa-IR.js +17 -8
  28. package/lib/es/locale/fr-FR.js +17 -8
  29. package/lib/es/locale/id-ID.js +17 -8
  30. package/lib/es/locale/it-IT.js +17 -8
  31. package/lib/es/locale/ja-JP.js +17 -8
  32. package/lib/es/locale/ko-KR.js +17 -8
  33. package/lib/es/locale/pl-PL.js +17 -8
  34. package/lib/es/locale/pt-BR.js +17 -8
  35. package/lib/es/locale/ru-RU.js +17 -8
  36. package/lib/es/locale/sk-SK.js +17 -8
  37. package/lib/es/locale/vi-VN.js +17 -8
  38. package/lib/es/locale/zh-CN.js +17 -8
  39. package/lib/es/locale/zh-HK.js +18 -9
  40. package/lib/es/locale/zh-TW.js +18 -9
  41. package/lib/index.css +165 -17
  42. package/lib/index.js +1662 -1127
  43. package/lib/locale/ar-SA.js +17 -8
  44. package/lib/locale/ca-ES.js +17 -8
  45. package/lib/locale/de-DE.js +17 -8
  46. package/lib/locale/en-US.js +17 -8
  47. package/lib/locale/es-ES.js +17 -8
  48. package/lib/locale/fa-IR.js +17 -8
  49. package/lib/locale/fr-FR.js +17 -8
  50. package/lib/locale/id-ID.js +17 -8
  51. package/lib/locale/it-IT.js +17 -8
  52. package/lib/locale/ja-JP.js +17 -8
  53. package/lib/locale/ko-KR.js +17 -8
  54. package/lib/locale/pl-PL.js +17 -8
  55. package/lib/locale/pt-BR.js +17 -8
  56. package/lib/locale/ru-RU.js +17 -8
  57. package/lib/locale/sk-SK.js +17 -8
  58. package/lib/locale/vi-VN.js +17 -8
  59. package/lib/locale/zh-CN.js +17 -8
  60. package/lib/locale/zh-HK.js +18 -9
  61. package/lib/locale/zh-TW.js +18 -9
  62. package/lib/types/commands/commands/break-line.command.d.ts +5 -1
  63. package/lib/types/commands/commands/clipboard.inner.command.d.ts +8 -2
  64. package/lib/types/commands/commands/doc-horizontal-line.command.d.ts +2 -1
  65. package/lib/types/commands/commands/doc-select-all.command.d.ts +2 -0
  66. package/lib/types/commands/commands/replace-content.command.d.ts +1 -0
  67. package/lib/types/config/config.d.ts +1 -0
  68. package/lib/types/controllers/render-controllers/doc-ime-input.controller.d.ts +3 -2
  69. package/lib/types/controllers/render-controllers/doc-input.controller.d.ts +1 -1
  70. package/lib/types/controllers/render-controllers/doc-paragraph-placeholder.render-controller.d.ts +1 -1
  71. package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +2 -0
  72. package/lib/types/embed-docs-custom-block-bleed.d.ts +2 -0
  73. package/lib/types/embed-host-anchor.d.ts +2 -0
  74. package/lib/types/index.d.ts +1 -1
  75. package/lib/types/locale/en-US.d.ts +16 -7
  76. package/lib/types/menu/paragraph-menu.d.ts +1 -1
  77. package/lib/types/services/doc-ime-input-manager.service.d.ts +17 -0
  78. package/lib/types/services/doc-menu-style.service.d.ts +3 -2
  79. package/lib/types/services/doc-render-background.d.ts +1 -1
  80. package/lib/types/services/editor/editor-manager.service.d.ts +1 -0
  81. package/lib/types/services/editor/editor.d.ts +2 -0
  82. package/lib/types/services/selection/doc-selection-render.service.d.ts +2 -0
  83. package/lib/types/services/selection/text-range.d.ts +3 -0
  84. package/lib/types/views/RichTextEditor.d.ts +2 -0
  85. package/lib/types/views/doc-statistics/DocStatistics.d.ts +16 -0
  86. package/lib/types/views/doc-statistics/use-doc-statistics.d.ts +30 -0
  87. package/lib/types/views/list-type-picker/Picker.d.ts +1 -4
  88. package/lib/types/views/rich-text-editor/hooks/use-editor.d.ts +1 -0
  89. package/lib/umd/index.js +9 -9
  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 +10 -10
@@ -16,8 +16,6 @@
16
16
  declare const locale: {
17
17
  'docs-ui': {
18
18
  toolbar: {
19
- undo: string;
20
- redo: string;
21
19
  font: string;
22
20
  fontSize: string;
23
21
  bold: string;
@@ -42,7 +40,6 @@ declare const locale: {
42
40
  order: string;
43
41
  unorder: string;
44
42
  checklist: string;
45
- documentFlavor: string;
46
43
  alignLeft: string;
47
44
  alignCenter: string;
48
45
  alignRight: string;
@@ -92,6 +89,22 @@ declare const locale: {
92
89
  closeHeaderFooter: string;
93
90
  disableText: string;
94
91
  };
92
+ statistics: {
93
+ title: string;
94
+ open: string;
95
+ document: string;
96
+ selection: string;
97
+ wordCount: string;
98
+ selectedWords: string;
99
+ pages: string;
100
+ words: string;
101
+ charactersWithoutSpaces: string;
102
+ charactersWithSpaces: string;
103
+ paragraphs: string;
104
+ lines: string;
105
+ nonAsianWords: string;
106
+ asianCharactersAndKoreanWords: string;
107
+ };
95
108
  placeholder: {
96
109
  heading1: string;
97
110
  heading2: string;
@@ -127,7 +140,6 @@ declare const locale: {
127
140
  multiSpace: string;
128
141
  atLeast: string;
129
142
  exactly: string;
130
- fixedValue: string;
131
143
  };
132
144
  sectionSetting: {
133
145
  selectedSections: string;
@@ -174,9 +186,6 @@ declare const locale: {
174
186
  };
175
187
  'page-settings': {
176
188
  'document-setting': string;
177
- mode: string;
178
- 'modern-mode': string;
179
- 'classic-mode': string;
180
189
  'modern-width': string;
181
190
  'modern-width-narrow': string;
182
191
  'modern-width-medium': string;
@@ -18,7 +18,7 @@ import type { IMenuButtonItem, IMenuItem, IMenuSelectorItem } from '@univerjs/ui
18
18
  import type { LocaleKey } from '../locale/types';
19
19
  export declare const TEXT_COLORS: string[];
20
20
  export declare const TEXT_COLOR_SWATCH_ICONS: readonly ["DocParagraphTextColorSwatchIcon.0", "DocParagraphTextColorSwatchIcon.1", "DocParagraphTextColorSwatchIcon.2", "DocParagraphTextColorSwatchIcon.3", "DocParagraphTextColorSwatchIcon.4", "DocParagraphTextColorSwatchIcon.5", "DocParagraphTextColorSwatchIcon.6"];
21
- export declare const BACKGROUND_COLOR_SWATCH_ICONS: readonly ["DocParagraphBackgroundColorSwatchIcon.0", "DocParagraphBackgroundColorSwatchIcon.1", "DocParagraphBackgroundColorSwatchIcon.2", "DocParagraphBackgroundColorSwatchIcon.3", "DocParagraphBackgroundColorSwatchIcon.4", "DocParagraphBackgroundColorSwatchIcon.5", "DocParagraphBackgroundColorSwatchIcon.6", "DocParagraphBackgroundColorSwatchIcon.7", "DocParagraphBackgroundColorSwatchIcon.8", "DocParagraphBackgroundColorSwatchIcon.9", "DocParagraphBackgroundColorSwatchIcon.10", "DocParagraphBackgroundColorSwatchIcon.11", "DocParagraphBackgroundColorSwatchIcon.12", "DocParagraphBackgroundColorSwatchIcon.13", "DocParagraphBackgroundColorSwatchIcon.14", "DocParagraphBackgroundColorSwatchIcon.15"];
21
+ export declare const BACKGROUND_COLOR_SWATCH_ICONS: readonly ["DocParagraphBackgroundColorSwatchIcon.0", "DocParagraphBackgroundColorSwatchIcon.1", "DocParagraphBackgroundColorSwatchIcon.2", "DocParagraphBackgroundColorSwatchIcon.3", "DocParagraphBackgroundColorSwatchIcon.4", "DocParagraphBackgroundColorSwatchIcon.5", "DocParagraphBackgroundColorSwatchIcon.6", "DocParagraphBackgroundColorSwatchIcon.7", "DocParagraphBackgroundColorSwatchIcon.8", "DocParagraphBackgroundColorSwatchIcon.9", "DocParagraphBackgroundColorSwatchIcon.10", "DocParagraphBackgroundColorSwatchIcon.11", "DocParagraphBackgroundColorSwatchIcon.12", "DocParagraphBackgroundColorSwatchIcon.13", "DocParagraphBackgroundColorSwatchIcon.14"];
22
22
  export declare function H1HeadingMenuItemFactory(accessor: IAccessor): IMenuItem<LocaleKey>;
23
23
  export declare function H2HeadingMenuItemFactory(accessor: IAccessor): IMenuItem<LocaleKey>;
24
24
  export declare function H3HeadingMenuItemFactory(accessor: IAccessor): IMenuItem<LocaleKey>;
@@ -24,6 +24,9 @@ interface ICacheParams {
24
24
  export declare class DocIMEInputManagerService extends RxDisposable implements IRenderModule {
25
25
  private readonly _context;
26
26
  private _previousActiveRange;
27
+ private _previousDocRanges;
28
+ private _compositionRange;
29
+ private _previousSelectionOptions;
27
30
  private _undoMutationParamsCache;
28
31
  private _redoMutationParamsCache;
29
32
  constructor(_context: IRenderContext<DocumentDataModel>);
@@ -35,11 +38,25 @@ export declare class DocIMEInputManagerService extends RxDisposable implements I
35
38
  setUndoRedoMutationParamsCache({ undoCache, redoCache }: ICacheParams): void;
36
39
  getActiveRange(): Nullable<ITextRangeWithStyle>;
37
40
  setActiveRange(range: Nullable<ITextRangeWithStyle>): void;
41
+ getCompositionRange(): Nullable<ITextRangeWithStyle>;
42
+ setCompositionRange(range: Nullable<ITextRangeWithStyle>): void;
43
+ getPreviousDocRanges(): ITextRangeWithStyle[];
44
+ setPreviousDocRanges(ranges: ITextRangeWithStyle[]): void;
45
+ getPreviousSelectionOptions(): Nullable<{
46
+ [key: string]: boolean;
47
+ }>;
48
+ setPreviousSelectionOptions(options: Nullable<{
49
+ [key: string]: boolean;
50
+ }>): void;
38
51
  pushUndoRedoMutationParams(undoParams: IRichTextEditingMutationParams, redoParams: IRichTextEditingMutationParams): void;
39
52
  fetchComposedUndoRedoMutationParams(): {
40
53
  redoMutationParams: IRichTextEditingMutationParams;
41
54
  undoMutationParams: IRichTextEditingMutationParams;
42
55
  previousActiveRange: ITextRangeWithStyle;
56
+ previousDocRanges: ITextRangeWithStyle[];
57
+ previousSelectionOptions: Nullable<{
58
+ [key: string]: boolean;
59
+ }>;
43
60
  } | null;
44
61
  dispose(): void;
45
62
  }
@@ -14,15 +14,16 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { ITextStyle, Nullable } from '@univerjs/core';
17
- import { Disposable, IUniverInstanceService } from '@univerjs/core';
17
+ import { Disposable, IUniverInstanceService, ThemeService } from '@univerjs/core';
18
18
  import { DocSelectionManagerService } from '@univerjs/docs';
19
19
  import { IRenderManagerService } from '@univerjs/engine-render';
20
20
  export declare class DocMenuStyleService extends Disposable {
21
21
  private readonly _textSelectionManagerService;
22
22
  private readonly _univerInstanceService;
23
23
  private readonly _renderManagerService;
24
+ private readonly _themeService;
24
25
  private _cacheStyle;
25
- constructor(_textSelectionManagerService: DocSelectionManagerService, _univerInstanceService: IUniverInstanceService, _renderManagerService: IRenderManagerService);
26
+ constructor(_textSelectionManagerService: DocSelectionManagerService, _univerInstanceService: IUniverInstanceService, _renderManagerService: IRenderManagerService, _themeService: ThemeService);
26
27
  private _init;
27
28
  private _listenDocRangeChange;
28
29
  getStyleCache(): Nullable<ITextStyle>;
@@ -26,4 +26,4 @@ export interface IResolvedDocRenderBackground {
26
26
  docBackgroundFillColor?: string;
27
27
  }
28
28
  export declare function resolveDocRenderBackground(options: IResolveDocRenderBackgroundOptions): IResolvedDocRenderBackground;
29
- export declare function getDefaultDocCanvasBackgroundColor(documentFlavor?: DocumentFlavor, isEditor?: boolean): "#fff" | "transparent" | "#fafafa";
29
+ export declare function getDefaultDocCanvasBackgroundColor(documentFlavor?: DocumentFlavor, isEditor?: boolean): "transparent" | "var(--univer-gray-100)" | "var(--univer-gray-0)";
@@ -23,6 +23,7 @@ import { IRenderManagerService } from '@univerjs/engine-render';
23
23
  import { Editor } from './editor';
24
24
  export interface IEditorRenderConfig {
25
25
  canvasStyle: IEditorCanvasStyle;
26
+ preserveHostFocus?: boolean;
26
27
  scrollBar?: boolean;
27
28
  backScrollOffset?: number;
28
29
  }
@@ -55,6 +55,8 @@ export interface IEditorCanvasStyle {
55
55
  }
56
56
  export interface IEditorConfigParams {
57
57
  initialSnapshot: IDocumentData;
58
+ /** Keep the globally focused unit on the editor's host while this editor receives input focus. */
59
+ preserveHostFocus?: boolean;
58
60
  cancelDefaultResizeListener?: boolean;
59
61
  canvasStyle?: IEditorCanvasStyle;
60
62
  autofocus?: boolean;
@@ -86,6 +86,7 @@ export declare class DocSelectionRenderService extends RxDisposable implements I
86
86
  get isOnPointerEvent(): boolean;
87
87
  get isFocusing(): boolean;
88
88
  get canFocusing(): boolean;
89
+ cancelPointerSelection(): void;
89
90
  constructor(_context: IRenderContext<DocumentDataModel>, _layoutService: ILayoutService, _logService: ILogService, _univerInstanceService: IUniverInstanceService, _docSkeletonManagerService: DocSkeletonManagerService, _embedInteractionBoundaryService?: IDocEmbedInteractionBoundaryService | undefined, _embedRuntimeFocusCoordinator?: IDocEmbedRuntimeFocusCoordinator | undefined);
90
91
  private _listenCurrentUnitChange;
91
92
  get activeViewPort(): import("@univerjs/engine-render").Viewport;
@@ -134,6 +135,7 @@ export declare class DocSelectionRenderService extends RxDisposable implements I
134
135
  private _removeAllTextRanges;
135
136
  private _removeAllRectRanges;
136
137
  private _removeAllCollapsedTextRanges;
138
+ private _hideCollapsedCaretsForVisibleSelection;
137
139
  private _deactivateAllTextRanges;
138
140
  private _deactivateAllRectRanges;
139
141
  private _addTextRangesToCache;
@@ -47,6 +47,7 @@ export declare class TextRange implements IDocRange {
47
47
  private _anchorShape;
48
48
  private _cursorList;
49
49
  private _anchorBlinkTimer;
50
+ private _anchorActiveStroke;
50
51
  constructor(_scene: Scene, _document: Documents, _docSkeleton: DocumentSkeleton, anchorNodePosition?: Nullable<INodePosition>, focusNodePosition?: Nullable<INodePosition>, style?: ITextSelectionStyle, _segmentId?: string, _segmentPage?: number);
51
52
  private _anchorBlink;
52
53
  get startOffset(): number | undefined;
@@ -76,5 +77,7 @@ export declare class TextRange implements IDocRange {
76
77
  private _isCollapsed;
77
78
  private _createOrUpdateRange;
78
79
  private _createOrUpdateAnchor;
80
+ private _getAnchorActiveStroke;
81
+ private _getAnchorBackgroundColor;
79
82
  private _setCursorList;
80
83
  }
@@ -23,6 +23,8 @@ export interface IRichTextEditorProps {
23
23
  onFocusChange?: (isFocus: boolean, newValue?: string) => void;
24
24
  initialValue?: IDocumentData | string;
25
25
  onClickOutside?: () => void;
26
+ /** Keep the globally focused unit on the editor's host while this editor receives input focus. */
27
+ preserveHostFocus?: boolean;
26
28
  keyboardEventConfig?: IKeyboardEventConfig;
27
29
  moveCursor?: boolean;
28
30
  style?: CSSProperties;
@@ -0,0 +1,16 @@
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
+ export declare function DocStatistics(): import("react").JSX.Element;
@@ -0,0 +1,30 @@
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 { IDocumentStatistics, ITextRangeParam } from '@univerjs/core';
17
+ import type { DocumentSkeleton } from '@univerjs/engine-render';
18
+ interface IDocLayoutStatistics {
19
+ pages: number;
20
+ lines: number;
21
+ }
22
+ export interface IDocStatisticsViewState {
23
+ document: IDocumentStatistics & IDocLayoutStatistics;
24
+ selection: (IDocumentStatistics & IDocLayoutStatistics) | null;
25
+ loading: boolean;
26
+ showPages: boolean;
27
+ }
28
+ export declare function getDocLayoutStatistics(skeleton: DocumentSkeleton | null, ranges?: Readonly<ITextRangeParam>[], calculatePages?: boolean): IDocLayoutStatistics;
29
+ export declare function useDocStatistics(calculateLayout?: boolean): IDocStatisticsViewState;
30
+ export {};
@@ -19,10 +19,7 @@ export interface IListTypePickerBaseProps {
19
19
  onChange: (value: PresetListType | undefined) => void;
20
20
  }
21
21
  interface IListTypePickerProps extends IListTypePickerBaseProps {
22
- options: {
23
- value: PresetListType;
24
- img: string;
25
- }[];
22
+ options: PresetListType[];
26
23
  }
27
24
  export declare const ListTypePicker: (props: IListTypePickerProps) => import("react").JSX.Element;
28
25
  export declare const OrderListTypePicker: (props: IListTypePickerBaseProps) => import("react").JSX.Element;
@@ -20,6 +20,7 @@ export interface IUseEditorProps {
20
20
  editorId: string;
21
21
  initialValue: Nullable<IDocumentData | string>;
22
22
  container: RefObject<HTMLDivElement>;
23
+ preserveHostFocus?: boolean;
23
24
  autoFocus?: boolean;
24
25
  isSingle?: boolean;
25
26
  canvasStyle?: IEditorCanvasStyle;