@hailin-zheng/editor-core 1.0.15 → 1.0.22
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/README.md +1613 -0
- package/lib/framework/element-props.d.ts +2 -2
- package/lib/framework/impl/index.d.ts +36 -0
- package/lib/index.d.ts +34 -0
- package/lib/index.js +15672 -0
- package/lib/texteditor.d.ts +3 -3
- package/package.json +27 -26
- package/lib/doc-ruler.js +0 -313
- package/lib/doc-ruler.js.map +0 -1
- package/lib/framework/common-util.js +0 -178
- package/lib/framework/common-util.js.map +0 -1
- package/lib/framework/document-change.js +0 -1342
- package/lib/framework/document-change.js.map +0 -1
- package/lib/framework/document-combine.js +0 -40
- package/lib/framework/document-combine.js.map +0 -1
- package/lib/framework/document-comment.js +0 -148
- package/lib/framework/document-comment.js.map +0 -1
- package/lib/framework/document-context.js +0 -330
- package/lib/framework/document-context.js.map +0 -1
- package/lib/framework/document-eval-func.js +0 -48
- package/lib/framework/document-eval-func.js.map +0 -1
- package/lib/framework/document-event.js +0 -1054
- package/lib/framework/document-event.js.map +0 -1
- package/lib/framework/document-history.js +0 -65
- package/lib/framework/document-history.js.map +0 -1
- package/lib/framework/document-images-loader.js +0 -66
- package/lib/framework/document-images-loader.js.map +0 -1
- package/lib/framework/document-input-cursor.js +0 -239
- package/lib/framework/document-input-cursor.js.map +0 -1
- package/lib/framework/document-paint.js +0 -103
- package/lib/framework/document-paint.js.map +0 -1
- package/lib/framework/document-print-offscreen.js +0 -128
- package/lib/framework/document-print-offscreen.js.map +0 -1
- package/lib/framework/document-print.js +0 -203
- package/lib/framework/document-print.js.map +0 -1
- package/lib/framework/document-segmenter.js +0 -106
- package/lib/framework/document-segmenter.js.map +0 -1
- package/lib/framework/document-selection.js +0 -358
- package/lib/framework/document-selection.js.map +0 -1
- package/lib/framework/document-template.js +0 -20
- package/lib/framework/document-template.js.map +0 -1
- package/lib/framework/document-textline-mode.js +0 -30
- package/lib/framework/document-textline-mode.js.map +0 -1
- package/lib/framework/element-define.js +0 -579
- package/lib/framework/element-define.js.map +0 -1
- package/lib/framework/element-event-define.js +0 -108
- package/lib/framework/element-event-define.js.map +0 -1
- package/lib/framework/element-measure.js +0 -551
- package/lib/framework/element-measure.js.map +0 -1
- package/lib/framework/element-paint.js +0 -170
- package/lib/framework/element-paint.js.map +0 -1
- package/lib/framework/element-props.js +0 -809
- package/lib/framework/element-props.js.map +0 -1
- package/lib/framework/element-reader.js +0 -151
- package/lib/framework/element-reader.js.map +0 -1
- package/lib/framework/element-render-cut.js +0 -449
- package/lib/framework/element-render-cut.js.map +0 -1
- package/lib/framework/element-serialize.js +0 -113
- package/lib/framework/element-serialize.js.map +0 -1
- package/lib/framework/element-util.js +0 -1463
- package/lib/framework/element-util.js.map +0 -1
- package/lib/framework/impl/checkbox/checkbox-impl.js +0 -64
- package/lib/framework/impl/checkbox/checkbox-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-content-impl.js +0 -105
- package/lib/framework/impl/comments/comment-content-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-element-impl.js +0 -62
- package/lib/framework/impl/comments/comment-element-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-container-impl.js +0 -62
- package/lib/framework/impl/comments/comments-container-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-util.js +0 -67
- package/lib/framework/impl/comments/comments-util.js.map +0 -1
- package/lib/framework/impl/comments/validate-msg-impl.js +0 -83
- package/lib/framework/impl/comments/validate-msg-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-decorate-impl.js +0 -91
- package/lib/framework/impl/data-element/data-decorate-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-barcode.js +0 -115
- package/lib/framework/impl/data-element/data-element-barcode.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-base-impl.js +0 -205
- package/lib/framework/impl/data-element/data-element-base-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-check-impl.js +0 -133
- package/lib/framework/impl/data-element/data-element-check-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-date-impl.js +0 -111
- package/lib/framework/impl/data-element/data-element-date-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-group-impl.js +0 -130
- package/lib/framework/impl/data-element/data-element-group-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-image-impl.js +0 -137
- package/lib/framework/impl/data-element/data-element-image-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-list-impl.js +0 -131
- package/lib/framework/impl/data-element/data-element-list-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-text-impl.js +0 -103
- package/lib/framework/impl/data-element/data-element-text-impl.js.map +0 -1
- package/lib/framework/impl/decorate/fill-null-space-imple.js +0 -43
- package/lib/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
- package/lib/framework/impl/document/doc-body-impl.js +0 -79
- package/lib/framework/impl/document/doc-body-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-body-part-impl.js +0 -94
- package/lib/framework/impl/document/doc-body-part-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-container-impl.js +0 -21
- package/lib/framework/impl/document/doc-container-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-footer-impl.js +0 -77
- package/lib/framework/impl/document/doc-footer-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-header-impl.js +0 -83
- package/lib/framework/impl/document/doc-header-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-impl.js +0 -209
- package/lib/framework/impl/document/doc-impl.js.map +0 -1
- package/lib/framework/impl/media-formula/menstrual-history.js +0 -153
- package/lib/framework/impl/media-formula/menstrual-history.js.map +0 -1
- package/lib/framework/impl/paragraph/p-impl.js +0 -156
- package/lib/framework/impl/paragraph/p-impl.js.map +0 -1
- package/lib/framework/impl/picture/image-impl.js +0 -124
- package/lib/framework/impl/picture/image-impl.js.map +0 -1
- package/lib/framework/impl/radio/radio-impl.js +0 -72
- package/lib/framework/impl/radio/radio-impl.js.map +0 -1
- package/lib/framework/impl/symbol/br-symbol-impl.js +0 -54
- package/lib/framework/impl/symbol/br-symbol-impl.js.map +0 -1
- package/lib/framework/impl/symbol/p-symbol-impl.js +0 -54
- package/lib/framework/impl/symbol/p-symbol-impl.js.map +0 -1
- package/lib/framework/impl/table/table-cell-impl.js +0 -145
- package/lib/framework/impl/table/table-cell-impl.js.map +0 -1
- package/lib/framework/impl/table/table-impl.js +0 -363
- package/lib/framework/impl/table/table-impl.js.map +0 -1
- package/lib/framework/impl/table/table-row-impl.js +0 -75
- package/lib/framework/impl/table/table-row-impl.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell-patch.js +0 -89
- package/lib/framework/impl/table/table-split-cell-patch.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell.js +0 -464
- package/lib/framework/impl/table/table-split-cell.js.map +0 -1
- package/lib/framework/impl/table/table-util.js +0 -678
- package/lib/framework/impl/table/table-util.js.map +0 -1
- package/lib/framework/impl/text/text-impl.js +0 -149
- package/lib/framework/impl/text/text-impl.js.map +0 -1
- package/lib/framework/impl/text/track-run-impl.js +0 -112
- package/lib/framework/impl/text/track-run-impl.js.map +0 -1
- package/lib/framework/notify.js +0 -116
- package/lib/framework/notify.js.map +0 -1
- package/lib/framework/range-util.js +0 -312
- package/lib/framework/range-util.js.map +0 -1
- package/lib/framework/render-context.js +0 -384
- package/lib/framework/render-context.js.map +0 -1
- package/lib/framework/render-define.js +0 -195
- package/lib/framework/render-define.js.map +0 -1
- package/lib/framework/selection-overlays.js +0 -124
- package/lib/framework/selection-overlays.js.map +0 -1
- package/lib/texteditor.js +0 -913
- package/lib/texteditor.js.map +0 -1
- package/lib/util/subject.js +0 -88
- package/lib/util/subject.js.map +0 -1
- package/lib/util/table-bind.js +0 -6
- package/lib/util/table-bind.js.map +0 -1
@@ -1,156 +0,0 @@
|
|
1
|
-
import { BlockContentElement, ElementFactory } from "../../element-define";
|
2
|
-
import { ParagraphProps } from "../../element-props";
|
3
|
-
import { ElementUtil } from "../../element-util";
|
4
|
-
import { BlockLineRectRenderObject, MuiltBlockLineRenderObject } from "../../render-define";
|
5
|
-
export class ParagraphElement extends BlockContentElement {
|
6
|
-
//props: ParagraphProps;
|
7
|
-
constructor() {
|
8
|
-
super('p');
|
9
|
-
this.props = new ParagraphProps();
|
10
|
-
//this.addPropValueChangedSub(this.props);
|
11
|
-
this.addEvent('BackspaceKey', (evt) => {
|
12
|
-
if (evt.selectionState.collapsed) {
|
13
|
-
const pFirstLeafElement = ElementUtil.getFirstLeafElement(this);
|
14
|
-
if (pFirstLeafElement === evt.source && evt.sourceOffset === 0) {
|
15
|
-
if (this.props.numberType >= 0) {
|
16
|
-
this.props.numberType = -1;
|
17
|
-
evt.isCancel = true;
|
18
|
-
}
|
19
|
-
else if (this.props.indent) {
|
20
|
-
this.props.indent = 0;
|
21
|
-
evt.isCancel = true;
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
25
|
-
}, true);
|
26
|
-
this.addEvent('ElementContextMenu', (evt) => {
|
27
|
-
const { selectionState } = evt;
|
28
|
-
evt.menus.push({
|
29
|
-
icon: 'DeleteTable', caption: '删除段落', eventObj: {
|
30
|
-
onClick: (cevt) => {
|
31
|
-
selectionState.clear();
|
32
|
-
const psymbol = ElementUtil.getLastLeafElement(this);
|
33
|
-
const nextFocusableEle = ElementUtil.getRecursionNextSiblingElement(psymbol, false, true);
|
34
|
-
if (nextFocusableEle) {
|
35
|
-
selectionState.resetRange(nextFocusableEle, 0);
|
36
|
-
}
|
37
|
-
else {
|
38
|
-
selectionState.clear();
|
39
|
-
}
|
40
|
-
this.remove();
|
41
|
-
this.destroy();
|
42
|
-
}
|
43
|
-
}
|
44
|
-
});
|
45
|
-
});
|
46
|
-
}
|
47
|
-
createRenderObject() {
|
48
|
-
const paraRender = new ParagraphRenderObject(this);
|
49
|
-
return paraRender;
|
50
|
-
}
|
51
|
-
serialize(viewOptions) {
|
52
|
-
return {
|
53
|
-
type: 'p',
|
54
|
-
props: {
|
55
|
-
...this.props.getSerializeProps(viewOptions)
|
56
|
-
}
|
57
|
-
};
|
58
|
-
}
|
59
|
-
clone(data) {
|
60
|
-
const clone = new ParagraphElement();
|
61
|
-
this.props.clone(clone.props);
|
62
|
-
if (data) {
|
63
|
-
for (let i = 0; i < this.length; i++) {
|
64
|
-
clone.addChild(this.getChild(i).clone(true));
|
65
|
-
}
|
66
|
-
}
|
67
|
-
return clone;
|
68
|
-
}
|
69
|
-
static createElement() {
|
70
|
-
return new ParagraphElement();
|
71
|
-
}
|
72
|
-
}
|
73
|
-
export class ParagraphRenderObject extends MuiltBlockLineRenderObject {
|
74
|
-
beginRender(ctx, position) {
|
75
|
-
}
|
76
|
-
endRender(ctx, position) {
|
77
|
-
this.drawProjectNumber(ctx);
|
78
|
-
}
|
79
|
-
/**
|
80
|
-
* 绘制项目符号
|
81
|
-
*/
|
82
|
-
drawProjectNumber(ctx) {
|
83
|
-
const paraElement = this.element;
|
84
|
-
if (paraElement.props.numberType >= 0) {
|
85
|
-
if (paraElement.paintRenders.indexOf(this) > 0) {
|
86
|
-
return;
|
87
|
-
}
|
88
|
-
const firstLine = this.getChild(0);
|
89
|
-
if (!firstLine) {
|
90
|
-
debugger;
|
91
|
-
}
|
92
|
-
const firstInline = firstLine.getChild(0);
|
93
|
-
if (!firstInline) {
|
94
|
-
debugger;
|
95
|
-
}
|
96
|
-
const firstInlinePaintPos = ElementUtil.getRenderAbsolutePaintPos(firstInline, {
|
97
|
-
x: 0,
|
98
|
-
y: -ctx.viewOptions.translateY
|
99
|
-
});
|
100
|
-
const numberSymbolY = firstInlinePaintPos.y + Math.ceil(firstInline.rect.height / 2);
|
101
|
-
//ctx.contentContext.drawText(str, textProps, firstInlinePaintPos.x - paraElement.paraProps.indent, numberSymbolY, 14, 14);
|
102
|
-
ctx.contentContext.fillCircular(firstInlinePaintPos.x - paraElement.props.indent + 2, numberSymbolY, 4);
|
103
|
-
}
|
104
|
-
}
|
105
|
-
clone() {
|
106
|
-
const cloneRender = new ParagraphRenderObject(this.element);
|
107
|
-
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
108
|
-
for (let i = 0; i < this.length; i++) {
|
109
|
-
cloneRender.addChild(this.getChild(i).clone());
|
110
|
-
}
|
111
|
-
return cloneRender;
|
112
|
-
}
|
113
|
-
createLineRect() {
|
114
|
-
const lineRect = new ParagraphLineRectRenderObject(this.element);
|
115
|
-
lineRect.rect.maxWidth = this.rect.maxWidth;
|
116
|
-
return lineRect;
|
117
|
-
}
|
118
|
-
}
|
119
|
-
export class ParagraphFactory extends ElementFactory {
|
120
|
-
match(type) {
|
121
|
-
return type === 'p';
|
122
|
-
}
|
123
|
-
createElement(data, renderCtx) {
|
124
|
-
const paraElement = new ParagraphElement();
|
125
|
-
const props = data.props;
|
126
|
-
paraElement.props.indent = props?.indent ?? 0;
|
127
|
-
paraElement.props.hanging = props?.hanging ?? 0;
|
128
|
-
paraElement.props.textAlign = props?.textAlign ?? 'left';
|
129
|
-
paraElement.props.numberType = props?.numberType ?? -1;
|
130
|
-
paraElement.props.lineHeight = props?.lineHeight ?? 1.3;
|
131
|
-
paraElement.props.textProps = ElementUtil.readTextProps(null, props?.textProps, renderCtx.viewOptions);
|
132
|
-
paraElement.props.pageBreak = props?.pageBreak ?? false;
|
133
|
-
return paraElement;
|
134
|
-
}
|
135
|
-
}
|
136
|
-
/**
|
137
|
-
* 段落行框
|
138
|
-
*/
|
139
|
-
export class ParagraphLineRectRenderObject extends BlockLineRectRenderObject {
|
140
|
-
beginRender(ctx, position) {
|
141
|
-
//console.log('绘制段落行-begin');
|
142
|
-
}
|
143
|
-
endRender(ctx, position) {
|
144
|
-
//console.log('绘制段落行-end');
|
145
|
-
//ctx.strokeRect(position.x, position.y, this.rect.width, this.rect.height);
|
146
|
-
}
|
147
|
-
clone() {
|
148
|
-
const cloneRender = new ParagraphLineRectRenderObject(this.element);
|
149
|
-
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
150
|
-
for (let i = 0; i < this.length; i++) {
|
151
|
-
cloneRender.addChild(this.getChild(i).clone());
|
152
|
-
}
|
153
|
-
return cloneRender;
|
154
|
-
}
|
155
|
-
}
|
156
|
-
//# sourceMappingURL=p-impl.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"p-impl.js","sourceRoot":"lib/","sources":["framework/impl/paragraph/p-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EACnB,cAAc,EAKjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EACH,yBAAyB,EACzB,0BAA0B,EAE7B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,OAAO,gBAAiB,SAAQ,mBAAmC;IACrE,wBAAwB;IACxB;QACI,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,KAAK,GAAG,IAAI,cAAc,EAAE,CAAC;QAClC,0CAA0C;QAC1C,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,GAAG,EAAE,EAAE;YAClC,IAAI,GAAG,CAAC,cAAc,CAAC,SAAS,EAAE;gBAC9B,MAAM,iBAAiB,GAAG,WAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;gBAChE,IAAI,iBAAiB,KAAK,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,YAAY,KAAK,CAAC,EAAE;oBAC5D,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,EAAE;wBAC5B,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;wBAC3B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;qBACvB;yBAAM,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;wBAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;wBACtB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;qBACv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\n Element,\n SerializeProps,\n ViewOptions,\n readElementProps\n} from \"../../element-define\";\nimport { ContextMenuElementEvent } from \"../../element-event-define\";\nimport { ParagraphProps } from \"../../element-props\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport {\n BlockLineRectRenderObject,\n MuiltBlockLineRenderObject,\n RenderObject\n} from \"../../render-define\";\n\nexport class ParagraphElement extends BlockContentElement<ParagraphProps> {\n //props: ParagraphProps;\n constructor() {\n super('p');\n this.props = new ParagraphProps();\n //this.addPropValueChangedSub(this.props);\n this.addEvent('BackspaceKey', (evt) => {\n if (evt.selectionState.collapsed) {\n const pFirstLeafElement = ElementUtil.getFirstLeafElement(this);\n if (pFirstLeafElement === evt.source && evt.sourceOffset === 0) {\n if (this.props.numberType >= 0) {\n this.props.numberType = -1;\n evt.isCancel = true;\n } else if (this.props.indent) {\n this.props.indent = 0;\n evt.isCancel = true;\n }\n }\n }\n\n }, true);\n this.addEvent<ContextMenuElementEvent>('ElementContextMenu', (evt) => {\n const { selectionState } = evt;\n evt.menus.push({\n icon: 'DeleteTable', caption: '删除段落', eventObj: {\n onClick: (cevt) => {\n selectionState.clear();\n const psymbol = ElementUtil.getLastLeafElement(this);\n const nextFocusableEle = ElementUtil.getRecursionNextSiblingElement(psymbol, false, true);\n if (nextFocusableEle) {\n selectionState.resetRange(nextFocusableEle, 0);\n } else {\n selectionState.clear();\n }\n this.remove();\n this.destroy();\n }\n }\n });\n });\n }\n\n createRenderObject(): ParagraphRenderObject {\n const paraRender = new ParagraphRenderObject(this);\n return paraRender;\n }\n\n serialize(viewOptions: ViewOptions): SerializeProps {\n return {\n type: 'p',\n props: {\n ...this.props.getSerializeProps(viewOptions)\n }\n }\n }\n\n clone(data: boolean): Element {\n const clone = new ParagraphElement();\n this.props.clone(clone.props);\n if (data) {\n for (let i = 0; i < this.length; i++) {\n clone.addChild(this.getChild(i).clone(true));\n }\n }\n return clone;\n }\n\n static createElement(): ParagraphElement {\n return new ParagraphElement();\n }\n\n}\n\nexport class ParagraphRenderObject extends MuiltBlockLineRenderObject {\n beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n }\n\n endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n this.drawProjectNumber(ctx);\n }\n\n\n /**\n * 绘制项目符号\n */\n drawProjectNumber(ctx: RenderContenxtType): void {\n const paraElement = this.element as ParagraphElement;\n if (paraElement.props.numberType >= 0) {\n if (paraElement.paintRenders.indexOf(this) > 0) {\n return;\n }\n const firstLine = this.getChild(0) as ParagraphLineRectRenderObject;\n if (!firstLine) {\n debugger;\n }\n const firstInline = firstLine.getChild(0);\n if (!firstInline) {\n debugger;\n }\n const firstInlinePaintPos = ElementUtil.getRenderAbsolutePaintPos(firstInline, {\n x: 0,\n y: -ctx.viewOptions.translateY\n });\n const numberSymbolY = firstInlinePaintPos.y + Math.ceil(firstInline.rect.height / 2);\n //ctx.contentContext.drawText(str, textProps, firstInlinePaintPos.x - paraElement.paraProps.indent, numberSymbolY, 14, 14);\n ctx.contentContext.fillCircular(firstInlinePaintPos.x - paraElement.props.indent + 2, numberSymbolY, 4)\n }\n }\n\n\n clone(): RenderObject {\n const cloneRender = new ParagraphRenderObject(this.element);\n cloneRender.rect = ElementUtil.cloneRect(this.rect);\n for (let i = 0; i < this.length; i++) {\n cloneRender.addChild(this.getChild(i).clone());\n }\n return cloneRender;\n }\n\n createLineRect(): ParagraphLineRectRenderObject {\n const lineRect = new ParagraphLineRectRenderObject(this.element);\n lineRect.rect.maxWidth = this.rect.maxWidth;\n return lineRect;\n }\n\n\n}\n\nexport class ParagraphFactory extends ElementFactory<ParagraphProps> {\n match(type: string): boolean {\n return type === 'p';\n }\n\n createElement(data: readElementProps<ParagraphProps>, renderCtx: RenderContenxtType): Element {\n const paraElement = new ParagraphElement();\n const props = data.props;\n paraElement.props.indent = props?.indent ?? 0;\n paraElement.props.hanging = props?.hanging ?? 0;\n paraElement.props.textAlign = props?.textAlign ?? 'left';\n paraElement.props.numberType = props?.numberType ?? -1;\n paraElement.props.lineHeight = props?.lineHeight ?? 1.3;\n paraElement.props.textProps = ElementUtil.readTextProps(null, props?.textProps, renderCtx.viewOptions);\n paraElement.props.pageBreak = props?.pageBreak ?? false;\n return paraElement;\n }\n}\n\n/**\n * 段落行框\n */\nexport class ParagraphLineRectRenderObject extends BlockLineRectRenderObject {\n\n beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n //console.log('绘制段落行-begin');\n\n }\n\n endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n //console.log('绘制段落行-end');\n //ctx.strokeRect(position.x, position.y, this.rect.width, this.rect.height);\n }\n\n\n clone(): RenderObject {\n const cloneRender = new ParagraphLineRectRenderObject(this.element);\n cloneRender.rect = ElementUtil.cloneRect(this.rect);\n for (let i = 0; i < this.length; i++) {\n cloneRender.addChild(this.getChild(i).clone());\n }\n return cloneRender;\n }\n}\n"]}
|
@@ -1,124 +0,0 @@
|
|
1
|
-
import { ElementFactory, LeafElement, ResizeLeafRenderObject } from "../../element-define";
|
2
|
-
import { PictureProps } from "../../element-props";
|
3
|
-
import { ElementUtil } from "../../element-util";
|
4
|
-
export class PictureElement extends LeafElement {
|
5
|
-
//props: PictureProps;
|
6
|
-
status = 'no';
|
7
|
-
resizeable = true;
|
8
|
-
constructor() {
|
9
|
-
super('img');
|
10
|
-
this.props = new PictureProps();
|
11
|
-
//this.addPropValueChangedSub(this.props);
|
12
|
-
this.cursorType = 'move';
|
13
|
-
this.focusable = true;
|
14
|
-
}
|
15
|
-
createRenderObject() {
|
16
|
-
const render = new PictureRenderObject(this);
|
17
|
-
render.rect.width = this.props.width + 2;
|
18
|
-
render.rect.height = this.props.height + 2;
|
19
|
-
return render;
|
20
|
-
}
|
21
|
-
serialize(options) {
|
22
|
-
return {
|
23
|
-
type: 'img',
|
24
|
-
props: {
|
25
|
-
...this.props.getSerializeProps(options)
|
26
|
-
}
|
27
|
-
};
|
28
|
-
}
|
29
|
-
clone(data) {
|
30
|
-
const clone = new PictureElement();
|
31
|
-
this.props.clone(clone.props);
|
32
|
-
return clone;
|
33
|
-
}
|
34
|
-
loadImage(ctx) {
|
35
|
-
if (this.status === 'no') {
|
36
|
-
this.status = 'loading';
|
37
|
-
//this.imageSource = new Image();
|
38
|
-
//this.imageSource.src = this.props.src;
|
39
|
-
// const onload = (e: any) => {
|
40
|
-
// this.isLoad = 'completed';
|
41
|
-
// this.refreshView('appearance');
|
42
|
-
// };
|
43
|
-
// const onerror = (e: any) => {
|
44
|
-
// this.isLoad = 'error';
|
45
|
-
// console.error(e);
|
46
|
-
// };
|
47
|
-
const onCallback = (status) => {
|
48
|
-
this.status = status;
|
49
|
-
if (status === 'completed') {
|
50
|
-
this.refreshView();
|
51
|
-
}
|
52
|
-
};
|
53
|
-
ctx.docCtx.imageLoader.loadImage(this.props.src, onCallback);
|
54
|
-
}
|
55
|
-
}
|
56
|
-
destroy() {
|
57
|
-
super.destroy();
|
58
|
-
}
|
59
|
-
}
|
60
|
-
export class PictureRenderObject extends ResizeLeafRenderObject {
|
61
|
-
render(ctx, position) {
|
62
|
-
const picElement = this.element;
|
63
|
-
const picProps = picElement.props;
|
64
|
-
if (picElement.status === 'no') {
|
65
|
-
picElement.loadImage(ctx);
|
66
|
-
return;
|
67
|
-
}
|
68
|
-
if (picElement.status === 'completed') {
|
69
|
-
const imageSource = ctx.docCtx.imageLoader.getImage(picProps.src);
|
70
|
-
if (!imageSource) {
|
71
|
-
return;
|
72
|
-
}
|
73
|
-
if (picProps.border === 'all') {
|
74
|
-
ctx.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, 'black');
|
75
|
-
}
|
76
|
-
ctx.contentContext.drawImage(imageSource, 0, 0, imageSource.naturalWidth, imageSource.naturalHeight, position.x + 2, position.y + 2, picProps.width, picProps.height);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
clone() {
|
80
|
-
const clone = new PictureRenderObject(this.element);
|
81
|
-
clone.rect = ElementUtil.cloneRect(this.rect);
|
82
|
-
return clone;
|
83
|
-
}
|
84
|
-
pagePaintCompleted(ctx, pos) {
|
85
|
-
if (this.element.isFocused) {
|
86
|
-
const { width, height } = this.rect;
|
87
|
-
ctx.contentContext.strokeRect(pos.x, pos.y, width, height, '#1890ff', 0.5);
|
88
|
-
this.drawResizeCircle(ctx, pos.x, pos.y);
|
89
|
-
this.drawResizeCircle(ctx, pos.x + width, pos.y);
|
90
|
-
this.drawResizeCircle(ctx, pos.x, pos.y + height);
|
91
|
-
this.drawResizeCircle(ctx, pos.x + width, pos.y + height);
|
92
|
-
this.drawResizeCircle(ctx, pos.x + (Math.floor(width / 2)), pos.y);
|
93
|
-
this.drawResizeCircle(ctx, pos.x + (Math.floor(width / 2)), pos.y + height);
|
94
|
-
this.drawResizeCircle(ctx, pos.x, pos.y + (Math.floor(height / 2)));
|
95
|
-
this.drawResizeCircle(ctx, pos.x + width, pos.y + (Math.floor(height / 2)));
|
96
|
-
}
|
97
|
-
}
|
98
|
-
drawResizeCircle(ctx, x, y) {
|
99
|
-
const ctxNative = ctx.contentContext.ctx;
|
100
|
-
ctxNative.fillStyle = '#69c0ff';
|
101
|
-
ctxNative.beginPath();
|
102
|
-
ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);
|
103
|
-
ctxNative.closePath();
|
104
|
-
ctxNative.fill();
|
105
|
-
}
|
106
|
-
}
|
107
|
-
export class PictureFactory extends ElementFactory {
|
108
|
-
match(type) {
|
109
|
-
return type === 'img';
|
110
|
-
}
|
111
|
-
createElement(data, renderCtx) {
|
112
|
-
const props = data.props;
|
113
|
-
const pic = new PictureElement();
|
114
|
-
const picProps = pic.props;
|
115
|
-
picProps.width = props.width;
|
116
|
-
picProps.height = props.height;
|
117
|
-
picProps.src = props.src;
|
118
|
-
picProps.border = props.border || 'all';
|
119
|
-
picProps.title = props.title;
|
120
|
-
pic.props = picProps;
|
121
|
-
return pic;
|
122
|
-
}
|
123
|
-
}
|
124
|
-
//# sourceMappingURL=image-impl.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"image-impl.js","sourceRoot":"lib/","sources":["framework/impl/picture/image-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAiB,WAAW,EAAY,sBAAsB,EAA+B,MAAM,sBAAsB,CAAC;AAC1J,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAQjD,MAAM,OAAO,cAAe,SAAQ,WAAyB;IACzD,sBAAsB;IACtB,MAAM,GAAkB,IAAI,CAAC;IAC7B,UAAU,GAAY,IAAI,CAAC;IAC3B;QACI,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,EAAE,CAAC;QAChC,0CAA0C;QAC1C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IACD,kBAAkB;QACd,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,SAAS,CAAC,OAAoB;QAC1B,OAAO;YACH,IAAI,EAAE,KAAK;YACX,KAAK,EAAE;gBACH,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC;aAC3C;SACJ,CAAA;IACL,CAAC;IACD,KAAK,CAAC,IAAa;QACf,MAAM,KAAK,GAAG,IAAI,cAAc,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,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AC,CAAC;QAC3D,SAAS,CAAC,SAAS,EAAE,CAAC;QACtB,SAAS,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;CACJ;AAGD,MAAM,OAAO,cAAe,SAAQ,cAA4B;IAC5D,KAAK,CAAC,IAAY;QACd,OAAO,IAAI,KAAK,KAAK,CAAC;IAC1B,CAAC;IACD,aAAa,CAAC,IAAS,EAAE,SAA6B;QAClD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAqB,CAAC;QACzC,MAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC;QAC3B,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC7B,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC/B,QAAQ,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QACzB,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC;QACxC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC7B,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC;QACrB,OAAO,GAAG,CAAC;IACf,CAAC;CACJ","sourcesContent":["import { Element, ElementFactory, ImgLoadStatus, LeafElement, Position, ResizeLeafRenderObject, SerializeProps, ViewOptions } from \"../../element-define\";\nimport { PictureProps } from \"../../element-props\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { LeafRenderObject, RenderObject } from \"../../render-define\";\n\n\ninterface IResizeElement {\n resizeable: boolean;\n}\nexport class PictureElement extends LeafElement<PictureProps> implements IResizeElement {\n //props: PictureProps;\n status: ImgLoadStatus = 'no';\n resizeable: boolean = true;\n constructor() {\n super('img');\n this.props = new PictureProps();\n //this.addPropValueChangedSub(this.props);\n this.cursorType = 'move'\n this.focusable = true;\n }\n createRenderObject(): LeafRenderObject {\n const render = new PictureRenderObject(this);\n render.rect.width = this.props.width + 2;\n render.rect.height = this.props.height + 2;\n return render;\n }\n serialize(options: ViewOptions): SerializeProps {\n return {\n type: 'img',\n props: {\n ...this.props.getSerializeProps(options)\n }\n }\n }\n clone(data: boolean): Element {\n const clone = new PictureElement();\n this.props.clone(clone.props);\n return clone;\n }\n\n loadImage(ctx: RenderContenxtType): void {\n if (this.status === 'no') {\n this.status = 'loading';\n //this.imageSource = new Image();\n //this.imageSource.src = this.props.src;\n // const onload = (e: any) => {\n // this.isLoad = 'completed';\n // this.refreshView('appearance');\n // };\n // const onerror = (e: any) => {\n // this.isLoad = 'error';\n // console.error(e);\n // };\n const onCallback = (status: ImgLoadStatus) => {\n this.status = status;\n if (status === 'completed') {\n this.refreshView();\n }\n }\n ctx.docCtx.imageLoader.loadImage(this.props.src, onCallback);\n }\n }\n destroy(): void {\n super.destroy();\n }\n}\n\nexport class PictureRenderObject extends ResizeLeafRenderObject {\n render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n const picElement = this.element as PictureElement;\n const picProps = picElement.props;\n if (picElement.status === 'no') {\n picElement.loadImage(ctx);\n return;\n }\n if (picElement.status === 'completed') {\n const imageSource = ctx.docCtx.imageLoader.getImage(picProps.src);\n if (!imageSource) {\n return;\n }\n if (picProps.border === 'all') {\n ctx.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, 'black');\n }\n ctx.contentContext.drawImage(imageSource, 0, 0, imageSource.naturalWidth, imageSource.naturalHeight, position.x + 2, position.y + 2, picProps.width, picProps.height);\n }\n }\n clone(): RenderObject {\n const clone = new PictureRenderObject(this.element);\n clone.rect = ElementUtil.cloneRect(this.rect);\n return clone;\n }\n\n pagePaintCompleted(ctx: RenderContenxtType, pos: Position): void {\n if (this.element.isFocused) {\n const { width, height } = this.rect;\n ctx.contentContext.strokeRect(pos.x, pos.y, width, height, '#1890ff', 0.5);\n this.drawResizeCircle(ctx, pos.x, pos.y);\n this.drawResizeCircle(ctx, pos.x + width, pos.y);\n this.drawResizeCircle(ctx, pos.x, pos.y + height);\n this.drawResizeCircle(ctx, pos.x + width, pos.y + height);\n this.drawResizeCircle(ctx, pos.x + (Math.floor(width / 2)), pos.y);\n this.drawResizeCircle(ctx, pos.x + (Math.floor(width / 2)), pos.y + height);\n this.drawResizeCircle(ctx, pos.x, pos.y + (Math.floor(height / 2)));\n this.drawResizeCircle(ctx, pos.x + width, pos.y + (Math.floor(height / 2)));\n }\n }\n\n private drawResizeCircle(ctx: RenderContenxtType, x: number, y: number): void {\n const ctxNative = ctx.contentContext.ctx;\n ctxNative.fillStyle = '#69c0ff';\n ctxNative.beginPath();\n ctxNative.arc(x, y, Math.floor(4 / 5 * 4), 0, 2 * Math.PI);\n ctxNative.closePath();\n ctxNative.fill();\n }\n}\n\n\nexport class PictureFactory extends ElementFactory<PictureProps> {\n match(type: string): boolean {\n return type === 'img';\n }\n createElement(data: any, renderCtx: RenderContenxtType): Element {\n const props = data.props as PictureProps;\n const pic = new PictureElement();\n const picProps = pic.props;\n picProps.width = props.width;\n picProps.height = props.height;\n picProps.src = props.src;\n picProps.border = props.border || 'all';\n picProps.title = props.title;\n pic.props = picProps;\n return pic;\n }\n}\n"]}
|
@@ -1,72 +0,0 @@
|
|
1
|
-
import { ElementFactory, LeafElement } from "../../element-define";
|
2
|
-
import { RadioBoxProps } from "../../element-props";
|
3
|
-
import { ElementUtil } from "../../element-util";
|
4
|
-
import { LeafRenderObject } from "../../render-define";
|
5
|
-
export class RadioBoxElement extends LeafElement {
|
6
|
-
//props: RadioBoxProps;
|
7
|
-
constructor() {
|
8
|
-
super('rd');
|
9
|
-
this.props = new RadioBoxProps();
|
10
|
-
//this.addPropValueChangedSub(this.props);
|
11
|
-
this.cursorType = 'default';
|
12
|
-
this.addEvent('ElementClick', (evt) => { this.changeState(); });
|
13
|
-
}
|
14
|
-
createRenderObject() {
|
15
|
-
const render = new RadioBoxRenderObject(this);
|
16
|
-
render.rect.width = this.props.size + 4;
|
17
|
-
render.rect.height = this.props.size;
|
18
|
-
return render;
|
19
|
-
}
|
20
|
-
changeState() {
|
21
|
-
const parent = this.parent;
|
22
|
-
if (!parent) {
|
23
|
-
throw new Error('parent is null');
|
24
|
-
}
|
25
|
-
for (let i = 0; i < parent.length; i++) {
|
26
|
-
const child = parent.getChild(i);
|
27
|
-
if (child instanceof RadioBoxElement && child !== this) {
|
28
|
-
child.props.isChecked = false;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
this.props.isChecked = true;
|
32
|
-
}
|
33
|
-
serialize() {
|
34
|
-
return {
|
35
|
-
type: 'rd',
|
36
|
-
props: {
|
37
|
-
...this.props
|
38
|
-
}
|
39
|
-
};
|
40
|
-
}
|
41
|
-
clone() {
|
42
|
-
const clone = new RadioBoxElement();
|
43
|
-
this.props.clone(clone.props);
|
44
|
-
return clone;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
export class RadioBoxFactory extends ElementFactory {
|
48
|
-
match(type) {
|
49
|
-
return type === 'rd';
|
50
|
-
}
|
51
|
-
createElement(data, renderCtx) {
|
52
|
-
const rdElement = new RadioBoxElement();
|
53
|
-
const props = data.props;
|
54
|
-
const ckbProps = rdElement.props;
|
55
|
-
ckbProps.size = props.size ?? 14;
|
56
|
-
ckbProps.isChecked = props.isChecked;
|
57
|
-
rdElement.props = ckbProps;
|
58
|
-
return rdElement;
|
59
|
-
}
|
60
|
-
}
|
61
|
-
export class RadioBoxRenderObject extends LeafRenderObject {
|
62
|
-
render(ctx, position) {
|
63
|
-
const element = this.element;
|
64
|
-
ctx.contentContext.drawRadioBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.isChecked);
|
65
|
-
}
|
66
|
-
clone(cloneData = true) {
|
67
|
-
const clone = new RadioBoxRenderObject(this.element);
|
68
|
-
clone.rect = ElementUtil.cloneRect(this.rect);
|
69
|
-
return clone;
|
70
|
-
}
|
71
|
-
}
|
72
|
-
//# sourceMappingURL=radio-impl.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"rad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CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACjI,CAAC;IAED,KAAK,CAAC,SAAS,GAAG,IAAI;QAClB,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrD,KAAK,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,KAAK,CAAC;IACjB,CAAC;CAEJ","sourcesContent":["import { ElementFactory, LeafElement, SerializeProps } from \"../../element-define\";\nimport { RadioBoxProps } from \"../../element-props\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { LeafRenderObject, RenderObject } from \"../../render-define\";\n\nexport class RadioBoxElement extends LeafElement<RadioBoxProps> {\n //props: RadioBoxProps;\n constructor() {\n super('rd');\n this.props = new RadioBoxProps();\n //this.addPropValueChangedSub(this.props);\n this.cursorType = 'default'\n this.addEvent('ElementClick', (evt) => { this.changeState() });\n }\n createRenderObject(): RadioBoxRenderObject {\n const render = new RadioBoxRenderObject(this);\n render.rect.width = this.props.size + 4;\n render.rect.height = this.props.size;\n return render;\n }\n\n changeState(): void {\n const parent = this.parent;\n if (!parent) {\n throw new Error('parent is null')\n }\n for (let i = 0; i < parent.length; i++) {\n const child = parent.getChild(i);\n if (child instanceof RadioBoxElement && child !== this) {\n child.props.isChecked = false;\n }\n }\n this.props.isChecked = true;\n }\n serialize(): SerializeProps {\n return {\n type: 'rd',\n props: {\n ...this.props\n }\n }\n }\n clone(): RadioBoxElement {\n const clone = new RadioBoxElement();\n this.props.clone(clone.props);\n return clone;\n }\n}\n\nexport class RadioBoxFactory extends ElementFactory<RadioBoxProps> {\n match(type: string): boolean {\n return type === 'rd';\n }\n createElement(data: any, renderCtx: RenderContenxtType): RadioBoxElement {\n const rdElement = new RadioBoxElement();\n const props = data.props as RadioBoxProps;\n const ckbProps = rdElement.props;\n ckbProps.size = props.size ?? 14;\n ckbProps.isChecked = props.isChecked;\n rdElement.props = ckbProps;\n return rdElement;\n }\n}\n\nexport class RadioBoxRenderObject extends LeafRenderObject {\n\n render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n const element = this.element as RadioBoxElement;\n ctx.contentContext.drawRadioBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.isChecked);\n }\n\n clone(cloneData = true): RenderObject {\n const clone = new RadioBoxRenderObject(this.element);\n clone.rect = ElementUtil.cloneRect(this.rect);\n return clone;\n }\n\n}\n"]}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import { ElementFactory, LeafElement } from "../../element-define";
|
2
|
-
import { ElementUtil } from "../../element-util";
|
3
|
-
import { LeafRenderObject } from "../../render-define";
|
4
|
-
import { TextProps } from "../../element-props";
|
5
|
-
export class BreakElement extends LeafElement {
|
6
|
-
textProps;
|
7
|
-
constructor() {
|
8
|
-
super('br');
|
9
|
-
this.textProps = new TextProps();
|
10
|
-
this.textProps.fontSize = 14;
|
11
|
-
this.textProps.fontName = '宋体';
|
12
|
-
this.textProps.color = '#595959';
|
13
|
-
}
|
14
|
-
createRenderObject() {
|
15
|
-
const symbol = new BreakRenderObject(this);
|
16
|
-
symbol.rect.height = 14;
|
17
|
-
symbol.rect.width = 7;
|
18
|
-
return symbol;
|
19
|
-
}
|
20
|
-
serialize() {
|
21
|
-
return {
|
22
|
-
type: 'br',
|
23
|
-
props: {}
|
24
|
-
};
|
25
|
-
}
|
26
|
-
clone() {
|
27
|
-
const clone = new BreakElement();
|
28
|
-
//clone.renderCtx = this.renderCtx;
|
29
|
-
return clone;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
export class BreakRenderObject extends LeafRenderObject {
|
33
|
-
render(ctx, position) {
|
34
|
-
if (ctx.drawMode === 'print') {
|
35
|
-
return;
|
36
|
-
}
|
37
|
-
ctx.contentContext.drawText('↓', this.element.textProps, position.x, position.y, 20, this.rect.height);
|
38
|
-
}
|
39
|
-
clone() {
|
40
|
-
const render = new BreakRenderObject(this.element);
|
41
|
-
render.rect = ElementUtil.cloneRect(this.rect);
|
42
|
-
return render;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
export class BreakFactory extends ElementFactory {
|
46
|
-
match(type) {
|
47
|
-
return type === 'br';
|
48
|
-
}
|
49
|
-
createElement(data, renderCtx) {
|
50
|
-
const ele = new BreakElement();
|
51
|
-
return ele;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
//# sourceMappingURL=br-symbol-impl.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"br-symbol-impl.js","sourceRoot":"lib/","sources":["framework/impl/symbol/br-symbol-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,OAAO,YAAa,SAAQ,WAAW;IACzC,SAAS,CAAY;IACrB;QACI,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,QAAQ,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC;IACrC,CAAC;IACD,kBAAkB;QACd,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,SAAS;QACL,OAAO;YACH,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,EAAE;SACZ,CAAA;IACL,CAAC;IACD,KAAK;QACD,MAAM,KAAK,GAAG,IAAI,YAAY,EAAE,CAAC;QACjC,mCAAmC;QACnC,OAAO,KAAK,CAAC;IACjB,CAAC;CAEJ;AAED,MAAM,OAAO,iBAAkB,SAAQ,gBAA8B;IACjE,MAAM,CAAC,GAAuB,EAAE,QAAmC;QAC/D,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,EAAE;YAC1B,OAAO;SACV;QACD,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3G,CAAC;IACD,KAAK;QACD,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAED,MAAM,OAAO,YAAa,SAAQ,cAAoB;IAClD,KAAK,CAAC,IAAY;QACd,OAAO,IAAI,KAAK,IAAI,CAAC;IACzB,CAAC;IACD,aAAa,CAAC,IAAS,EAAE,SAA6B;QAClD,MAAM,GAAG,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,OAAO,GAAG,CAAC;IACf,CAAC;CAEJ","sourcesContent":["import { Element, ElementFactory, LeafElement, SerializeProps } from \"../../element-define\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { LeafRenderObject, RenderObject } from \"../../render-define\";\nimport { TextProps } from \"../../element-props\";\n\nexport class BreakElement extends LeafElement {\n textProps: TextProps;\n constructor() {\n super('br');\n this.textProps = new TextProps();\n this.textProps.fontSize = 14;\n this.textProps.fontName = '宋体';\n this.textProps.color = '#595959';\n }\n createRenderObject(): LeafRenderObject {\n const symbol = new BreakRenderObject(this);\n symbol.rect.height = 14;\n symbol.rect.width = 7;\n return symbol;\n }\n serialize(): SerializeProps {\n return {\n type: 'br',\n props: {}\n }\n }\n clone(): Element {\n const clone = new BreakElement();\n //clone.renderCtx = this.renderCtx;\n return clone;\n }\n\n}\n\nexport class BreakRenderObject extends LeafRenderObject<BreakElement> {\n render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n if (ctx.drawMode === 'print') {\n return;\n }\n ctx.contentContext.drawText('↓', this.element.textProps, position.x, position.y, 20, this.rect.height);\n }\n clone(): RenderObject {\n const render = new BreakRenderObject(this.element);\n render.rect = ElementUtil.cloneRect(this.rect);\n return render;\n }\n}\n\nexport class BreakFactory extends ElementFactory<null> {\n match(type: string): boolean {\n return type === 'br';\n }\n createElement(data: any, renderCtx: RenderContenxtType): Element {\n const ele = new BreakElement();\n return ele;\n }\n\n}\n\n"]}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import { LeafElement } from "../../element-define";
|
2
|
-
import { ElementUtil } from "../../element-util";
|
3
|
-
import { LeafRenderObject } from "../../render-define";
|
4
|
-
import { TextProps } from "../../element-props";
|
5
|
-
export class PSymbolElement extends LeafElement {
|
6
|
-
textProps;
|
7
|
-
defaultHeight = 14;
|
8
|
-
constructor() {
|
9
|
-
super('psym');
|
10
|
-
this.addEvent('GotCursor', evt => {
|
11
|
-
const { selectionState: ss } = evt;
|
12
|
-
//强制光标定位到段落符号之前
|
13
|
-
//offset=1,段落回车时,导致合并的bug
|
14
|
-
if (ss.collapsed) {
|
15
|
-
if (ss.startControl === this && ss.startOffset === 1) {
|
16
|
-
evt.isCancel = true;
|
17
|
-
evt.selectionState.resetRange(this, 0);
|
18
|
-
}
|
19
|
-
}
|
20
|
-
});
|
21
|
-
this.textProps = new TextProps();
|
22
|
-
this.textProps.fontSize = this.defaultHeight;
|
23
|
-
this.textProps.fontName = '宋体';
|
24
|
-
this.textProps.color = '#8c8c8c';
|
25
|
-
}
|
26
|
-
createRenderObject() {
|
27
|
-
const symbol = new PSymbolRenderObject(this);
|
28
|
-
symbol.rect.height = this.defaultHeight;
|
29
|
-
symbol.rect.width = 7;
|
30
|
-
return symbol;
|
31
|
-
}
|
32
|
-
serialize() {
|
33
|
-
return null;
|
34
|
-
}
|
35
|
-
clone() {
|
36
|
-
const clone = new PSymbolElement();
|
37
|
-
return clone;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
export class PSymbolRenderObject extends LeafRenderObject {
|
41
|
-
render(ctx, position) {
|
42
|
-
if (ctx.drawMode === 'print') {
|
43
|
-
return;
|
44
|
-
}
|
45
|
-
ctx.contentContext.drawText('⤶', this.element.textProps, position.x, position.y, 20, this.rect.height);
|
46
|
-
}
|
47
|
-
//绘制段落符号
|
48
|
-
clone() {
|
49
|
-
const render = new PSymbolRenderObject(this.element);
|
50
|
-
render.rect = ElementUtil.cloneRect(this.rect);
|
51
|
-
return render;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
//# sourceMappingURL=p-symbol-impl.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"p-symbol-impl.js","sourceRoot":"lib/","sources":["framework/impl/symbol/p-symbol-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC3C,SAAS,CAAY;IACrB,aAAa,GAAG,EAAE,CAAC;IACnB;QACI,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG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AE,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3G,CAAC;IACD,QAAQ;IACR,KAAK;QACD,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrD,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC;IAClB,CAAC;CAEJ","sourcesContent":["import { Element, LeafElement, SerializeProps } from \"../../element-define\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { LeafRenderObject, RenderObject } from \"../../render-define\";\nimport { TextProps } from \"../../element-props\";\nexport class PSymbolElement extends LeafElement {\n textProps: TextProps;\n defaultHeight = 14;\n constructor() {\n super('psym');\n this.addEvent('GotCursor', evt => {\n const { selectionState: ss } = evt;\n //强制光标定位到段落符号之前\n //offset=1,段落回车时,导致合并的bug\n if (ss.collapsed) {\n if (ss.startControl === this && ss.startOffset === 1) {\n evt.isCancel = true;\n evt.selectionState.resetRange(this, 0);\n }\n }\n })\n this.textProps = new TextProps();\n this.textProps.fontSize = this.defaultHeight;\n this.textProps.fontName = '宋体';\n this.textProps.color = '#8c8c8c';\n }\n createRenderObject(): LeafRenderObject {\n const symbol = new PSymbolRenderObject(this);\n symbol.rect.height = this.defaultHeight;\n symbol.rect.width = 7;\n return symbol;\n }\n serialize(): SerializeProps | null {\n return null;\n }\n clone(): Element {\n const clone = new PSymbolElement();\n return clone;\n }\n}\n\nexport class PSymbolRenderObject extends LeafRenderObject<PSymbolElement> {\n render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n if (ctx.drawMode === 'print') {\n return;\n }\n ctx.contentContext.drawText('⤶', this.element.textProps, position.x, position.y, 20, this.rect.height);\n }\n //绘制段落符号\n clone(): RenderObject {\n const render = new PSymbolRenderObject(this.element);\n render.rect = ElementUtil.cloneRect(this.rect);\n return render;\n }\n\n}\n\n"]}
|