@gct-paas/word 0.1.22 → 0.1.23
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/dist/capabilities/model-field-runtime/provider/FieldProviderRuntime.d.ts +4 -0
- package/dist/capabilities/model-field-runtime/service/FieldService.d.ts +2 -0
- package/dist/core/cursor/types/cursor.d.ts +50 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/layout/LayoutMapper.d.ts +2 -2
- package/dist/core/layout/handlers/{ImageHandler.d.ts → InlineImageLayoutHandler.d.ts} +2 -3
- package/dist/core/layout/handlers/fields/AttachmentHandler.d.ts +3 -2
- package/dist/core/layout/handlers/fields/{BaseHandler.d.ts → FieldBaseHandler.d.ts} +2 -5
- package/dist/core/layout/handlers/fields/FieldImageHandler.d.ts +7 -0
- package/dist/core/layout/handlers/fields/InputHandler.d.ts +3 -2
- package/dist/core/layout/handlers/fields/OptionHandler.d.ts +3 -2
- package/dist/core/layout/handlers/fields/SignatureHandler.d.ts +3 -2
- package/dist/core/layout/handlers/fields/index.d.ts +1 -2
- package/dist/core/layout/handlers/index.d.ts +1 -1
- package/dist/core/layout/handlers/pageWidgets/BarcodeHandler.d.ts +2 -2
- package/dist/core/layout/handlers/pageWidgets/DefaultHandler.d.ts +2 -2
- package/dist/core/layout/handlers/pageWidgets/DiagonalHandler.d.ts +2 -2
- package/dist/core/layout/handlers/pageWidgets/LineHandler.d.ts +2 -2
- package/dist/core/layout/handlers/pageWidgets/PageWidgetImageHandler.d.ts +5 -0
- package/dist/core/layout/handlers/pageWidgets/PaginationHandler.d.ts +2 -2
- package/dist/core/layout/handlers/pageWidgets/QrCodeHandler.d.ts +2 -2
- package/dist/core/layout/handlers/pageWidgets/SerialNumberHandler.d.ts +2 -2
- package/dist/core/layout/handlers/{base/BaseHandler.d.ts → pageWidgets/WidgetBaseHandler.d.ts} +2 -5
- package/dist/core/layout/handlers/pageWidgets/index.d.ts +1 -1
- package/dist/core/layout/logic/LayoutBuilder.d.ts +1 -1
- package/dist/core/layout/types/index.d.ts +23 -6
- package/dist/core/model/DocModel.d.ts +13 -1
- package/dist/core/model/types/index.d.ts +0 -1
- package/dist/core/view/Doc.d.ts +8 -1
- package/dist/core/view/base/LayoutNode.d.ts +4 -0
- package/dist/core/view/runs/TextRun.d.ts +4 -0
- package/dist/core/view/types/index.d.ts +2 -0
- package/dist/core/view/types/layout-node-by-component.d.ts +38 -0
- package/dist/core/view/utils/TextUtil.d.ts +61 -7
- package/dist/index.es.js +2052 -1795
- package/dist/runtime/_register_/runtime/SuiteRuntime.d.ts +4 -1
- package/dist/runtime/canvas/node/text-character.vue.d.ts +3 -1
- package/dist/runtime/interface/render.d.ts +1 -1
- package/dist/sdk/engine/index.d.ts +1 -1
- package/dist/sdk/types/field-model-query.d.ts +19 -0
- package/dist/sdk/types/index.d.ts +9 -0
- package/dist/utils/func/core.d.ts +15 -0
- package/package.json +1 -1
- package/dist/core/layout/handlers/fields/ImageHandler.d.ts +0 -5
- package/dist/core/layout/handlers/pageWidgets/ImageHandler.d.ts +0 -4
- package/dist/core/model/types/model.d.ts +0 -144
|
@@ -9,6 +9,10 @@ export declare abstract class FieldProviderRuntime {
|
|
|
9
9
|
private idMap;
|
|
10
10
|
constructor(base: FieldProviderBase, modelKey: ModelKey);
|
|
11
11
|
fetchFields(params?: FieldQueryParams): Promise<FieldListResult>;
|
|
12
|
+
/** 同步获取字段 */
|
|
13
|
+
getFieldByKeySync(key: FieldKey): FieldMeta | undefined;
|
|
14
|
+
/** 同步获取字段 */
|
|
15
|
+
getFieldByIdSync(id: FieldId): FieldMeta | undefined;
|
|
12
16
|
getFieldByKey(key: FieldKey): Promise<FieldMeta | undefined>;
|
|
13
17
|
getFieldById(id: FieldId): Promise<FieldMeta | undefined>;
|
|
14
18
|
getFieldList(): FieldMeta[];
|
|
@@ -13,6 +13,8 @@ export declare class FieldService {
|
|
|
13
13
|
queryFieldList(modelKey: ModelKey, params?: any): Promise<FieldListResult>;
|
|
14
14
|
queryFieldByKey(modelKey: ModelKey, fieldKey: FieldKey): Promise<FieldMeta | undefined>;
|
|
15
15
|
queryFieldById(modelKey: ModelKey, id: FieldId): Promise<FieldMeta | undefined>;
|
|
16
|
+
queryFieldByKeySync(modelKey: ModelKey, fieldKey: FieldKey): FieldMeta | undefined;
|
|
17
|
+
queryFieldByIdSync(modelKey: ModelKey, id: FieldId): FieldMeta | undefined;
|
|
16
18
|
getFieldList(modelKey: ModelKey): FieldMeta[];
|
|
17
19
|
clear(modelKey: ModelKey): void;
|
|
18
20
|
dispose(): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** 特殊原子节点位置 */
|
|
2
|
+
export type Side = 'before' | 'after';
|
|
3
|
+
/** 光标信息 */
|
|
4
|
+
export interface ICursorPosition {
|
|
5
|
+
/** 节点的唯一key */
|
|
6
|
+
nodeId: string;
|
|
7
|
+
/** 纸张id */
|
|
8
|
+
pageId: string;
|
|
9
|
+
/** 父节点key */
|
|
10
|
+
preNodeId: string;
|
|
11
|
+
/** 归属节点key */
|
|
12
|
+
preLocation: string;
|
|
13
|
+
/** 节点路径,从根到当前节点 */
|
|
14
|
+
path: string[];
|
|
15
|
+
/** 节点索引路径: 每层在父节点数组中的下标 */
|
|
16
|
+
pathIndex: number[];
|
|
17
|
+
/** 偏移量 */
|
|
18
|
+
offset: number;
|
|
19
|
+
/** 特殊原子节点的光标“在前/在后” */
|
|
20
|
+
side: Side;
|
|
21
|
+
/** 是否是占位符 */
|
|
22
|
+
isPlaceholder: boolean;
|
|
23
|
+
/** 光标阶段 */
|
|
24
|
+
phase: 'preview' | 'commit';
|
|
25
|
+
}
|
|
26
|
+
/** 选区信息 */
|
|
27
|
+
export interface ISelectionRange {
|
|
28
|
+
/** 起始点 */
|
|
29
|
+
anchor: ICursorPosition;
|
|
30
|
+
/** 结束点 */
|
|
31
|
+
focus: ICursorPosition;
|
|
32
|
+
}
|
|
33
|
+
/** 真正的文档选区 */
|
|
34
|
+
export interface INormalizedRange {
|
|
35
|
+
rangeStart: ICursorPosition;
|
|
36
|
+
rangeEnd: ICursorPosition;
|
|
37
|
+
}
|
|
38
|
+
export type Rect = {
|
|
39
|
+
pageId: string;
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
};
|
|
45
|
+
export interface CursorIntent {
|
|
46
|
+
kind: 'boundary' | 'point' | 'continue';
|
|
47
|
+
offset: number;
|
|
48
|
+
side: Side;
|
|
49
|
+
dir?: 'left' | 'right' | 'up' | 'down';
|
|
50
|
+
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export type { DocInitOptions } from './view/Doc';
|
|
|
15
15
|
export type { WidgetMeta } from './widget/widget-meta';
|
|
16
16
|
export type { DocModeType, CompleteComponentType, BuiltinComponentType } from './constants';
|
|
17
17
|
export type { LayoutNode } from './view/base/LayoutNode';
|
|
18
|
+
export type { BuiltinComponentToLayoutNode, LayoutNodeForComponent } from './view/types';
|
|
19
|
+
export { isLayoutInlineImage, isLayoutOverlayLayout, isLayoutPage, isLayoutParagraph, isLayoutTable, isLayoutTableCell, isLayoutTableRow, isLayoutTextRun, isLayoutTextWidget, } from './view/types';
|
|
18
20
|
export type { Page } from './view/Page';
|
|
19
21
|
export type { TextRun } from './view/runs/TextRun';
|
|
20
22
|
export type { ImageRun } from './view/runs/ImageRun';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Doc } from '../view/Doc';
|
|
2
2
|
import { BaseMetaNode, LineInfo } from './types';
|
|
3
|
-
import { LayoutNode } from '../view/base';
|
|
4
3
|
import { Wp, Wtbl, Wtr, Wtc, Wr } from '../model/document';
|
|
4
|
+
import { Page } from '../view/Page';
|
|
5
5
|
type ModelMode = Wp | Wtbl | Wtr | Wtc | Wr;
|
|
6
6
|
export declare class LayoutMapper {
|
|
7
7
|
readonly doc: Doc;
|
|
@@ -22,7 +22,7 @@ export declare class LayoutMapper {
|
|
|
22
22
|
buildModelMap(): void;
|
|
23
23
|
getBaseMetaNodeById<T extends BaseMetaNode>(id?: string): T | undefined;
|
|
24
24
|
getBaseMetaNodeByIds<T extends BaseMetaNode>(ids: string[]): T[] | undefined;
|
|
25
|
-
getLayoutNodeById
|
|
25
|
+
getLayoutNodeById(id: string): Page | import('../view/base').BandContainer | import('..').Paragraph | import('..').Table | import('../view/TableCell').TableCell | import('../view/TableRow').TableRow | import('..').OverlayLayout | import('../view/base').OverlayContainer | import('..').TextRun | import('..').ImageRun | undefined;
|
|
26
26
|
getAllPageIds(): string[];
|
|
27
27
|
getLineIdsByPageId(pageId: string): string[];
|
|
28
28
|
getLineInfoById(lineId: string): LineInfo | undefined;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { WrImage } from '../../model/document';
|
|
2
2
|
import { LayoutContext } from '../LayoutContext';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* 负责图片尺寸计算和布局(整体处理)
|
|
4
|
+
* 行内 OOXML 图片(WrImage)布局策略:尺寸计算与 ImageRun 创建
|
|
6
5
|
*/
|
|
7
|
-
export declare class
|
|
6
|
+
export declare class InlineImageLayoutHandler {
|
|
8
7
|
static emuToPixels(emu: number): number;
|
|
9
8
|
private static resolveImageQuery;
|
|
10
9
|
static layout(context: LayoutContext, wr: WrImage): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldBaseHandler } from './FieldBaseHandler';
|
|
2
2
|
import { TextRun } from '../../../view/runs/TextRun';
|
|
3
|
-
|
|
3
|
+
import { HandlerContext } from '../../types';
|
|
4
|
+
export declare class AttachmentHandler extends FieldBaseHandler {
|
|
4
5
|
static layout(ctx: HandlerContext): void;
|
|
5
6
|
static layoutField(ctx: HandlerContext): void;
|
|
6
7
|
static layoutFileItem(payload: {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { WrText } from '../../../model/document';
|
|
2
2
|
import { LayoutContext } from '../../LayoutContext';
|
|
3
3
|
import { TextWidget } from '../../../view/runs/TextWidget';
|
|
4
|
+
import { HandlerContext } from '../../types';
|
|
4
5
|
type ValueType = string | number | undefined | null;
|
|
5
|
-
export
|
|
6
|
-
context: LayoutContext;
|
|
7
|
-
wr: WrText;
|
|
8
|
-
};
|
|
9
|
-
export declare class BaseHandler {
|
|
6
|
+
export declare class FieldBaseHandler {
|
|
10
7
|
static hasValue(value: ValueType): boolean;
|
|
11
8
|
static getId(context: LayoutContext, wr: WrText): string;
|
|
12
9
|
static get2DInfo(context: LayoutContext): {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FieldBaseHandler } from './FieldBaseHandler';
|
|
2
|
+
import { HandlerContext } from '../../types';
|
|
3
|
+
/** 表单字段 fw:image 的布局处理 */
|
|
4
|
+
export declare class FieldImageHandler extends FieldBaseHandler {
|
|
5
|
+
static layout(ctx: HandlerContext): void;
|
|
6
|
+
static layoutField(ctx: HandlerContext): void;
|
|
7
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { FieldBaseHandler } from './FieldBaseHandler';
|
|
2
|
+
import { HandlerContext } from '../../types';
|
|
3
|
+
export declare class InputHandler extends FieldBaseHandler {
|
|
3
4
|
static layout(ctx: HandlerContext): void;
|
|
4
5
|
static layoutField(ctx: HandlerContext): void;
|
|
5
6
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldBaseHandler } from './FieldBaseHandler';
|
|
2
2
|
import { WrText } from '../../../model/document';
|
|
3
3
|
import { LayoutContext } from '../../LayoutContext';
|
|
4
4
|
import { TextRun } from '../../../view/runs/TextRun';
|
|
5
|
+
import { HandlerContext } from '../../types';
|
|
5
6
|
type WidgetOption = {
|
|
6
7
|
value: any;
|
|
7
8
|
label: string;
|
|
8
9
|
};
|
|
9
|
-
export declare class OptionHandler extends
|
|
10
|
+
export declare class OptionHandler extends FieldBaseHandler {
|
|
10
11
|
static layout(ctx: HandlerContext): void;
|
|
11
12
|
static isVerticalLayout(wr: WrText): boolean;
|
|
12
13
|
static layoutField(ctx: HandlerContext): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldBaseHandler } from './FieldBaseHandler';
|
|
2
2
|
import { ImageWidgetOptions } from '../../../view/runs/ImageWidget';
|
|
3
|
-
|
|
3
|
+
import { HandlerContext } from '../../types';
|
|
4
|
+
export declare class SignatureHandler extends FieldBaseHandler {
|
|
4
5
|
static layout(ctx: HandlerContext): void;
|
|
5
6
|
/**
|
|
6
7
|
* 获取签名装饰信息
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { BaseHandler, type HandlerContext } from './BaseHandler';
|
|
2
1
|
export { OptionHandler } from './OptionHandler';
|
|
3
|
-
export {
|
|
2
|
+
export { FieldImageHandler } from './FieldImageHandler';
|
|
4
3
|
export { SignatureHandler } from './SignatureHandler';
|
|
5
4
|
export { InputHandler } from './InputHandler';
|
|
6
5
|
export { AttachmentHandler } from './AttachmentHandler';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WidgetBaseHandler } from './WidgetBaseHandler';
|
|
2
2
|
import { ImageWidgetOptions } from '../../../view/runs/ImageWidget';
|
|
3
|
-
export declare class BarcodeHandler extends
|
|
3
|
+
export declare class BarcodeHandler extends WidgetBaseHandler {
|
|
4
4
|
getDecorationsInfo(width: number, height: number, label?: string): {
|
|
5
5
|
render: boolean;
|
|
6
6
|
rectWidth: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class PaginationHandler extends
|
|
1
|
+
import { WidgetBaseHandler } from './WidgetBaseHandler';
|
|
2
|
+
export declare class PaginationHandler extends WidgetBaseHandler {
|
|
3
3
|
layout(): void;
|
|
4
4
|
/** 解析 ${no} ${total} */
|
|
5
5
|
private parseTokens;
|
package/dist/core/layout/handlers/{base/BaseHandler.d.ts → pageWidgets/WidgetBaseHandler.d.ts}
RENAMED
|
@@ -2,11 +2,8 @@ import { WrText } from '../../../model/document';
|
|
|
2
2
|
import { LayoutContext } from '../../LayoutContext';
|
|
3
3
|
import { TextRun } from '../../../view/runs/TextRun';
|
|
4
4
|
import { TableCell } from '../../../view/TableCell';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
wr: WrText;
|
|
8
|
-
};
|
|
9
|
-
export declare abstract class BaseHandler {
|
|
5
|
+
import { HandlerContext } from '../../types';
|
|
6
|
+
export declare abstract class WidgetBaseHandler {
|
|
10
7
|
context: LayoutContext;
|
|
11
8
|
wr: WrText;
|
|
12
9
|
constructor(ctx: HandlerContext);
|
|
@@ -2,7 +2,7 @@ export { SerialNumberHandler } from './SerialNumberHandler';
|
|
|
2
2
|
export { DefaultHandler } from './DefaultHandler';
|
|
3
3
|
export { QrCodeHandler } from './QrCodeHandler';
|
|
4
4
|
export { BarcodeHandler } from './BarcodeHandler';
|
|
5
|
-
export {
|
|
5
|
+
export { PageWidgetImageHandler } from './PageWidgetImageHandler';
|
|
6
6
|
export { DiagonalHandler } from './DiagonalHandler';
|
|
7
7
|
export { PaginationHandler } from './PaginationHandler';
|
|
8
8
|
export { LineHandler } from './LineHandler';
|
|
@@ -11,7 +11,7 @@ export declare function buildLayoutMeta(pages: Page[]): {
|
|
|
11
11
|
/** 是否是原子组件 */
|
|
12
12
|
export declare function isAtom(component: BuiltinComponentType): boolean;
|
|
13
13
|
/** 判断是否为占位符文本原子节点 */
|
|
14
|
-
export declare function isPlaceholderNode(node:
|
|
14
|
+
export declare function isPlaceholderNode(node: BaseMetaNode): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* 判断是否点击是字段组件节点
|
|
17
17
|
* @param node - 节点
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { BuiltinComponentType } from '../../constants';
|
|
2
|
-
import { LayoutNode } from '../../view/base';
|
|
3
2
|
import { TextRun } from '../../view/runs/TextRun';
|
|
3
|
+
import { LayoutNodeForComponent } from '../../view/types/layout-node-by-component';
|
|
4
|
+
import { LayoutContext } from '../LayoutContext';
|
|
5
|
+
import { WrText } from '../../model/document';
|
|
6
|
+
export type HandlerContext = {
|
|
7
|
+
context: LayoutContext;
|
|
8
|
+
wr: WrText;
|
|
9
|
+
};
|
|
4
10
|
export type LineType = 'paragraph' | 'tablerow' | undefined;
|
|
5
11
|
export interface BuildCtx {
|
|
6
12
|
currentPageId: string;
|
|
@@ -52,13 +58,15 @@ export interface Bounds {
|
|
|
52
58
|
bottom: number;
|
|
53
59
|
}
|
|
54
60
|
export type TableSelectionMode = 'none' | 'mixed' | 'row-range' | 'cell-range' | 'cell-full' | 'cell-inner';
|
|
55
|
-
|
|
61
|
+
/**
|
|
62
|
+
* 布局元数据公共字段(不含 `component` / `raw`)。
|
|
63
|
+
*
|
|
64
|
+
* **重要**:画布上的节点是 `LayoutNode` 子类实例,**没有** `raw` 属性。
|
|
65
|
+
* 仅在本结构的 `raw`(见 {@link BaseMetaNode})上挂对应画布节点;不要用 `run.raw`。
|
|
66
|
+
*/
|
|
67
|
+
export interface BaseMetaNodeBase {
|
|
56
68
|
/** 节点 id */
|
|
57
69
|
id: string;
|
|
58
|
-
/** 组件类型 */
|
|
59
|
-
component: BuiltinComponentType;
|
|
60
|
-
/** 组件节点信息 */
|
|
61
|
-
raw?: LayoutNode;
|
|
62
70
|
/** 章节引用 id */
|
|
63
71
|
secRefId: string;
|
|
64
72
|
/** 纸张 id */
|
|
@@ -126,3 +134,12 @@ export interface BaseMetaNode {
|
|
|
126
134
|
lineTop?: number;
|
|
127
135
|
lineBottom?: number;
|
|
128
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* 布局元数据:与 `component` 判别联合,`raw` 类型随 `component` 收窄(见 {@link LayoutNodeForComponent})。
|
|
139
|
+
*/
|
|
140
|
+
export type BaseMetaNode = {
|
|
141
|
+
[C in BuiltinComponentType]: BaseMetaNodeBase & {
|
|
142
|
+
component: C;
|
|
143
|
+
raw?: LayoutNodeForComponent<C>;
|
|
144
|
+
};
|
|
145
|
+
}[BuiltinComponentType];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Wdocument } from './document';
|
|
1
|
+
import { Wdocument, Wtbl } from './document';
|
|
2
2
|
import { Wstyles } from './styles';
|
|
3
3
|
import { Wimages } from './images';
|
|
4
4
|
import { Wsettings } from './settings/Wsettings';
|
|
@@ -7,6 +7,7 @@ import { Wfooters } from './footers/Wfooters';
|
|
|
7
7
|
import { Woverlays } from './overlays/Woverlays';
|
|
8
8
|
import { Wr } from './document/Wp';
|
|
9
9
|
import { Section } from '../view/Section';
|
|
10
|
+
import { Child } from './document/Wbody';
|
|
10
11
|
/**
|
|
11
12
|
* Word 文档模型
|
|
12
13
|
* 包含文档的所有组件(document、styles、images 等)
|
|
@@ -48,11 +49,22 @@ export declare class DocModel {
|
|
|
48
49
|
* @returns 原始 JSON 格式 (可用于 xml2js 反向转换)
|
|
49
50
|
*/
|
|
50
51
|
toXmlJson(): any;
|
|
52
|
+
/** 获取所有 children */
|
|
53
|
+
getAllChildren(): Child[];
|
|
54
|
+
/** 获取所有表格 */
|
|
55
|
+
getAllTables(): Wtbl[];
|
|
51
56
|
/**
|
|
52
57
|
* 获取所有同时存在 widgetMeta 和 valuePath 的实例
|
|
53
58
|
* @returns Wr 实例数组(包含 widgetMeta 和 valuePath 的文本或图片 run)
|
|
54
59
|
*/
|
|
55
60
|
getWidgetInstances(): Wr[];
|
|
61
|
+
/** 获取子表信息列表 */
|
|
62
|
+
getSubTableInfoList(): {
|
|
63
|
+
field: string;
|
|
64
|
+
key: string;
|
|
65
|
+
name: string;
|
|
66
|
+
subType: string;
|
|
67
|
+
}[];
|
|
56
68
|
/** 根据 pageIndex 获取页眉实例 */
|
|
57
69
|
getHeader(pageIndex: number, section: Section): import('./headers/Wheader').Wheader | null;
|
|
58
70
|
/** 根据 pageIndex 获取页脚实例 */
|
package/dist/core/view/Doc.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { InteractionManager } from '../interaction/InteractionManager';
|
|
|
10
10
|
import { DocModeType } from '../constants';
|
|
11
11
|
import { CommandPayloadMap, RequiredPayloadCommands, OptionalPayloadCommands } from '../command/types';
|
|
12
12
|
import { DocModel } from '../model';
|
|
13
|
-
import { DocRuntimeMeta } from '../../sdk';
|
|
13
|
+
import { DocRuntimeMeta, FieldModelQuery } from '../../sdk/types';
|
|
14
14
|
export interface DocInitOptions {
|
|
15
15
|
mode?: DocModeType;
|
|
16
16
|
model?: DocModel;
|
|
@@ -27,6 +27,11 @@ export interface DocInitOptions {
|
|
|
27
27
|
pagePadding?: [number, number, number, number];
|
|
28
28
|
onLayoutChange?: (doc: Doc) => void;
|
|
29
29
|
onSelectionChange?: (doc: Doc) => void;
|
|
30
|
+
/**
|
|
31
|
+
* 字段/模型查询(与套件 `SuiteRuntime` 同源)。
|
|
32
|
+
* 由文档工厂传入后,命令与布局等纯 TS 代码可通过 `doc.fieldModelQuery` 访问,无需 Vue inject。
|
|
33
|
+
*/
|
|
34
|
+
fieldModelQuery: FieldModelQuery;
|
|
30
35
|
}
|
|
31
36
|
export declare class Doc {
|
|
32
37
|
id: string;
|
|
@@ -56,6 +61,8 @@ export declare class Doc {
|
|
|
56
61
|
docRuntimeMeta: DocRuntimeMeta;
|
|
57
62
|
/** 外部的参数配置 */
|
|
58
63
|
paramsConfig: Record<string, any>;
|
|
64
|
+
/** 字段/模型查询(由上层注入 `SuiteRuntime` 等实现) */
|
|
65
|
+
fieldModelQuery: FieldModelQuery;
|
|
59
66
|
/** 安全距离-上下 */
|
|
60
67
|
SAFE_DIST_Y: number;
|
|
61
68
|
/** 安全距离-左右 */
|
|
@@ -32,6 +32,8 @@ export interface ITextRun {
|
|
|
32
32
|
fontSize: number;
|
|
33
33
|
/** 字体 */
|
|
34
34
|
fontFamily: string;
|
|
35
|
+
/** 高亮 */
|
|
36
|
+
highlight: string;
|
|
35
37
|
/** 文字颜色 */
|
|
36
38
|
color: string;
|
|
37
39
|
/** 加粗 */
|
|
@@ -71,6 +73,8 @@ export declare class TextRun extends LayoutNode implements ITextRun {
|
|
|
71
73
|
fontSize: number;
|
|
72
74
|
/** 字体 */
|
|
73
75
|
fontFamily: string;
|
|
76
|
+
/** 高亮 */
|
|
77
|
+
highlight: string;
|
|
74
78
|
/** 文字颜色 */
|
|
75
79
|
color: string;
|
|
76
80
|
/** 加粗 */
|
|
@@ -13,3 +13,5 @@ export interface Border {
|
|
|
13
13
|
width?: number;
|
|
14
14
|
style?: 'solid' | 'dashed' | 'dotted';
|
|
15
15
|
}
|
|
16
|
+
export type { BuiltinComponentToLayoutNode, LayoutNodeForComponent, } from './layout-node-by-component';
|
|
17
|
+
export { isLayoutInlineImage, isLayoutOverlayLayout, isLayoutPage, isLayoutParagraph, isLayoutTable, isLayoutTableCell, isLayoutTableRow, isLayoutTextRun, isLayoutTextWidget, } from './layout-node-by-component';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BuiltinComponentType, BuiltinComponentTypeConst } from '../../constants';
|
|
2
|
+
import { LayoutNode } from '../base/LayoutNode';
|
|
3
|
+
import { BandContainer } from '../base/BandContainer';
|
|
4
|
+
import { OverlayContainer } from '../base/OverlayContainer';
|
|
5
|
+
import { OverlayLayout } from '../base/OverlayLayout';
|
|
6
|
+
import { Page } from '../Page';
|
|
7
|
+
import { Paragraph } from '../Paragraph';
|
|
8
|
+
import { Table } from '../Table';
|
|
9
|
+
import { TableRow } from '../TableRow';
|
|
10
|
+
import { TableCell } from '../TableCell';
|
|
11
|
+
import { TextRun } from '../runs/TextRun';
|
|
12
|
+
import { TextWidget } from '../runs/TextWidget';
|
|
13
|
+
import { ImageRun } from '../runs/ImageRun';
|
|
14
|
+
/** 内置 `component` 取值到画布节点类型的映射(用于 `getLayoutNodeById(id, component)` 等) */
|
|
15
|
+
export interface BuiltinComponentToLayoutNode {
|
|
16
|
+
[BuiltinComponentTypeConst.Paper]: Page;
|
|
17
|
+
[BuiltinComponentTypeConst.Header]: BandContainer;
|
|
18
|
+
[BuiltinComponentTypeConst.Footer]: BandContainer;
|
|
19
|
+
[BuiltinComponentTypeConst.OverlayContainer]: OverlayContainer;
|
|
20
|
+
[BuiltinComponentTypeConst.OverlayLayout]: OverlayLayout;
|
|
21
|
+
[BuiltinComponentTypeConst.Paragraph]: Paragraph;
|
|
22
|
+
[BuiltinComponentTypeConst.Text]: TextRun;
|
|
23
|
+
[BuiltinComponentTypeConst.InlineImage]: ImageRun;
|
|
24
|
+
[BuiltinComponentTypeConst.Table]: Table;
|
|
25
|
+
[BuiltinComponentTypeConst.TableRow]: TableRow;
|
|
26
|
+
[BuiltinComponentTypeConst.TableCell]: TableCell;
|
|
27
|
+
}
|
|
28
|
+
export type LayoutNodeForComponent<C extends BuiltinComponentType> = C extends keyof BuiltinComponentToLayoutNode ? BuiltinComponentToLayoutNode[C] : LayoutNode;
|
|
29
|
+
export declare function isLayoutTextRun(node: LayoutNode | undefined | null): node is TextRun;
|
|
30
|
+
/** 字段/页面文本组件(`TextWidget` 子类);普通纯文本 run 为 `TextRun` 而非此类 */
|
|
31
|
+
export declare function isLayoutTextWidget(node: LayoutNode | undefined | null): node is TextWidget;
|
|
32
|
+
export declare function isLayoutInlineImage(node: LayoutNode | undefined | null): node is ImageRun;
|
|
33
|
+
export declare function isLayoutParagraph(node: LayoutNode | undefined | null): node is Paragraph;
|
|
34
|
+
export declare function isLayoutTable(node: LayoutNode | undefined | null): node is Table;
|
|
35
|
+
export declare function isLayoutTableRow(node: LayoutNode | undefined | null): node is TableRow;
|
|
36
|
+
export declare function isLayoutTableCell(node: LayoutNode | undefined | null): node is TableCell;
|
|
37
|
+
export declare function isLayoutPage(node: LayoutNode | undefined | null): node is Page;
|
|
38
|
+
export declare function isLayoutOverlayLayout(node: LayoutNode | undefined | null): node is OverlayLayout;
|
|
@@ -8,6 +8,17 @@ export declare class TextUtil {
|
|
|
8
8
|
private static readonly EAST_ASIAN_FULL_WIDTH_REGEX;
|
|
9
9
|
/** 表单/文档中常见的几何符号 */
|
|
10
10
|
private static readonly FULL_WIDTH_SYMBOL_REGEX;
|
|
11
|
+
/**
|
|
12
|
+
* 视觉间距系数
|
|
13
|
+
* 值 = fontSize * ratio
|
|
14
|
+
*
|
|
15
|
+
* 解决:
|
|
16
|
+
* - N·m
|
|
17
|
+
* - N/A
|
|
18
|
+
* - kg·m²
|
|
19
|
+
* 等符号贴太近的问题
|
|
20
|
+
*/
|
|
21
|
+
private static readonly VISUAL_SPACING_MAP;
|
|
11
22
|
private static fontMetricsCache;
|
|
12
23
|
private static layoutSizeCache;
|
|
13
24
|
/**
|
|
@@ -22,6 +33,25 @@ export declare class TextUtil {
|
|
|
22
33
|
* @returns
|
|
23
34
|
*/
|
|
24
35
|
static isFullWidthChar(char: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 获取字符视觉间距
|
|
38
|
+
*
|
|
39
|
+
* 注意:
|
|
40
|
+
* 这里不是 glyph width
|
|
41
|
+
* 而是用于排版推进的额外 advance width
|
|
42
|
+
*
|
|
43
|
+
* 例如:
|
|
44
|
+
* - N·m
|
|
45
|
+
* - N/A
|
|
46
|
+
*
|
|
47
|
+
* 中间符号真实宽度很小,
|
|
48
|
+
* 但视觉上需要 breathing space
|
|
49
|
+
*
|
|
50
|
+
* @param char
|
|
51
|
+
* @param fontSize
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
static getVisualSpacing(char: string, fontSize: number): number;
|
|
25
55
|
/**
|
|
26
56
|
* 生成文本度量缓存键
|
|
27
57
|
* @param payload
|
|
@@ -30,9 +60,9 @@ export declare class TextUtil {
|
|
|
30
60
|
*/
|
|
31
61
|
private static getMeasureCacheKey;
|
|
32
62
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
63
|
+
* 计算字体度量
|
|
64
|
+
* ascent / descent
|
|
65
|
+
*
|
|
36
66
|
* @param payload
|
|
37
67
|
* @returns
|
|
38
68
|
*/
|
|
@@ -41,7 +71,31 @@ export declare class TextUtil {
|
|
|
41
71
|
descent: number;
|
|
42
72
|
};
|
|
43
73
|
/**
|
|
44
|
-
*
|
|
74
|
+
* 获取字符排版推进宽度
|
|
75
|
+
*
|
|
76
|
+
* 注意:
|
|
77
|
+
* 这里返回的是:
|
|
78
|
+
* advance width
|
|
79
|
+
*
|
|
80
|
+
* 而不是:
|
|
81
|
+
* glyph width
|
|
82
|
+
*
|
|
83
|
+
* 用于:
|
|
84
|
+
* - 自动换行
|
|
85
|
+
* - 光标推进
|
|
86
|
+
* - 文本布局
|
|
87
|
+
* - selection
|
|
88
|
+
*
|
|
89
|
+
* @param payload
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
static getAdvanceWidth(payload: Konva.TextConfig): number;
|
|
93
|
+
/**
|
|
94
|
+
* 计算单字符布局大小
|
|
95
|
+
*
|
|
96
|
+
* 注意:
|
|
97
|
+
* width 使用 advance width
|
|
98
|
+
*
|
|
45
99
|
* @param payload
|
|
46
100
|
* @returns
|
|
47
101
|
*/
|
|
@@ -50,12 +104,12 @@ export declare class TextUtil {
|
|
|
50
104
|
height: number;
|
|
51
105
|
};
|
|
52
106
|
/**
|
|
53
|
-
*
|
|
107
|
+
* 清除度量缓存
|
|
54
108
|
*/
|
|
55
109
|
static clearMeasureCache(): void;
|
|
56
110
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @returns
|
|
111
|
+
* 获取缓存大小
|
|
112
|
+
* @returns
|
|
59
113
|
*/
|
|
60
114
|
static getMeasureCacheSize(): {
|
|
61
115
|
fontMetrics: number;
|