@hailin-zheng/editor-core 2.1.20 → 2.1.21
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/index-cjs.js +614 -900
- package/index-cjs.js.map +1 -1
- package/index.js +608 -901
- package/index.js.map +1 -1
- package/med_editor/framework/ast-parser.d.ts +2 -1
- package/med_editor/framework/common-util.d.ts +2 -0
- package/med_editor/framework/document-arrange.d.ts +4 -1
- package/med_editor/framework/document-paint.d.ts +0 -2
- package/med_editor/framework/{dynamic-executer.d.ts → dynamic-execute.d.ts} +6 -7
- package/med_editor/framework/element-define.d.ts +35 -1
- package/med_editor/framework/element-reader.d.ts +1 -0
- package/med_editor/framework/element-serialize.d.ts +1 -0
- package/med_editor/framework/element-trace-manage.d.ts +5 -0
- package/med_editor/framework/element-util.d.ts +3 -0
- package/med_editor/framework/impl/index.d.ts +1 -0
- package/med_editor/framework/impl/media-formula/permanent-teeth.d.ts +5 -2
- package/med_editor/framework/paragraph-arrange.d.ts +18 -1
- package/package.json +1 -1
- package/med_editor/framework/element-measure.d.ts +0 -94
- package/med_editor/framework/element-render-cut.d.ts +0 -59
@@ -1,3 +1,4 @@
|
|
1
1
|
import { Node } from "acorn";
|
2
|
-
export declare function parser(code: string): string;
|
2
|
+
export declare function parser(code: string, objects?: Array<string>): string;
|
3
|
+
export declare function addReturn(code: string): string;
|
3
4
|
export declare function getCalleeName(node: Node): string;
|
@@ -61,6 +61,7 @@ export declare class CommonUtil {
|
|
61
61
|
static getNowDiffSeconds(date: Date | string): number;
|
62
62
|
static isDate(str: string): boolean;
|
63
63
|
static cloneValue(val: any): any;
|
64
|
+
static cloneDeep<T>(source: T, visited?: WeakMap<object, any>): T;
|
64
65
|
static isConstructor(f: any): boolean;
|
65
66
|
static toArray<T>(item: Array<T> | T): Array<T>;
|
66
67
|
static removeChild(ele: HTMLElement): void;
|
@@ -68,6 +69,7 @@ export declare class CommonUtil {
|
|
68
69
|
static isIntersect(rect1: Rect, rect2: Rect): boolean;
|
69
70
|
static debounce<F extends AnyFunction>(fn: F, wait: number): (...args: Parameters<F>) => void;
|
70
71
|
static btoa(str: string): string;
|
72
|
+
static isEqual(a: any, b: any): boolean;
|
71
73
|
}
|
72
74
|
declare type AnyFunction = (...args: any[]) => any;
|
73
75
|
export {};
|
@@ -3,12 +3,16 @@ import { EditorContext } from "./document-context";
|
|
3
3
|
import { RenderContextType } from "./render-context";
|
4
4
|
import { DocumentRenderObject, ParagraphElement, TableCellRenderObject, TableRenderObject, TableRowRenderObject } from "./impl";
|
5
5
|
import { BlockContentRenderObject, BranchRenderObject } from "./render-define";
|
6
|
+
import { DynamicExecute } from "./dynamic-execute";
|
7
|
+
import { ParagraphMeasure } from "./paragraph-arrange";
|
6
8
|
import { SelectionEffectObject } from "./element-props";
|
7
9
|
export declare class DocumentArrange {
|
8
10
|
docCtx: EditorContext;
|
9
11
|
renderCtx: RenderContextType;
|
10
12
|
seo: SelectionEffectObject;
|
11
13
|
options: ViewOptions;
|
14
|
+
execute: DynamicExecute;
|
15
|
+
pMeasure: ParagraphMeasure;
|
12
16
|
constructor(docCtx: EditorContext, renderCtx: RenderContextType, seo: SelectionEffectObject);
|
13
17
|
/**
|
14
18
|
* 测量排版过程
|
@@ -24,7 +28,6 @@ export declare class DocumentArrange {
|
|
24
28
|
private createEmptyBodyRender;
|
25
29
|
private measureControl;
|
26
30
|
private processTableTextLineMode;
|
27
|
-
private createRenderObject;
|
28
31
|
private getDocInnerRect;
|
29
32
|
/**
|
30
33
|
* 切割渲染元素
|
@@ -3,13 +3,11 @@ import { DocumentRenderObject } from "./impl";
|
|
3
3
|
import { RenderContextType } from "./render-context";
|
4
4
|
import { DocumentContainerRender } from "./impl";
|
5
5
|
import { EditorContext } from "./document-context";
|
6
|
-
import { ElementMeasure } from "./element-measure";
|
7
6
|
import { SelectionEffectObject } from "./element-props";
|
8
7
|
export declare class DocumentPaint {
|
9
8
|
private renderContext;
|
10
9
|
private docCtx;
|
11
10
|
private seo;
|
12
|
-
elementMeasure: ElementMeasure;
|
13
11
|
elementPaint: ElementPaint;
|
14
12
|
docPages: Array<DocumentRenderObject>;
|
15
13
|
docContainer: DocumentContainerRender;
|
@@ -1,10 +1,14 @@
|
|
1
|
-
import { BranchElement } from "./element-define";
|
1
|
+
import { BranchElement, Element, RefCtxValue } from "./element-define";
|
2
2
|
import { SelectionState } from "./document-selection";
|
3
3
|
import { DataCheckEleModel, DataInputEleModel, DataLeafEleModel, DocumentContext } from "./document-context";
|
4
|
-
export declare class
|
4
|
+
export declare class DynamicExecute {
|
5
5
|
doc: BranchElement;
|
6
6
|
ss: SelectionState;
|
7
|
+
current?: Element;
|
8
|
+
depItems?: Map<string, RefCtxValue>;
|
7
9
|
constructor(doc: BranchElement, ss: SelectionState);
|
10
|
+
setCurrentCtx(ele: Element, depItems: Map<string, RefCtxValue>): void;
|
11
|
+
clearCurrentCtx(): void;
|
8
12
|
cacheList: ReturnType<DocumentContext['getDataElementModelList']>;
|
9
13
|
getControlById(id: string): DataCheckEleModel | DataInputEleModel | DataLeafEleModel | undefined;
|
10
14
|
getObject(id: string): RefCtxValue;
|
@@ -17,8 +21,3 @@ export declare class DynamicContextParser {
|
|
17
21
|
Number(val: any): number;
|
18
22
|
TableData(tableId: string, startRow: number, startCol: number, endRow: number, endCol: number): Array<string>;
|
19
23
|
}
|
20
|
-
interface RefCtxValue {
|
21
|
-
get value(): any;
|
22
|
-
set value(val: any);
|
23
|
-
}
|
24
|
-
export {};
|
@@ -11,6 +11,7 @@ export declare class Rect {
|
|
11
11
|
export interface SerializeProps {
|
12
12
|
type: string;
|
13
13
|
props?: any;
|
14
|
+
attribute?: any;
|
14
15
|
children?: Array<SerializeProps>;
|
15
16
|
complete?: boolean;
|
16
17
|
}
|
@@ -71,6 +72,8 @@ export declare abstract class Element<P extends object = any> {
|
|
71
72
|
disableClick: boolean;
|
72
73
|
disposed: boolean;
|
73
74
|
loaded: boolean;
|
75
|
+
visibleExpr?: IVisibleExpression;
|
76
|
+
attribute?: ElementAttribute;
|
74
77
|
private _parent;
|
75
78
|
get parent(): BranchElement;
|
76
79
|
set parent(val: BranchElement);
|
@@ -278,6 +281,7 @@ export declare class ViewOptions {
|
|
278
281
|
ruleHeight: number;
|
279
282
|
printHeaderFooterLine: boolean;
|
280
283
|
showEnterSymbol: boolean;
|
284
|
+
enableVisibleExpression: boolean;
|
281
285
|
get fullPageView(): boolean;
|
282
286
|
set fullPageView(value: boolean);
|
283
287
|
mmToPixelsRatio: number;
|
@@ -333,6 +337,19 @@ export declare class BorderProps {
|
|
333
337
|
constructor(width?: number, color?: string, style?: string);
|
334
338
|
clone(): BorderProps;
|
335
339
|
}
|
340
|
+
/**
|
341
|
+
* 克隆元素的基本属性
|
342
|
+
* @param ele
|
343
|
+
* @param target
|
344
|
+
*/
|
345
|
+
export declare function cloneElementBase(ele: Element, target: Element): any;
|
346
|
+
/**
|
347
|
+
* 克隆元素的子元素
|
348
|
+
* @param ele
|
349
|
+
* @param target
|
350
|
+
* @param data
|
351
|
+
*/
|
352
|
+
export declare function cloneChildren(ele: BranchElement, target: BranchElement, data: boolean): void;
|
336
353
|
export declare abstract class IDispose {
|
337
354
|
abstract destroy(): void;
|
338
355
|
}
|
@@ -359,7 +376,7 @@ export declare function onceTask(fn: IVoidFn): IVoidFn;
|
|
359
376
|
export interface IBeginMeasureData {
|
360
377
|
doc: BranchElement;
|
361
378
|
viewOptions: ViewOptions;
|
362
|
-
|
379
|
+
execute: object;
|
363
380
|
createParaFn: () => Element;
|
364
381
|
}
|
365
382
|
export interface ICreateRenderData {
|
@@ -370,4 +387,21 @@ export interface FontBoundingBox {
|
|
370
387
|
fontBoundingBoxAscent: number;
|
371
388
|
fontBoundingBoxDescent: number;
|
372
389
|
}
|
390
|
+
export interface RefCtxValue {
|
391
|
+
get value(): any;
|
392
|
+
set value(val: any);
|
393
|
+
get ref(): any;
|
394
|
+
}
|
395
|
+
/**
|
396
|
+
* 需要实现一个可见性表达式的类型,控制目标元素的可见性(sourceElement),targetElement为影响元素,影响元素可能为多个
|
397
|
+
* 例如:sourceElement.visible= targetElement1.value==="1" && targetElement2.value===2等
|
398
|
+
*/
|
399
|
+
export interface IVisibleExpression {
|
400
|
+
compliedCode: string;
|
401
|
+
func: Function;
|
402
|
+
depItems: Map<string, RefCtxValue>;
|
403
|
+
}
|
404
|
+
export interface ElementAttribute {
|
405
|
+
visibleExpr?: string;
|
406
|
+
}
|
373
407
|
export {};
|
@@ -10,6 +10,7 @@ export declare class ElementReader {
|
|
10
10
|
read(data: any | DocumentElement): void;
|
11
11
|
setDocument(document: DocumentElement): void;
|
12
12
|
readElement(data: any, strictMode?: boolean): Element | null;
|
13
|
+
readAttribute(data: any, ele: Element): void;
|
13
14
|
/**
|
14
15
|
* 读取扩展属性
|
15
16
|
* @param data
|
@@ -398,5 +398,8 @@ export declare class ElementUtil {
|
|
398
398
|
static setDataElemEndFocus(ss: {
|
399
399
|
resetRange: (ele: any, offset: any) => void;
|
400
400
|
}, ele: DataElementInlineGroup): void;
|
401
|
+
static setEleAttribute(ele: Element, attr: string, value: any): void;
|
402
|
+
static getEleAttribute(ele: Element, attr: string): any;
|
403
|
+
static removeEleAttribute(ele: Element, attr: string): void;
|
401
404
|
}
|
402
405
|
export {};
|
@@ -21,6 +21,7 @@ export * from './document/doc-header-impl';
|
|
21
21
|
export * from './document/doc-footer-impl';
|
22
22
|
export * from './document/doc-impl';
|
23
23
|
export * from "./media-formula/menstrual-history";
|
24
|
+
export * from "./media-formula/permanent-teeth";
|
24
25
|
export * from './paragraph/p-impl';
|
25
26
|
export * from './picture/image-impl';
|
26
27
|
export * from './radio/radio-impl';
|
@@ -1,11 +1,14 @@
|
|
1
|
-
import { ICreateRenderData,
|
1
|
+
import { ICreateRenderData, ViewOptions, Element, SerializeProps, ElementFactory, readElementProps } from "../../element-define";
|
2
2
|
import { INotifyPropertyChanged } from "../../element-props";
|
3
3
|
import { IEditorVNodeOptions, LeafRenderObject, RenderObject } from "../../render-define";
|
4
|
+
import { DataElementLeaf } from "../data-element/data-element-base-impl";
|
4
5
|
/**
|
5
6
|
* 恒牙牙位图
|
6
7
|
*/
|
7
|
-
export declare class PermanentTeethElement extends
|
8
|
+
export declare class PermanentTeethElement extends DataElementLeaf<PermanentTeethProps> {
|
8
9
|
constructor();
|
10
|
+
setValue(val: PermanentTeethProps | string): void;
|
11
|
+
getValue(): string;
|
9
12
|
clone(data: boolean): Element;
|
10
13
|
createRenderObject(data: ICreateRenderData): RenderObject | null;
|
11
14
|
serialize(viewOptions: ViewOptions): SerializeProps | null;
|
@@ -2,10 +2,12 @@ import { LeafRenderObject, RenderObject } from "./render-define";
|
|
2
2
|
import { FillNullSpaceRenderObject, ParagraphElement, ParagraphRenderObject, TextGroupRenderObject } from "./impl";
|
3
3
|
import { Element, InlineGroupElement, LeafElement, ViewOptions } from "./element-define";
|
4
4
|
import { RenderContextType } from "./render-context";
|
5
|
+
import { DynamicExecute } from "./dynamic-execute";
|
5
6
|
export declare class ParagraphMeasure {
|
6
7
|
options: ViewOptions;
|
7
8
|
renderCtx: RenderContextType;
|
8
|
-
|
9
|
+
execute: DynamicExecute;
|
10
|
+
constructor(options: ViewOptions, renderCtx: RenderContextType, execute: DynamicExecute);
|
9
11
|
/**
|
10
12
|
* 段落排版:
|
11
13
|
* 1.当前段落不存在项目符号,按照缩进和悬挂处理
|
@@ -69,6 +71,21 @@ export declare class ParagraphMeasure {
|
|
69
71
|
* 获取段落行渲染单位个数,字符需要计算为字符长度
|
70
72
|
*/
|
71
73
|
private getRenderUnitLength;
|
74
|
+
/**
|
75
|
+
* 解析可见性表达式
|
76
|
+
* @param ele
|
77
|
+
* @param execute
|
78
|
+
* @private
|
79
|
+
*/
|
80
|
+
parseVisibleExpression(ele: Element, execute: DynamicExecute): void;
|
81
|
+
/**
|
82
|
+
* 元素可见行求值
|
83
|
+
* @param ele
|
84
|
+
* @param executeCtx
|
85
|
+
* @private
|
86
|
+
*/
|
87
|
+
evalVisibleExpr(ele: Element, executeCtx: DynamicExecute): boolean;
|
88
|
+
createRenderObject<T extends Element>(element: T): ReturnType<T['createRenderObject']>;
|
72
89
|
}
|
73
90
|
interface MeasureLine {
|
74
91
|
add(child: RenderObject): void;
|
package/package.json
CHANGED
@@ -1,94 +0,0 @@
|
|
1
|
-
import { Element, IBeginMeasureData, InlineGroupElement, ViewOptions } from "./element-define";
|
2
|
-
import { FillNullSpaceRenderObject } from "./impl";
|
3
|
-
import { DocumentElement, DocumentRenderObject } from "./impl";
|
4
|
-
import { ParagraphElement, ParagraphLineRectRenderObject, ParagraphRenderObject } from "./impl";
|
5
|
-
import { TextGroupRenderObject } from "./impl";
|
6
|
-
import { RenderContextType } from "./render-context";
|
7
|
-
import { InlineGroupRenderObject, RenderObject } from "./render-define";
|
8
|
-
import { EditorContext } from "./document-context";
|
9
|
-
interface ICutLineData {
|
10
|
-
firstItem: RenderObject | null;
|
11
|
-
lastItem: RenderObject | null;
|
12
|
-
br?: boolean;
|
13
|
-
}
|
14
|
-
/**
|
15
|
-
* 测量阶段,生成Render-UI
|
16
|
-
*/
|
17
|
-
export declare class ElementMeasure {
|
18
|
-
docCtx: EditorContext;
|
19
|
-
renderCtx: RenderContextType;
|
20
|
-
options: ViewOptions;
|
21
|
-
constructor(docCtx: EditorContext, renderCtx: RenderContextType);
|
22
|
-
measureDocument(document: DocumentElement): DocumentRenderObject;
|
23
|
-
measureControl(element: Element, maxWidth: number): RenderObject | null;
|
24
|
-
/**
|
25
|
-
* 生成段落 UI 树
|
26
|
-
* @param para
|
27
|
-
* @param render
|
28
|
-
*/
|
29
|
-
measureParagraph(para: ParagraphElement, render: ParagraphRenderObject): void;
|
30
|
-
/**
|
31
|
-
* 根据段落UI元素,进行排列
|
32
|
-
* @param render
|
33
|
-
* @param paragraph
|
34
|
-
* @param renderObjects
|
35
|
-
*/
|
36
|
-
measureInnerParagraph(render: ParagraphRenderObject, paragraph: ParagraphElement, renderObjects: Array<RenderObject>): void;
|
37
|
-
/**
|
38
|
-
* 获取段落行布局横向坐标起始位置,被段落text-align影响
|
39
|
-
*/
|
40
|
-
getParaLineRectStartX(counter: number, paraLineIndex: number, paraElement: ParagraphElement, paraRenderObject: ParagraphRenderObject, paraLineRender: ParagraphLineRectRenderObject): number;
|
41
|
-
/**
|
42
|
-
* 设置两端对齐
|
43
|
-
* @param render
|
44
|
-
* @param count
|
45
|
-
* @param spaceWidth
|
46
|
-
*/
|
47
|
-
private setAlignJustify;
|
48
|
-
/**
|
49
|
-
* 获取段落行渲染单位个数,字符需要计算为字符长度
|
50
|
-
*/
|
51
|
-
private getRenderUnitLength;
|
52
|
-
getInlineGroupRenderItem(item: InlineGroupElement): RenderObject | null;
|
53
|
-
cutRenderItem(render: RenderObject, nextRender: RenderObject, limitWidth: number, lineEmpty: boolean, inCloseBody: boolean): ICutLineData;
|
54
|
-
cutTextRender(render: TextGroupRenderObject, nextRender: RenderObject, limitWidth: number, lineEmpty: boolean, inCloseBody: boolean): ICutLineData;
|
55
|
-
/**
|
56
|
-
* 处理前置标点,前置标点不能出现在末尾
|
57
|
-
* @param render
|
58
|
-
* @param i
|
59
|
-
*/
|
60
|
-
private patchHandleLeadingPunctuation;
|
61
|
-
/**
|
62
|
-
* 处理后置标点,后置标点不能出现在行首
|
63
|
-
* @param render
|
64
|
-
* @param i
|
65
|
-
* @param lineEmpty
|
66
|
-
*/
|
67
|
-
private patchHandlePostPunctuation;
|
68
|
-
/**
|
69
|
-
* 是否包含后置标点
|
70
|
-
* @param str
|
71
|
-
* @returns
|
72
|
-
*/
|
73
|
-
private containPostPunctuation;
|
74
|
-
private containLeadingPunctuation;
|
75
|
-
/**
|
76
|
-
* 文本开头是否包含后置标点
|
77
|
-
* @param render
|
78
|
-
* @returns
|
79
|
-
*/
|
80
|
-
private containerStartSymbolInTextStart;
|
81
|
-
cutFillNullRender(render: FillNullSpaceRenderObject, limitWidth: number): ICutLineData;
|
82
|
-
/**
|
83
|
-
* 行内编组元素超出行内可用空间,需要根据剩余空间长度进行截断
|
84
|
-
*/
|
85
|
-
cutInlineGroupRenderItem(render: InlineGroupRenderObject, limitWidth: number, emptyLine: boolean, inCloseBody: boolean): ICutLineData;
|
86
|
-
/**
|
87
|
-
* 修改测量完毕后的元素状态
|
88
|
-
* @param ele
|
89
|
-
*/
|
90
|
-
setMeasureCompletedModifyFlag(ele: Element): void;
|
91
|
-
clearPaintCache(ele: Element, data: IBeginMeasureData): void;
|
92
|
-
endMeasures(ele: Element): void;
|
93
|
-
}
|
94
|
-
export {};
|
@@ -1,59 +0,0 @@
|
|
1
|
-
import { DocumentBodyRenderObject, DocumentElement, DocumentRenderObject, TableCellRenderObject, TableRenderObject, TableRowRenderObject } from "./impl";
|
2
|
-
import { RenderContextType } from "./render-context";
|
3
|
-
import { BlockContentRenderObject } from "./render-define";
|
4
|
-
import { Rect, ViewOptions } from "./element-define";
|
5
|
-
export declare class ElementRenderCut {
|
6
|
-
private options;
|
7
|
-
private renderContext;
|
8
|
-
constructor(options: ViewOptions, renderContext: RenderContextType);
|
9
|
-
cutPage(documentRender: DocumentRenderObject, documentElement: DocumentElement): Array<DocumentRenderObject>;
|
10
|
-
private getDocInnerRect;
|
11
|
-
getFullViewDocRender(documentRender: DocumentRenderObject, documentElement: DocumentElement): Array<DocumentRenderObject>;
|
12
|
-
createEmptyBodyRender(bodyRender: DocumentBodyRenderObject, limitRect: Rect): {
|
13
|
-
emptyBody: DocumentBodyRenderObject;
|
14
|
-
innerRect: Rect & {
|
15
|
-
prevMargin: number;
|
16
|
-
} & {
|
17
|
-
maxHeight: number;
|
18
|
-
maxWidth: number;
|
19
|
-
};
|
20
|
-
};
|
21
|
-
/**
|
22
|
-
* 切割渲染元素
|
23
|
-
* @param render 被切割的对象
|
24
|
-
* @param limitHeight
|
25
|
-
* @returns
|
26
|
-
*/
|
27
|
-
cutRenderItem(render: BlockContentRenderObject, limitHeight: number): BlockContentRenderObject | null;
|
28
|
-
/**
|
29
|
-
* 切割渲染元素
|
30
|
-
* @param tbRender 被切割的对象
|
31
|
-
* @param limitHeight
|
32
|
-
* @param addFunc
|
33
|
-
* @returns
|
34
|
-
*/
|
35
|
-
cutTable(tbRender: TableRenderObject, limitHeight: number): BlockContentRenderObject | null;
|
36
|
-
cutRowRenderItem(render: TableRowRenderObject, limitHeight: number): TableRowRenderObject | null;
|
37
|
-
/**
|
38
|
-
* 标记合并单元格所在行需要重新计算
|
39
|
-
* @param cellRender
|
40
|
-
* @private
|
41
|
-
*/
|
42
|
-
private markMergeRowRenderDirty;
|
43
|
-
/**
|
44
|
-
* 修复->已经截断的合并单元格要向下移动到合适的位置
|
45
|
-
* @param tbRender
|
46
|
-
* @param cutRows
|
47
|
-
* @returns
|
48
|
-
*/
|
49
|
-
private fixCutTable;
|
50
|
-
/**
|
51
|
-
* 校验当前是否是一个完整的行,没有Null单元格,检查当前是否还需要向下合并
|
52
|
-
* @param row
|
53
|
-
*/
|
54
|
-
private checkFullRow;
|
55
|
-
private existsCellRender;
|
56
|
-
private getBlockLineHeight;
|
57
|
-
getRowInsertCellIndex(sourceCell: TableCellRenderObject, destRow: TableRowRenderObject): number;
|
58
|
-
private getHeaderRows;
|
59
|
-
}
|