@univerjs/docs-ui 1.0.0-alpha.0 → 1.0.0-alpha.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.
- package/lib/cjs/index.js +700 -313
- package/lib/es/index.js +704 -318
- package/lib/index.js +704 -318
- package/lib/types/commands/operations/doc-cursor.operation.d.ts +1 -1
- package/lib/types/controllers/doc-move-cursor.controller.d.ts +27 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +3 -2
- package/lib/types/services/clipboard/udm-to-html/convertor.d.ts +3 -0
- package/lib/types/services/clipboard/udm-to-html/doc-html-export.service.d.ts +23 -0
- package/lib/types/services/doc-paragraph-menu.service.d.ts +2 -3
- package/lib/types/shortcuts/cursor.shortcut.d.ts +4 -0
- package/lib/types/views/ParagraphMenu.d.ts +12 -0
- package/lib/umd/index.js +10 -10
- package/package.json +10 -10
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Direction, IOperation } from '@univerjs/core';
|
|
17
|
-
export type DocCursorMoveGranularity = 'character' | 'word' | 'line' | 'document';
|
|
17
|
+
export type DocCursorMoveGranularity = 'character' | 'word' | 'line' | 'paragraph' | 'document';
|
|
18
18
|
export interface IMoveCursorOperationParams {
|
|
19
19
|
direction: Direction;
|
|
20
20
|
granularity?: DocCursorMoveGranularity;
|
|
@@ -28,18 +28,44 @@ export declare class DocMoveCursorController extends Disposable {
|
|
|
28
28
|
private _handleShiftMoveSelection;
|
|
29
29
|
private _handleMoveCursor;
|
|
30
30
|
private _getCursorOffsetByGranularity;
|
|
31
|
+
private _getParagraphBoundaryOffset;
|
|
32
|
+
private _getCurrentParagraphStartOffset;
|
|
31
33
|
private _getWordBoundaryOffset;
|
|
32
34
|
private _getLineBoundaryOffset;
|
|
33
35
|
private _getFirstCursorGlyphInLine;
|
|
34
36
|
private _getLastCursorGlyphInLine;
|
|
35
37
|
private _isCursorAddressableGlyph;
|
|
36
38
|
private _normalizeCursorOffset;
|
|
39
|
+
private _normalizeRenderableCursorOffset;
|
|
40
|
+
private _findNearestRenderableCursorOffset;
|
|
41
|
+
private _isRenderableCursorOffset;
|
|
37
42
|
private _normalizeWholeEntityRanges;
|
|
38
43
|
private _getCursorSkipTokens;
|
|
44
|
+
private _getNonRenderableCursorTokens;
|
|
39
45
|
private _getTopOrBottomPosition;
|
|
40
46
|
private _getGlyphLeftOffsetInLine;
|
|
41
47
|
private _matchPositionByLeftOffset;
|
|
42
|
-
private
|
|
48
|
+
private _getNextOrPrevLineTarget;
|
|
49
|
+
private _getTableLineTargetFromPageLine;
|
|
50
|
+
private _getTableBoundaryLineTarget;
|
|
51
|
+
private _getAdjacentTableCellLineTarget;
|
|
52
|
+
private _findAdjacentTableRow;
|
|
53
|
+
private _findAdjacentTableSliceRow;
|
|
54
|
+
private _getNearestTableCellLineTarget;
|
|
55
|
+
private _findLineAroundTable;
|
|
56
|
+
private _getDistanceToTableCell;
|
|
57
|
+
private _getTableCellHostOffsetLeft;
|
|
58
|
+
private _getTableCellContentWidth;
|
|
59
|
+
private _isTableCellContentPage;
|
|
60
|
+
private _getColumnGroupLineTargetFromBlockLine;
|
|
61
|
+
private _getColumnGroupContentLineTarget;
|
|
62
|
+
private _getColumnGroupExitLineTarget;
|
|
63
|
+
private _findColumnGroupByBlockLine;
|
|
64
|
+
private _findColumnGroupBlockLine;
|
|
65
|
+
private _getAdjacentLineAroundBlockLine;
|
|
66
|
+
private _getColumnGroupColumnBoundaryLine;
|
|
67
|
+
private _getDistanceToColumnGroupColumn;
|
|
68
|
+
private _isColumnGroupContentPage;
|
|
43
69
|
private _scrollToFocusNodePosition;
|
|
44
70
|
private _getDocObject;
|
|
45
71
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -79,6 +79,8 @@ export { UniverDocsUIPlugin } from './plugin';
|
|
|
79
79
|
export * from './services';
|
|
80
80
|
export { IDocClipboardService } from './services/clipboard/clipboard.service';
|
|
81
81
|
export { convertBodyToHtml } from './services/clipboard/udm-to-html/convertor';
|
|
82
|
+
export { DocHtmlExportService } from './services/clipboard/udm-to-html/doc-html-export.service';
|
|
83
|
+
export type { DocHtmlExportTransformer } from './services/clipboard/udm-to-html/doc-html-export.service';
|
|
82
84
|
export { DocAutoFormatService } from './services/doc-auto-format.service';
|
|
83
85
|
export { DocEventManagerService, getListMarkerFallbackBound, getListParagraphContextMenuHit, } from './services/doc-event-manager.service';
|
|
84
86
|
export type { IBulletBound, IMutiPageParagraphBound } from './services/doc-event-manager.service';
|
|
@@ -19,6 +19,7 @@ import { Disposable, ICommandService, ILogService, IUniverInstanceService, Slice
|
|
|
19
19
|
import { DocSelectionManagerService } from '@univerjs/docs';
|
|
20
20
|
import { ImageSourceType } from '@univerjs/drawing';
|
|
21
21
|
import { IClipboardInterfaceService } from '@univerjs/ui';
|
|
22
|
+
import { DocHtmlExportService } from './udm-to-html/doc-html-export.service';
|
|
22
23
|
export interface IClipboardPropertyItem {
|
|
23
24
|
}
|
|
24
25
|
export interface IDocClipboardHook {
|
|
@@ -52,8 +53,8 @@ export declare class DocClipboardService extends Disposable implements IDocClipb
|
|
|
52
53
|
private readonly _docSelectionManagerService;
|
|
53
54
|
private _clipboardHooks;
|
|
54
55
|
private _htmlToUDM;
|
|
55
|
-
private _umdToHtml;
|
|
56
|
-
constructor(_univerInstanceService: IUniverInstanceService, _logService: ILogService, _commandService: ICommandService, _clipboardInterfaceService: IClipboardInterfaceService, _docSelectionManagerService: DocSelectionManagerService);
|
|
56
|
+
private readonly _umdToHtml;
|
|
57
|
+
constructor(_univerInstanceService: IUniverInstanceService, _logService: ILogService, _commandService: ICommandService, _clipboardInterfaceService: IClipboardInterfaceService, docHtmlExportService: DocHtmlExportService, _docSelectionManagerService: DocSelectionManagerService);
|
|
57
58
|
copy(sliceType?: SliceBodyType, ranges?: ITextRangeWithStyle[]): Promise<boolean>;
|
|
58
59
|
cut(ranges?: ITextRangeWithStyle[]): Promise<boolean>;
|
|
59
60
|
paste(items: ClipboardItem[]): Promise<boolean>;
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IDocumentData, ITextRun } from '@univerjs/core';
|
|
17
|
+
import type { DocHtmlExportService } from './doc-html-export.service';
|
|
17
18
|
export declare function covertTextRunToHtml(dataStream: string, textRun: ITextRun): string;
|
|
18
19
|
export declare function getBodySliceHtml(doc: IDocumentData, startIndex: number, endIndex: number): string;
|
|
19
20
|
export declare function convertBodyToHtml(doc: IDocumentData): string;
|
|
20
21
|
export declare class UDMToHtmlService {
|
|
22
|
+
private readonly _docHtmlExportService?;
|
|
23
|
+
constructor(_docHtmlExportService?: Pick<DocHtmlExportService, "transformDocumentForHtmlExport"> | undefined);
|
|
21
24
|
convert(docList: IDocumentData[]): string;
|
|
22
25
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IDisposable, IDocumentData } from '@univerjs/core';
|
|
17
|
+
import { Disposable } from '@univerjs/core';
|
|
18
|
+
export type DocHtmlExportTransformer = (documentData: IDocumentData) => IDocumentData;
|
|
19
|
+
export declare class DocHtmlExportService extends Disposable {
|
|
20
|
+
private readonly _transformers;
|
|
21
|
+
registerTransformer(transformer: DocHtmlExportTransformer): IDisposable;
|
|
22
|
+
transformDocumentForHtmlExport(documentData: IDocumentData): IDocumentData;
|
|
23
|
+
}
|
|
@@ -16,15 +16,14 @@
|
|
|
16
16
|
import type { DocumentDataModel, ICustomBlock, ICustomTable, IDocumentBlockRange } from '@univerjs/core';
|
|
17
17
|
import type { IBoundRectNoAngle, IRenderContext, IRenderModule } from '@univerjs/engine-render';
|
|
18
18
|
import type { IMutiPageParagraphBound, ITableBound } from './doc-event-manager.service';
|
|
19
|
-
import { Disposable } from '@univerjs/core';
|
|
19
|
+
import { Disposable, DocumentBlockType } from '@univerjs/core';
|
|
20
20
|
import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs';
|
|
21
21
|
import { DocEventManagerService } from './doc-event-manager.service';
|
|
22
22
|
import { DocCanvasPopManagerService } from './doc-popup-manager.service';
|
|
23
23
|
import { DocFloatMenuService } from './float-menu.service';
|
|
24
24
|
import { DocSelectionRenderService } from './selection/doc-selection-render.service';
|
|
25
|
-
export type DocBlockMenuTargetKind = 'paragraph' | 'blockRange' | 'table' | 'customBlock';
|
|
26
25
|
export interface IDocBlockMenuTarget {
|
|
27
|
-
kind:
|
|
26
|
+
kind: Exclude<DocumentBlockType, DocumentBlockType.COLUMN_GROUP>;
|
|
28
27
|
key: string;
|
|
29
28
|
paragraph?: IMutiPageParagraphBound;
|
|
30
29
|
blockRange?: IDocumentBlockRange;
|
|
@@ -34,4 +34,8 @@ export declare const MoveCursorWordLeftShortcut: IShortcutItem<object>;
|
|
|
34
34
|
export declare const MoveCursorWordRightShortcut: IShortcutItem<object>;
|
|
35
35
|
export declare const MoveSelectionWordLeftShortcut: IShortcutItem<object>;
|
|
36
36
|
export declare const MoveSelectionWordRightShortcut: IShortcutItem<object>;
|
|
37
|
+
export declare const MoveCursorParagraphUpShortcut: IShortcutItem<object>;
|
|
38
|
+
export declare const MoveCursorParagraphDownShortcut: IShortcutItem<object>;
|
|
39
|
+
export declare const MoveSelectionParagraphUpShortcut: IShortcutItem<object>;
|
|
40
|
+
export declare const MoveSelectionParagraphDownShortcut: IShortcutItem<object>;
|
|
37
41
|
export declare const SelectAllShortcut: IShortcutItem;
|
|
@@ -13,17 +13,21 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import type { IDocumentBlockRange, IDocumentBody } from '@univerjs/core';
|
|
17
|
+
import type { IDocBlockMoveValidationContext } from '@univerjs/docs';
|
|
16
18
|
import type { ITextRangeWithStyle } from '@univerjs/engine-render';
|
|
17
19
|
import type { IPopup, IValueOption } from '@univerjs/ui';
|
|
18
20
|
import type { CSSProperties } from 'react';
|
|
19
21
|
import type { IMutiPageParagraphBound } from '../services/doc-event-manager.service';
|
|
20
22
|
import type { IDocBlockMenuTarget } from '../services/doc-paragraph-menu.service';
|
|
21
23
|
import { NamedStyleType } from '@univerjs/core';
|
|
24
|
+
import { DocBlockMoveValidatorService } from '@univerjs/docs';
|
|
22
25
|
import { ILayoutService } from '@univerjs/ui';
|
|
23
26
|
import { DocParagraphMenuService } from '../services/doc-paragraph-menu.service';
|
|
24
27
|
export { DOC_PARAGRAPH_MENU_COMPONENT_KEY, DOC_TABLE_BLOCK_MENU_COMPONENT_KEY } from './paragraph-menu/component-keys';
|
|
25
28
|
export declare function getParagraphMenuPopupDirection(anchorLeft: number, menuWidth?: number, viewportPadding?: number): 'left' | 'right';
|
|
26
29
|
export declare const PARAGRAPH_MENU_HOVER_OPEN_DELAY = 800;
|
|
30
|
+
export declare function shouldExecuteParagraphMenuMove(validatorService: Pick<DocBlockMoveValidatorService, 'canMoveBlock'>, context: IDocBlockMoveValidationContext): boolean;
|
|
27
31
|
export declare function createParagraphMenuHoverOpenScheduler(openMenu: () => void, delay?: number): {
|
|
28
32
|
schedule(): void;
|
|
29
33
|
cancel: () => void;
|
|
@@ -50,6 +54,14 @@ export declare function getParagraphMenuResolvedCommand(option: IValueOption, ta
|
|
|
50
54
|
};
|
|
51
55
|
export declare function shouldShowParagraphSettingMenu(target: IDocBlockMenuTarget | null | undefined): boolean;
|
|
52
56
|
export declare function getParagraphMenuHiddenItemIds(menuType: string, target: IDocBlockMenuTarget | null | undefined, namedStyleType?: NamedStyleType): string[];
|
|
57
|
+
export declare function unwrapBlockRangeBody(documentBody: IDocumentBody, blockRange: IDocumentBlockRange): {
|
|
58
|
+
body: IDocumentBody;
|
|
59
|
+
range: {
|
|
60
|
+
startOffset: number;
|
|
61
|
+
endOffset: number;
|
|
62
|
+
collapsed: boolean;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
53
65
|
export declare function getParagraphFormattingRange(target: IDocBlockMenuTarget | null | undefined, paragraph?: IMutiPageParagraphBound | null): ITextRangeWithStyle | null;
|
|
54
66
|
export declare function getParagraphMenuCommandTargetRange(commandId: string | undefined, targetRange?: ITextRangeWithStyle | null, formattingRange?: ITextRangeWithStyle | null): ITextRangeWithStyle | null | undefined;
|
|
55
67
|
export declare function finishParagraphMenuCommand(docParagraphMenuService: Pick<DocParagraphMenuService, 'hideParagraphMenu'> | null | undefined, layoutService: Pick<ILayoutService, 'focus'>, hideMenu: () => void): void;
|