@univerjs/docs-ui 0.2.15 → 0.3.0-alpha.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.
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-panel{padding-top:20px;font-size:var(--font-size-sm)}.univer-options-section{margin-top:10px;padding-bottom:10px}.univer-options-form-item{display:block;margin-bottom:5px}.univer-options-input{width:80%;margin-top:5px}.univer-options-margin-setting{display:flex}.univer-doc-list-type-picker{display:flex;flex-direction:row;justify-content:space-between;flex-wrap:wrap;padding:var(--padding-sm);width:240px;margin-bottom:-var(--margin-xs)}.univer-doc-list-type-picker-item{width:72px;height:81px;border-radius:4px;border:1px solid rgb(var(--border-color));margin-bottom:var(--margin-xs)}.univer-doc-list-type-picker-item:hover,.univer-doc-list-type-picker-item-active{border:1px solid rgb(var(--blue-400))}.univer-doc-count-bar{display:flex;flex:0 0 260px;justify-content:flex-end}.univer-doc-footer-container{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:0 var(--padding-xl)}.univer-paragraph-setting-icon-list{display:flex;width:100%;padding:4px;align-items:center;gap:4px;justify-content:space-between;border:1px solid var(---Grey-200, #e5e5e5);border-radius:var(--radius-m, 6px)}.univer-paragraph-setting-icon-list-item{padding:4px 14px;border-radius:4px;background:none;display:flex;justify-content:center;align-items:center;cursor:pointer}.univer-paragraph-setting-icon-list-item:hover{background:var(--black-6, rgba(30, 34, 43, .06))}.univer-paragraph-setting-icon-list-item.univer-paragraph-setting-icon-list-active{background:var(--black-9, rgba(30, 34, 43, .09))}.univer-paragraph-setting-title{margin-top:var(--margin-base);font-size:13px;color:#1e222b;font-weight:500}.univer-paragraph-setting-label{font-size:12px;margin-top:var(--margin-sm);color:#1e222b;font-weight:400}.univer-paragraph-setting-mt-base{margin-top:var(--margin-base)}.univer-paragraph-setting-flex-col{display:flex;justify-content:space-between;align-items:center}.univer-paragraph-setting-space-line{display:flex;flex-direction:column;gap:6px}.univer-create{padding:20px auto;display:flex;align-content:center;justify-content:space-between}.univer-create-item{display:flex;align-items:center}.univer-create-label{margin-right:5px}.univer-create-input{width:110px}
1
+ .univer-text-editor-container{position:relative;width:100%;height:30px;user-select:none;border:1px solid rgb(var(--border-color));transition:all .15s;border-radius:var(--border-radius-base)}.univer-text-editor-container:hover,.univer-text-editor-container:active,.univer-text-editor-container-active,.univer-text-editor-container-active:hover{border:1px solid rgb(var(--hyacinth-500))}.univer-text-editor-container-error,.univer-text-editor-container-error:hover{border:1px solid rgb(var(--red-400))}.univer-text-editor-container-disabled,.univer-text-editor-container-disabled:hover{border-color:rgb(var(--grey-100))}.univer-text-editor-container-placeholder{position:absolute;top:49%;left:5px;transform:translateY(-50%);color:rgb(var(--grey-400));font-size:var(--font-size-xs);pointer-events:none}.univer-text-editor-validation-error{position:absolute;top:-16px;font-size:10px;color:rgb(var(--red-400))}.univer-range-selector{overflow:hidden;display:flex;align-items:center;justify-content:space-between;color:rgb(var(--grey-600));border:1px solid rgb(var(--border-color));border-radius:var(--border-radius-base);width:220px;height:28px}.univer-range-selector-editor{position:relative;user-select:none;width:100%;height:100%;border:0;outline:0}.univer-range-selector-icon{cursor:pointer;display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;margin-right:4px;font-size:var(--font-size-lg);color:rgb(var(--text-color));background-color:transparent;border:none;border-radius:var(--border-radius-base);outline:none}.univer-range-selector-icon:not([disabled]):hover{background-color:rgb(var(--grey-100))}.univer-range-selector-icon[disabled]{cursor:not-allowed;color:rgb(var(--grey-200))}.univer-range-selector:hover,.univer-range-selector-active{border-color:rgb(var(--hyacinth-500))}.univer-range-selector-active .univer-range-selector-icon{color:rgb(var(--hyacinth-500))}.univer-range-selector-error{border-color:rgb(var(--red-400))}.univer-range-selector-error .univer-range-selector-icon{color:rgb(var(--red-400))}.univer-range-selector-error:hover{border-color:rgb(var(--red-400))}.univer-range-selector-disabled{border-color:rgb(var(--grey-100))}.univer-range-selector-disabled .univer-range-selector-icon{color:rgb(var(--grey-100))}.univer-range-selector-disabled:hover{border-color:rgb(var(--grey-100))}.univer-range-selector-modal{position:relative;max-height:500px;overflow:hidden;overflow-y:auto}.univer-range-selector-modal-container{display:flex;flex-direction:row;align-items:center;margin-bottom:10px}.univer-range-selector-modal-container-input{display:inline-block;width:280px}.univer-range-selector-modal-container-input-active{border-color:rgb(var(--hyacinth-500))}.univer-range-selector-modal-container-button{display:inline-block;text-align:center;width:28px}.univer-range-selector-modal-container-button:hover{cursor:pointer;color:rgb(var(--hyacinth-500))}.univer-range-selector-modal-container-delete-button{margin:auto}.univer-range-selector-modal-add{position:relative;width:300px;margin-top:5px;text-align:left;color:rgb(var(--hyacinth-500));font-size:var(--font-size-xs)}.univer-range-selector-modal-add .univer-range-selector-modal-add-button{display:flex;align-items:center;justify-content:center}.univer-range-selector-modal-add .univer-range-selector-modal-add-button:hover{cursor:pointer;background-color:rgb(var(--hyacinth-500),.05)}.univer-panel{padding-top:20px;font-size:var(--font-size-sm)}.univer-options-section{margin-top:10px;padding-bottom:10px}.univer-options-form-item{display:block;margin-bottom:5px}.univer-options-input{width:80%;margin-top:5px}.univer-options-margin-setting{display:flex}.univer-doc-list-type-picker{display:flex;flex-direction:row;justify-content:space-between;flex-wrap:wrap;padding:var(--padding-sm);width:240px;margin-bottom:-var(--margin-xs)}.univer-doc-list-type-picker-item{width:72px;height:81px;border-radius:4px;border:1px solid rgb(var(--border-color));margin-bottom:var(--margin-xs)}.univer-doc-list-type-picker-item:hover,.univer-doc-list-type-picker-item-active{border:1px solid rgb(var(--blue-400))}.univer-doc-count-bar{display:flex;flex:0 0 260px;justify-content:flex-end}.univer-doc-footer-container{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:0 var(--padding-xl)}.univer-paragraph-setting-icon-list{display:flex;width:100%;padding:4px;align-items:center;gap:4px;justify-content:space-between;border:1px solid var(---Grey-200, #e5e5e5);border-radius:var(--radius-m, 6px)}.univer-paragraph-setting-icon-list-item{padding:4px 14px;border-radius:4px;background:none;display:flex;justify-content:center;align-items:center;cursor:pointer}.univer-paragraph-setting-icon-list-item:hover{background:var(--black-6, rgba(30, 34, 43, .06))}.univer-paragraph-setting-icon-list-item.univer-paragraph-setting-icon-list-active{background:var(--black-9, rgba(30, 34, 43, .09))}.univer-paragraph-setting-title{margin-top:var(--margin-base);font-size:13px;color:#1e222b;font-weight:500}.univer-paragraph-setting-label{font-size:12px;margin-top:var(--margin-sm);color:#1e222b;font-weight:400}.univer-paragraph-setting-mt-base{margin-top:var(--margin-base)}.univer-paragraph-setting-flex-col{display:flex;justify-content:space-between;align-items:center}.univer-paragraph-setting-space-line{display:flex;flex-direction:column;gap:6px}.univer-create{padding:20px auto;display:flex;align-content:center;justify-content:space-between}.univer-create-item{display:flex;align-items:center}.univer-create-label{margin-right:5px}.univer-create-input{width:110px}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
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 isElementVisible(element: HTMLElement | null): boolean;
@@ -24,6 +24,7 @@ export declare const CheckListCommand: ICommand<IBulletListCommandParams>;
24
24
  export interface IToggleCheckListCommandParams {
25
25
  index: number;
26
26
  segmentId?: string;
27
+ textRanges?: ITextRangeWithStyle[];
27
28
  }
28
29
  export declare const ToggleCheckListCommand: ICommand<IToggleCheckListCommandParams>;
29
30
  interface IOrderListCommandParams {
@@ -0,0 +1,36 @@
1
+ import { default as React } from 'react';
2
+ import { IDocumentData, Nullable } from '@univerjs/core';
3
+ import { IEditorCanvasStyle } from '../../services/editor/editor';
4
+ type MyComponentProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
5
+ export interface ITextEditorProps {
6
+ id: string;
7
+ className?: string;
8
+ snapshot?: IDocumentData;
9
+ value?: string;
10
+ resizeCallBack?: (editor: Nullable<HTMLDivElement>) => void;
11
+ cancelDefaultResizeListener?: boolean;
12
+ canvasStyle?: IEditorCanvasStyle;
13
+ isSheetEditor?: boolean;
14
+ isFormulaEditor?: boolean;
15
+ isSingle?: boolean;
16
+ isReadonly?: boolean;
17
+ onlyInputFormula?: boolean;
18
+ onlyInputRange?: boolean;
19
+ onlyInputContent?: boolean;
20
+ isSingleChoice?: boolean;
21
+ openForSheetUnitId?: Nullable<string>;
22
+ openForSheetSubUnitId?: Nullable<string>;
23
+ onChange?: (value: Nullable<string>) => void;
24
+ onActive?: (state: boolean) => void;
25
+ onValid?: (state: boolean) => void;
26
+ placeholder?: string;
27
+ isValueValid?: boolean;
28
+ disbaled?: boolean;
29
+ }
30
+ /**
31
+ * The component to render toolbar item label and menu item label.
32
+ * @param props
33
+ * @deprecated The business side encapsulates its own Editor component.
34
+ */
35
+ export declare function TextEditor(props: ITextEditorProps & Omit<MyComponentProps, 'onChange' | 'onActive'>): JSX.Element | null;
36
+ export {};
@@ -0,0 +1,21 @@
1
+ import { default as React } from 'react';
2
+ import { IUnitRangeWithName, Nullable } from '@univerjs/core';
3
+ export interface IRangeSelectorProps {
4
+ id: string;
5
+ value?: string;
6
+ onChange?: (ranges: IUnitRangeWithName[]) => void;
7
+ onActive?: (state: boolean) => void;
8
+ onValid?: (state: boolean) => void;
9
+ isSingleChoice?: boolean;
10
+ isReadonly?: boolean;
11
+ openForSheetUnitId?: Nullable<string>;
12
+ openForSheetSubUnitId?: Nullable<string>;
13
+ width?: number | string;
14
+ size?: 'mini' | 'small' | 'middle' | 'large';
15
+ placeholder?: string;
16
+ className?: string;
17
+ textEditorClassName?: string;
18
+ onSelectorVisibleChange?: (visible: boolean) => void;
19
+ disableInput?: boolean;
20
+ }
21
+ export declare function RangeSelector(props: IRangeSelectorProps): React.JSX.Element;
@@ -1,7 +1,8 @@
1
1
  import { Disposable, ICommandService, IUniverInstanceService, LocaleService, DocumentDataModel } from '@univerjs/core';
2
2
  import { DocSkeletonManagerService } from '@univerjs/docs';
3
3
  import { IRenderManagerService, IRenderContext, IRenderModule } from '@univerjs/engine-render';
4
- import { ComponentManager, IEditorService } from '@univerjs/ui';
4
+ import { ComponentManager } from '@univerjs/ui';
5
+ import { IEditorService } from '../services/editor/editor-manager.service';
5
6
  import { DocSelectionRenderService } from '../services/selection/doc-selection-render.service';
6
7
  export declare enum HeaderFooterType {
7
8
  FIRST_PAGE_HEADER = 0,
@@ -1,7 +1,7 @@
1
1
  import { RxDisposable, DocumentDataModel, ITextRange, Nullable } from '@univerjs/core';
2
2
  import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs';
3
- import { IEditorService } from '@univerjs/ui';
4
3
  import { INodePosition, IRenderContext, IRenderModule } from '@univerjs/engine-render';
4
+ import { IEditorService } from '../../services/editor/editor-manager.service';
5
5
  export declare class DocBackScrollRenderController extends RxDisposable implements IRenderModule {
6
6
  private readonly _context;
7
7
  private readonly _textSelectionManagerService;
@@ -1,7 +1,7 @@
1
1
  import { Disposable, ICommandService, IUniverInstanceService, DocumentDataModel } from '@univerjs/core';
2
2
  import { DocSkeletonManagerService } from '@univerjs/docs';
3
3
  import { IRenderManagerService, IRenderContext, IRenderModule } from '@univerjs/engine-render';
4
- import { IEditorService } from '@univerjs/ui';
4
+ import { IEditorService } from '../../services/editor/editor-manager.service';
5
5
  import { DocSelectionRenderService } from '../../services/selection/doc-selection-render.service';
6
6
  export declare class DocEditorBridgeController extends Disposable implements IRenderModule {
7
7
  private readonly _context;
@@ -1,7 +1,7 @@
1
1
  import { Disposable, ICommandService, IUniverInstanceService, DocumentDataModel } from '@univerjs/core';
2
2
  import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs';
3
- import { IEditorService } from '@univerjs/ui';
4
3
  import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
4
+ import { IEditorService } from '../../services/editor/editor-manager.service';
5
5
  import { DocSelectionRenderService } from '../../services/selection/doc-selection-render.service';
6
6
  export declare class DocSelectionRenderController extends Disposable implements IRenderModule {
7
7
  private readonly _context;
@@ -1,7 +1,7 @@
1
- import { ICommandService, IContextService, RxDisposable, DocumentDataModel } from '@univerjs/core';
1
+ import { ICommandService, IContextService, IUniverInstanceService, RxDisposable, DocumentDataModel } from '@univerjs/core';
2
2
  import { DocSkeletonManagerService } from '@univerjs/docs';
3
3
  import { IRenderManagerService, IRenderContext, IRenderModule } from '@univerjs/engine-render';
4
- import { IEditorService } from '@univerjs/ui';
4
+ import { IEditorService } from '../../services/editor/editor-manager.service';
5
5
  import { DocSelectionRenderService } from '../../services/selection/doc-selection-render.service';
6
6
  export declare class DocRenderController extends RxDisposable implements IRenderModule {
7
7
  private readonly _context;
@@ -11,7 +11,8 @@ export declare class DocRenderController extends RxDisposable implements IRender
11
11
  private readonly _docSkeletonManagerService;
12
12
  private readonly _editorService;
13
13
  private readonly _renderManagerService;
14
- constructor(_context: IRenderContext<DocumentDataModel>, _contextService: IContextService, _commandService: ICommandService, _docSelectionRenderService: DocSelectionRenderService, _docSkeletonManagerService: DocSkeletonManagerService, _editorService: IEditorService, _renderManagerService: IRenderManagerService);
14
+ private readonly _univerInstanceService;
15
+ constructor(_context: IRenderContext<DocumentDataModel>, _contextService: IContextService, _commandService: ICommandService, _docSelectionRenderService: DocSelectionRenderService, _docSkeletonManagerService: DocSkeletonManagerService, _editorService: IEditorService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService);
15
16
  reRender(unitId: string): void;
16
17
  private _addNewRender;
17
18
  private _addComponent;
@@ -1,8 +1,8 @@
1
1
  import { Disposable, ICommandService, IContextService, IUniverInstanceService, DocumentDataModel } from '@univerjs/core';
2
2
  import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs';
3
- import { IEditorService } from '@univerjs/ui';
4
3
  import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
5
4
  import { DocPageLayoutService } from '../../services/doc-page-layout.service';
5
+ import { IEditorService } from '../../services/editor/editor-manager.service';
6
6
  export declare class DocZoomRenderController extends Disposable implements IRenderModule {
7
7
  private readonly _context;
8
8
  private readonly _contextService;
@@ -1,4 +1,4 @@
1
- import { ICommandService, IConfigService, ILogService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { ICommandService, IConfigService, ILogService, Injector, Plugin } from '@univerjs/core';
2
2
  import { IRenderManagerService } from '@univerjs/engine-render';
3
3
  import { IUniverDocsUIConfig } from './controllers/config.schema';
4
4
  export declare class UniverDocsUIPlugin extends Plugin {
@@ -9,7 +9,6 @@ export declare class UniverDocsUIPlugin extends Plugin {
9
9
  private _logService;
10
10
  private readonly _configService;
11
11
  static pluginName: string;
12
- static type: UniverInstanceType;
13
12
  constructor(_config: Partial<IUniverDocsUIConfig> | undefined, _injector: Injector, _renderManagerSrv: IRenderManagerService, _commandService: ICommandService, _logService: ILogService, _configService: IConfigService);
14
13
  onReady(): void;
15
14
  onRendered(): void;
@@ -23,6 +23,35 @@ export * from './basics/docs-view-key';
23
23
  export { hasParagraphInTable } from './basics/paragraph';
24
24
  export { replaceSelectionFactory } from './basics/replace';
25
25
  export { docDrawingPositionToTransform, transformToDocDrawingPosition } from './basics/transform-position';
26
+ export { getCommandSkeleton, getRichTextEditPath } from './commands/util';
27
+ export { TextEditor } from './components/editor/TextEditor';
28
+ export { RangeSelector } from './components/range-selector/RangeSelector';
29
+ export { DocUIController } from './controllers/doc-ui.controller';
30
+ export { menuSchema } from './controllers/menu.schema';
31
+ export { DocBackScrollRenderController } from './controllers/render-controllers/back-scroll.render-controller';
32
+ export { DocRenderController } from './controllers/render-controllers/doc.render-controller';
33
+ export * from './docs-ui-plugin';
34
+ export * from './services';
35
+ export { IDocClipboardService } from './services/clipboard/clipboard.service';
36
+ export { DocEventManagerService } from './services/doc-event-manager.service';
37
+ export { DocIMEInputManagerService } from './services/doc-ime-input-manager.service';
38
+ export { DocCanvasPopManagerService } from './services/doc-popup-manager.service';
39
+ export { DocStateChangeManagerService } from './services/doc-state-change-manager.service';
40
+ export { DocsRenderService } from './services/docs-render.service';
41
+ export { Editor } from './services/editor/editor';
42
+ export { EditorService, IEditorService } from './services/editor/editor-manager.service';
43
+ export { type IRangeSelectorRange, IRangeSelectorService, RangeSelectorService } from './services/range-selector/range-selector.service';
44
+ export { isInSameTableCell, isValidRectRange, NodePositionConvertToRectRange } from './services/selection/convert-rect-range';
45
+ export { NodePositionConvertToCursor } from './services/selection/convert-text-range';
46
+ export { getOneTextSelectionRange } from './services/selection/convert-text-range';
47
+ export type { IEditorInputConfig } from './services/selection/doc-selection-render.service';
48
+ export { DocSelectionRenderService } from './services/selection/doc-selection-render.service';
49
+ export type { IDocRange } from './services/selection/range-interface';
50
+ export { convertPositionsToRectRanges, RectRange } from './services/selection/rect-range';
51
+ export { getCanvasOffsetByEngine } from './services/selection/selection-utils';
52
+ export { getAnchorBounding, getLineBounding, TEXT_RANGE_LAYER_INDEX, TextRange } from './services/selection/text-range';
53
+ export { whenDocAndEditorFocused } from './shortcuts/utils';
54
+ export { DOC_VERTICAL_PADDING } from './types/const/padding';
26
55
  export { AfterSpaceCommand, EnterCommand, type ITabCommandParams, TabCommand } from './commands/commands/auto-format.command';
27
56
  export { BreakLineCommand } from './commands/commands/break-line.command';
28
57
  export { generateParagraphs } from './commands/commands/break-line.command';
@@ -43,9 +72,9 @@ export { CoverContentCommand, ReplaceContentCommand } from './commands/commands/
43
72
  export { SetDocZoomRatioCommand } from './commands/commands/set-doc-zoom-ratio.command';
44
73
  export { CreateDocTableCommand, type ICreateDocTableCommandParams } from './commands/commands/table/doc-table-create.command';
45
74
  export { DocTableDeleteColumnsCommand, DocTableDeleteRowsCommand, DocTableDeleteTableCommand } from './commands/commands/table/doc-table-delete.command';
46
- export type { IDocTableDeleteColumnsCommandParams, IDocTableDeleteRowsCommandParams, IDocTableDeleteTableCommandParams } from './commands/commands/table/doc-table-delete.command';
47
- export type { IDocTableInsertColumnCommandParams, IDocTableInsertColumnLeftCommandParams, IDocTableInsertColumnRightCommandParams, IDocTableInsertRowAboveCommandParams, IDocTableInsertRowBellowCommandParams, IDocTableInsertRowCommandParams } from './commands/commands/table/doc-table-insert.command';
48
- export { DocTableInsertColumnCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertRowCommand } from './commands/commands/table/doc-table-insert.command';
75
+ export type { IDocTableDeleteColumnsCommandParams, IDocTableDeleteRowsCommandParams, IDocTableDeleteTableCommandParams, } from './commands/commands/table/doc-table-delete.command';
76
+ export type { IDocTableInsertColumnCommandParams, IDocTableInsertColumnLeftCommandParams, IDocTableInsertColumnRightCommandParams, IDocTableInsertRowAboveCommandParams, IDocTableInsertRowBellowCommandParams, IDocTableInsertRowCommandParams, } from './commands/commands/table/doc-table-insert.command';
77
+ export { DocTableInsertColumnCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertRowCommand, } from './commands/commands/table/doc-table-insert.command';
49
78
  export type { IDocTableTabCommandParams } from './commands/commands/table/doc-table-tab.command';
50
79
  export { DocTableTabCommand } from './commands/commands/table/doc-table-tab.command';
51
80
  export { genTableSource, getEmptyTableCell, getEmptyTableRow, getTableColumn } from './commands/commands/table/table';
@@ -54,27 +83,3 @@ export { MoveSelectionOperation } from './commands/operations/doc-cursor.operati
54
83
  export { MoveCursorOperation } from './commands/operations/doc-cursor.operation';
55
84
  export { SelectAllOperation } from './commands/operations/select-all.operation';
56
85
  export { type ISetDocZoomRatioOperationParams, SetDocZoomRatioOperation } from './commands/operations/set-doc-zoom-ratio.operation';
57
- export { getCommandSkeleton, getRichTextEditPath } from './commands/util';
58
- export { DocUIController } from './controllers/doc-ui.controller';
59
- export { menuSchema } from './controllers/menu.schema';
60
- export { DocBackScrollRenderController } from './controllers/render-controllers/back-scroll.render-controller';
61
- export { DocRenderController } from './controllers/render-controllers/doc.render-controller';
62
- export * from './docs-ui-plugin';
63
- export * from './services';
64
- export { IDocClipboardService } from './services/clipboard/clipboard.service';
65
- export { DocEventManagerService } from './services/doc-event-manager.service';
66
- export { DocIMEInputManagerService } from './services/doc-ime-input-manager.service';
67
- export { DocCanvasPopManagerService } from './services/doc-popup-manager.service';
68
- export { DocStateChangeManagerService } from './services/doc-state-change-manager.service';
69
- export { DocsRenderService } from './services/docs-render.service';
70
- export { isInSameTableCell, isValidRectRange, NodePositionConvertToRectRange } from './services/selection/convert-rect-range';
71
- export { NodePositionConvertToCursor } from './services/selection/convert-text-range';
72
- export { getOneTextSelectionRange } from './services/selection/convert-text-range';
73
- export type { IEditorInputConfig } from './services/selection/doc-selection-render.service';
74
- export { DocSelectionRenderService } from './services/selection/doc-selection-render.service';
75
- export type { IDocRange } from './services/selection/range-interface';
76
- export { convertPositionsToRectRanges, RectRange } from './services/selection/rect-range';
77
- export { getCanvasOffsetByEngine } from './services/selection/selection-utils';
78
- export { getAnchorBounding, getLineBounding, TEXT_RANGE_LAYER_INDEX, TextRange } from './services/selection/text-range';
79
- export { whenDocAndEditorFocused } from './shortcuts/utils';
80
- export { DOC_VERTICAL_PADDING } from './types/const/padding';
@@ -0,0 +1,157 @@
1
+ import { Disposable, ICommandService, IContextService, IUndoRedoService, IUniverInstanceService, IDisposable, IDocumentBody, Nullable } from '@univerjs/core';
2
+ import { DocSelectionManagerService } from '@univerjs/docs';
3
+ import { LexerTreeBuilder } from '@univerjs/engine-formula';
4
+ import { IRenderManagerService, ISuccinctDocRangeParam } from '@univerjs/engine-render';
5
+ import { Observable } from 'rxjs';
6
+ import { Editor, IEditorConfigParams, IEditorStateParams } from './editor';
7
+ export interface IEditorSetValueParam {
8
+ editorUnitId: string;
9
+ body: IDocumentBody;
10
+ }
11
+ export interface IEditorInputFormulaParam {
12
+ editorUnitId: string;
13
+ formulaString: string;
14
+ }
15
+ export interface IEditorService {
16
+ getEditor(id?: string): Readonly<Nullable<Editor>>;
17
+ register(config: IEditorConfigParams, container: HTMLDivElement): IDisposable;
18
+ isVisible(id: string): Nullable<boolean>;
19
+ inputFormula$: Observable<IEditorInputFormulaParam>;
20
+ setFormula(formulaString: string): void;
21
+ resize$: Observable<string>;
22
+ resize(id: string): void;
23
+ getAllEditor(): Map<string, Editor>;
24
+ /**
25
+ * The sheet currently being operated on will determine
26
+ * whether to include unitId information in the ref.
27
+ */
28
+ setOperationSheetUnitId(unitId: Nullable<string>): void;
29
+ getOperationSheetUnitId(): Nullable<string>;
30
+ /**
31
+ * The sub-table within the sheet currently being operated on
32
+ * will determine whether to include subUnitId information in the ref.
33
+ */
34
+ setOperationSheetSubUnitId(sheetId: Nullable<string>): void;
35
+ getOperationSheetSubUnitId(): Nullable<string>;
36
+ isEditor(editorUnitId: string): boolean;
37
+ isSheetEditor(editorUnitId: string): boolean;
38
+ closeRangePrompt$: Observable<unknown>;
39
+ closeRangePrompt(): void;
40
+ blur$: Observable<unknown>;
41
+ blur(): void;
42
+ focus$: Observable<ISuccinctDocRangeParam>;
43
+ focus(editorUnitId?: string): void;
44
+ setValue$: Observable<IEditorSetValueParam>;
45
+ valueChange$: Observable<Readonly<Editor>>;
46
+ setValue(val: string, editorUnitId?: string): void;
47
+ setValueNoRefresh(val: string, editorUnitId?: string): void;
48
+ setRichValue(body: IDocumentBody, editorUnitId?: string): void;
49
+ getFirstEditor(): Editor;
50
+ focusStyle$: Observable<Nullable<string>>;
51
+ focusStyle(editorUnitId: Nullable<string>): void;
52
+ refreshValueChange(editorId: string): void;
53
+ checkValueLegality(editorId: string): boolean;
54
+ getValue(id: string): Nullable<string>;
55
+ getRichValue(id: string): Nullable<IDocumentBody>;
56
+ changeSpreadsheetFocusState(state: boolean): void;
57
+ getSpreadsheetFocusState(): boolean;
58
+ selectionChangingState(): boolean;
59
+ singleSelection$: Observable<boolean>;
60
+ singleSelection(state: boolean): void;
61
+ setFocusId(id: Nullable<string>): void;
62
+ getFocusId(): Nullable<string>;
63
+ getFocusEditor(): Readonly<Nullable<Editor>>;
64
+ }
65
+ export declare class EditorService extends Disposable implements IEditorService, IDisposable {
66
+ private readonly _univerInstanceService;
67
+ private readonly _renderManagerService;
68
+ private readonly _lexerTreeBuilder;
69
+ private readonly _docSelectionManagerService;
70
+ private readonly _contextService;
71
+ private readonly _commandService;
72
+ private readonly _undoRedoService;
73
+ private _editors;
74
+ private _focusEditorUnitId;
75
+ private readonly _state$;
76
+ readonly state$: Observable<Nullable<IEditorStateParams>>;
77
+ private _currentSheetUnitId;
78
+ private _currentSheetSubUnitId;
79
+ private readonly _inputFormula$;
80
+ readonly inputFormula$: Observable<IEditorInputFormulaParam>;
81
+ private readonly _resize$;
82
+ readonly resize$: Observable<string>;
83
+ private readonly _closeRangePrompt$;
84
+ readonly closeRangePrompt$: Observable<unknown>;
85
+ private readonly _blur$;
86
+ readonly blur$: Observable<unknown>;
87
+ private readonly _focus$;
88
+ readonly focus$: Observable<ISuccinctDocRangeParam>;
89
+ private readonly _setValue$;
90
+ readonly setValue$: Observable<IEditorSetValueParam>;
91
+ private readonly _valueChange$;
92
+ readonly valueChange$: Observable<Readonly<Editor>>;
93
+ private readonly _focusStyle$;
94
+ readonly focusStyle$: Observable<Nullable<string>>;
95
+ private readonly _singleSelection$;
96
+ readonly singleSelection$: Observable<boolean>;
97
+ private _spreadsheetFocusState;
98
+ constructor(_univerInstanceService: IUniverInstanceService, _renderManagerService: IRenderManagerService, _lexerTreeBuilder: LexerTreeBuilder, _docSelectionManagerService: DocSelectionManagerService, _contextService: IContextService, _commandService: ICommandService, _undoRedoService: IUndoRedoService);
99
+ private _initUniverFocusListener;
100
+ private _blurSheetEditor;
101
+ /** @deprecated */
102
+ setFocusId(id: Nullable<string>): void;
103
+ /** @deprecated */
104
+ getFocusId(): Nullable<string>;
105
+ /** @deprecated */
106
+ getFocusEditor(): Readonly<Nullable<Editor>>;
107
+ isEditor(editorUnitId: string): boolean;
108
+ isSheetEditor(editorUnitId: string): boolean;
109
+ closeRangePrompt(): void;
110
+ /** @deprecated */
111
+ changeSpreadsheetFocusState(state: boolean): void;
112
+ /** @deprecated */
113
+ getSpreadsheetFocusState(): boolean;
114
+ focusStyle(editorUnitId: string): false | undefined;
115
+ singleSelection(state: boolean): void;
116
+ selectionChangingState(): boolean;
117
+ /** @deprecated */
118
+ blur(): void;
119
+ /** @deprecated */
120
+ focus(editorUnitId?: string | undefined): void;
121
+ /** @deprecated */
122
+ setFormula(formulaString: string, editorUnitId?: string): void;
123
+ /** @deprecated */
124
+ setValue(val: string, editorUnitId?: string): void;
125
+ /** @deprecated */
126
+ setValueNoRefresh(val: string, editorUnitId: string): void;
127
+ /** @deprecated */
128
+ getValue(id: string): string | undefined;
129
+ /** @deprecated */
130
+ setRichValue(body: IDocumentBody, editorUnitId?: string): void;
131
+ /** @deprecated */
132
+ getRichValue(id: string): IDocumentBody | undefined;
133
+ dispose(): void;
134
+ getEditor(id?: string): Readonly<Nullable<Editor>>;
135
+ /** @deprecated */
136
+ getAllEditor(): Map<string, Editor>;
137
+ /** @deprecated */
138
+ getFirstEditor(): Editor;
139
+ resize(unitId: string): void;
140
+ isVisible(id: string): boolean | undefined;
141
+ /** @deprecated */
142
+ setOperationSheetUnitId(unitId: Nullable<string>): void;
143
+ /** @deprecated */
144
+ getOperationSheetUnitId(): Nullable<string>;
145
+ /** @deprecated */
146
+ setOperationSheetSubUnitId(sheetId: Nullable<string>): void;
147
+ /** @deprecated */
148
+ getOperationSheetSubUnitId(): Nullable<string>;
149
+ register(config: IEditorConfigParams, container: HTMLDivElement): IDisposable;
150
+ private _unRegister;
151
+ refreshValueChange(editorUnitId: string): void;
152
+ checkValueLegality(editorUnitId: string): boolean;
153
+ private _refreshValueChange;
154
+ private _getCurrentEditorUnitId;
155
+ private _getBlank;
156
+ }
157
+ export declare const IEditorService: import('@wendellhu/redi').IdentifierDecorator<IEditorService>;
@@ -0,0 +1,177 @@
1
+ import { Disposable, DocumentDataModel, ICommandService, IDocumentData, IPosition, IUndoRedoService, IUniverInstanceService, Nullable } from '@univerjs/core';
2
+ import { Observable } from 'rxjs';
3
+ import { DocSelectionManagerService } from '@univerjs/docs';
4
+ import { IDocSelectionInnerParam, IRender, ISuccinctDocRangeParam, ITextRangeWithStyle } from '@univerjs/engine-render';
5
+ import { IEditorInputConfig } from '../selection/doc-selection-render.service';
6
+ interface IEditorEvent {
7
+ target: IEditor;
8
+ data: IDocumentData;
9
+ }
10
+ interface IEditorInputEvent extends IEditorEvent {
11
+ content: string;
12
+ isComposing: boolean;
13
+ }
14
+ interface IEditor {
15
+ change$: Observable<IEditorEvent>;
16
+ input$: Observable<IEditorInputEvent>;
17
+ paste$: Observable<IEditorInputConfig>;
18
+ focus$: Observable<IEditorInputConfig>;
19
+ blur$: Observable<IEditorInputConfig>;
20
+ selectionChange$: Observable<IDocSelectionInnerParam>;
21
+ focus(): void;
22
+ blur(): void;
23
+ isFocus(): boolean;
24
+ select(): void;
25
+ setSelectionRanges(ranges: ISuccinctDocRangeParam[]): void;
26
+ getSelectionRanges(): ITextRangeWithStyle[];
27
+ getEditorId(): string;
28
+ getDocumentData(): IDocumentData;
29
+ setDocumentData(data: IDocumentData): void;
30
+ clearUndoRedoHistory(): void;
31
+ }
32
+ export interface IEditorStateParams extends Partial<IPosition> {
33
+ visible?: boolean;
34
+ }
35
+ export interface IEditorCanvasStyle {
36
+ fontSize?: number;
37
+ }
38
+ export interface IEditorConfigParams {
39
+ initialSnapshot?: IDocumentData;
40
+ cancelDefaultResizeListener?: boolean;
41
+ canvasStyle?: IEditorCanvasStyle;
42
+ autofocus?: boolean;
43
+ readonly?: boolean;
44
+ editorUnitId: string;
45
+ /**
46
+ * @deprecated The implementer makes its own judgment.
47
+ */
48
+ isSheetEditor: boolean;
49
+ /**
50
+ * If the editor is for formula editing.
51
+ * @deprecated this is a temp fix before refactoring editor.
52
+ */
53
+ isFormulaEditor: boolean;
54
+ /**
55
+ * @deprecated The implementer makes its own judgment.
56
+ */
57
+ isSingle: boolean;
58
+ /**
59
+ * @deprecated The implementer makes its own judgment.
60
+ */
61
+ onlyInputFormula: boolean;
62
+ /**
63
+ * @deprecated The implementer makes its own judgment.
64
+ */
65
+ onlyInputRange: boolean;
66
+ /**
67
+ * @deprecated The implementer makes its own judgment.
68
+ */
69
+ onlyInputContent: boolean;
70
+ /**
71
+ * @deprecated The implementer makes its own judgment.
72
+ */
73
+ isSingleChoice: boolean;
74
+ /**
75
+ * @deprecated The implementer makes its own judgment.
76
+ */
77
+ openForSheetUnitId: Nullable<string>;
78
+ /**
79
+ * @deprecated The implementer makes its own judgment.
80
+ */
81
+ openForSheetSubUnitId: Nullable<string>;
82
+ }
83
+ export interface IEditorOptions extends IEditorConfigParams, IEditorStateParams {
84
+ render: IRender;
85
+ documentDataModel: DocumentDataModel;
86
+ editorDom: HTMLDivElement;
87
+ }
88
+ export declare class Editor extends Disposable implements IEditor {
89
+ private _param;
90
+ private _univerInstanceService;
91
+ private _docSelectionManagerService;
92
+ private _commandService;
93
+ private _undoRedoService;
94
+ private readonly _change$;
95
+ change$: Observable<IEditorEvent>;
96
+ private readonly _input$;
97
+ input$: Observable<IEditorInputEvent>;
98
+ private readonly _paste$;
99
+ paste$: Observable<IEditorInputConfig>;
100
+ private _focus;
101
+ private readonly _focus$;
102
+ focus$: Observable<IEditorInputConfig>;
103
+ private readonly _blur$;
104
+ blur$: Observable<IEditorInputConfig>;
105
+ private readonly _selectionChange$;
106
+ selectionChange$: Observable<IDocSelectionInnerParam>;
107
+ private _valueLegality;
108
+ private _openForSheetUnitId;
109
+ private _openForSheetSubUnitId;
110
+ constructor(_param: IEditorOptions, _univerInstanceService: IUniverInstanceService, _docSelectionManagerService: DocSelectionManagerService, _commandService: ICommandService, _undoRedoService: IUndoRedoService);
111
+ private _listenSelection;
112
+ focus(): void;
113
+ blur(): void;
114
+ select(): void;
115
+ setSelectionRanges(ranges: ISuccinctDocRangeParam[]): void;
116
+ getSelectionRanges(): ITextRangeWithStyle[];
117
+ getEditorId(): string;
118
+ getDocumentData(): IDocumentData;
119
+ setDocumentData(data: IDocumentData, textRanges: Nullable<ITextRangeWithStyle[]>): void;
120
+ clearUndoRedoHistory(): void;
121
+ /**
122
+ * @deprecated use getDocumentData.
123
+ */
124
+ get documentDataModel(): DocumentDataModel;
125
+ /**
126
+ * @deprecated use getEditorId.
127
+ */
128
+ get editorUnitId(): string;
129
+ get cancelDefaultResizeListener(): boolean | undefined;
130
+ get render(): IRender;
131
+ isSingleChoice(): boolean;
132
+ /** @deprecated */
133
+ setOpenForSheetUnitId(unitId: Nullable<string>): void;
134
+ /** @deprecated */
135
+ getOpenForSheetUnitId(): Nullable<string>;
136
+ /** @deprecated */
137
+ setOpenForSheetSubUnitId(subUnitId: Nullable<string>): void;
138
+ /** @deprecated */
139
+ getOpenForSheetSubUnitId(): Nullable<string>;
140
+ /** @deprecated */
141
+ isValueLegality(): boolean;
142
+ /** @deprecated */
143
+ setValueLegality(state?: boolean): void;
144
+ isFocus(): boolean;
145
+ /** @deprecated */
146
+ setFocus(state?: boolean): void;
147
+ /** @deprecated */
148
+ isSingle(): boolean;
149
+ isReadOnly(): boolean;
150
+ /** @deprecated */
151
+ onlyInputContent(): boolean;
152
+ /** @deprecated */
153
+ onlyInputFormula(): boolean;
154
+ /** @deprecated */
155
+ onlyInputRange(): boolean;
156
+ getBoundingClientRect(): DOMRect;
157
+ isVisible(): boolean | undefined;
158
+ /** @deprecated */
159
+ isSheetEditor(): boolean;
160
+ /** @deprecated */
161
+ isFormulaEditor(): boolean;
162
+ /**
163
+ * @deprecated use getDocumentData.
164
+ */
165
+ getValue(): string;
166
+ /**
167
+ * @deprecated use getDocumentData.
168
+ */
169
+ getBody(): import('@univerjs/core').IDocumentBody | undefined;
170
+ /**
171
+ * @deprecated.
172
+ */
173
+ update(param: Partial<IEditorOptions>): void;
174
+ verticalAlign(): void;
175
+ updateCanvasStyle(): void;
176
+ }
177
+ export {};
@@ -0,0 +1,32 @@
1
+ import { Disposable, IDisposable, IUnitRange, Nullable } from '@univerjs/core';
2
+ import { Observable } from 'rxjs';
3
+ export interface IRangeSelectorRange extends IUnitRange {
4
+ sheetName: string;
5
+ }
6
+ export interface IRangeSelectorService {
7
+ selectionChange$: Observable<IRangeSelectorRange[]>;
8
+ selectionChange(ranges: IRangeSelectorRange[]): void;
9
+ setCurrentSelectorId(id: Nullable<string>): void;
10
+ getCurrentSelectorId(): Nullable<string>;
11
+ openSelector$: Observable<unknown>;
12
+ openSelector(): void;
13
+ selectorModalVisible$: Observable<boolean>;
14
+ get selectorModalVisible(): boolean;
15
+ triggerModalVisibleChange(visible: boolean): void;
16
+ }
17
+ export declare class RangeSelectorService extends Disposable implements IRangeSelectorService, IDisposable {
18
+ private _currentSelectorId;
19
+ private readonly _selectionChange$;
20
+ readonly selectionChange$: Observable<IRangeSelectorRange[]>;
21
+ private readonly _openSelector$;
22
+ readonly openSelector$: Observable<unknown>;
23
+ private readonly _selectorModalVisible$;
24
+ readonly selectorModalVisible$: Observable<boolean>;
25
+ get selectorModalVisible(): boolean;
26
+ setCurrentSelectorId(id: Nullable<string>): void;
27
+ getCurrentSelectorId(): Nullable<string>;
28
+ selectionChange(range: IRangeSelectorRange[]): void;
29
+ openSelector(): void;
30
+ triggerModalVisibleChange(visible: boolean): void;
31
+ }
32
+ export declare const IRangeSelectorService: import('@wendellhu/redi').IdentifierDecorator<IRangeSelectorService>;