@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,384 +0,0 @@
|
|
1
|
-
import { ElementUtil } from "./element-util";
|
2
|
-
import { ParagraphElement } from "./impl/paragraph/p-impl";
|
3
|
-
export class RenderContenxt {
|
4
|
-
mainCtx;
|
5
|
-
viewOptions;
|
6
|
-
docCtx;
|
7
|
-
contentContext;
|
8
|
-
overlaysContext;
|
9
|
-
drawMode = 'view';
|
10
|
-
contentOffCanvas;
|
11
|
-
overlayOffCanvas;
|
12
|
-
constructor(mainCtx, viewOptions, docCtx) {
|
13
|
-
this.mainCtx = mainCtx;
|
14
|
-
this.viewOptions = viewOptions;
|
15
|
-
this.docCtx = docCtx;
|
16
|
-
this.createNativeCanvas();
|
17
|
-
}
|
18
|
-
createNativeCanvas() {
|
19
|
-
this.contentOffCanvas = document.createElement('canvas');
|
20
|
-
this.overlayOffCanvas = document.createElement('canvas');
|
21
|
-
this.contentContext = new PaintContent(this.contentOffCanvas.getContext('2d'), this.viewOptions);
|
22
|
-
this.overlaysContext = new PaintContent(this.overlayOffCanvas.getContext('2d'), this.viewOptions);
|
23
|
-
this.setCanvasProps();
|
24
|
-
}
|
25
|
-
// private createOffscreenCanvas() {
|
26
|
-
// this.contentOffCanvas = new OffscreenCanvas(250, 250);
|
27
|
-
// this.overlayOffCanvas = new OffscreenCanvas(250, 250);
|
28
|
-
// this.contentContext = new PaintContent(this.contentOffCanvas.getContext('2d') as OffscreenCanvasRenderingContext2D, this.viewOptions);
|
29
|
-
// this.overlaysContext = new PaintContent(this.overlayOffCanvas.getContext('2d') as OffscreenCanvasRenderingContext2D, this.viewOptions);
|
30
|
-
// this.setCanvasProps();
|
31
|
-
// }
|
32
|
-
setCanvasProps(pageSetting = null) {
|
33
|
-
if (!pageSetting) {
|
34
|
-
pageSetting = { width: this.viewOptions.viewSettings.width, height: this.viewOptions.viewPaintHeight };
|
35
|
-
if (this.viewOptions.showReviewWindow) {
|
36
|
-
pageSetting.width += this.viewOptions.reviewWindowWidth;
|
37
|
-
}
|
38
|
-
}
|
39
|
-
pageSetting = pageSetting || {
|
40
|
-
width: this.viewOptions.viewSettings.width,
|
41
|
-
height: this.viewOptions.viewPaintHeight
|
42
|
-
};
|
43
|
-
ElementUtil.setCanvasProps(this.contentOffCanvas, this.contentContext.ctx, pageSetting, this.viewOptions.scale);
|
44
|
-
ElementUtil.setCanvasProps(this.overlayOffCanvas, this.overlaysContext.ctx, pageSetting, this.viewOptions.scale);
|
45
|
-
ElementUtil.setCanvasProps(this.mainCtx.canvas, this.mainCtx, pageSetting, this.viewOptions.scale);
|
46
|
-
}
|
47
|
-
clear() {
|
48
|
-
this.contentContext.clear();
|
49
|
-
this.overlaysContext.clear();
|
50
|
-
this.mainCtx.clearRect(0, 0, this.mainCtx.canvas.width, this.mainCtx.canvas.height);
|
51
|
-
}
|
52
|
-
commit(pageSetting = null) {
|
53
|
-
//pageSetting = pageSetting || { width: this.viewOptions.viewSettings.width, height: this.viewOptions.viewPaintHeight };
|
54
|
-
if (!pageSetting) {
|
55
|
-
pageSetting = { width: this.viewOptions.viewSettings.width, height: this.viewOptions.viewPaintHeight };
|
56
|
-
if (this.viewOptions.showReviewWindow) {
|
57
|
-
pageSetting.width += this.viewOptions.reviewWindowWidth;
|
58
|
-
}
|
59
|
-
}
|
60
|
-
let { width, height } = pageSetting;
|
61
|
-
//this.mainCtx.clearRect(0, 0, this.mainCtx.canvas.width, this.mainCtx.canvas.height);
|
62
|
-
if (!this.overlayOffCanvas.width || !this.overlayOffCanvas.height) {
|
63
|
-
return;
|
64
|
-
}
|
65
|
-
this.mainCtx.drawImage(this.overlayOffCanvas, 0, 0, ElementUtil.getDprNumber(width, this.viewOptions.scale), ElementUtil.getDprNumber(height));
|
66
|
-
//console.time('drawImage');
|
67
|
-
this.mainCtx.drawImage(this.contentOffCanvas, 0, 0, ElementUtil.getDprNumber(width, this.viewOptions.scale), ElementUtil.getDprNumber(height));
|
68
|
-
//console.timeEnd('drawImage');
|
69
|
-
}
|
70
|
-
}
|
71
|
-
export class PaintContent {
|
72
|
-
ctx;
|
73
|
-
viewOptions;
|
74
|
-
constructor(ctx, viewOptions) {
|
75
|
-
this.ctx = ctx;
|
76
|
-
this.viewOptions = viewOptions;
|
77
|
-
this.init();
|
78
|
-
}
|
79
|
-
init() {
|
80
|
-
this.ctx.textBaseline = 'alphabetic';
|
81
|
-
}
|
82
|
-
setGlobalAlpha(alpha) {
|
83
|
-
this.ctx.globalAlpha = alpha;
|
84
|
-
}
|
85
|
-
getGlobalAlpha() {
|
86
|
-
return this.ctx.globalAlpha;
|
87
|
-
}
|
88
|
-
clear() {
|
89
|
-
this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
|
90
|
-
this.init();
|
91
|
-
}
|
92
|
-
drawText(text, textProps, x, y, width, height) {
|
93
|
-
if (textProps.background) {
|
94
|
-
this.fillRect(x, y, width, height, textProps.background);
|
95
|
-
}
|
96
|
-
this.ctx.save();
|
97
|
-
this.ctx.fillStyle = textProps.color;
|
98
|
-
this.ctx.font = textProps.getFont();
|
99
|
-
const vertHeight = textProps.vertAlign === 'superscript' ? 0 : height;
|
100
|
-
this.ctx.fillText(text, x, y + vertHeight - height / 7);
|
101
|
-
this.ctx.restore();
|
102
|
-
if (textProps.linethrough) {
|
103
|
-
this.drawLine(x, y + (Math.ceil(height / 2)), width, textProps.color, 1);
|
104
|
-
}
|
105
|
-
if (textProps.underline) {
|
106
|
-
this.drawLine(x, y + height, width, textProps.color, 1);
|
107
|
-
}
|
108
|
-
if (textProps.overline) {
|
109
|
-
this.drawLine(x, y, width, textProps.color, 1);
|
110
|
-
}
|
111
|
-
}
|
112
|
-
fillCircular(x, y, r, color = 'black') {
|
113
|
-
this.ctx.save();
|
114
|
-
this.ctx.beginPath();
|
115
|
-
this.ctx.fillStyle = color;
|
116
|
-
this.ctx.arc(x, y, r, 0, 2 * Math.PI);
|
117
|
-
this.ctx.fill();
|
118
|
-
this.ctx.restore();
|
119
|
-
}
|
120
|
-
drawTextUnits(textGroupRender, x, y) {
|
121
|
-
const textEle = textGroupRender.element;
|
122
|
-
const textProps = textEle.props;
|
123
|
-
const { width, height } = textGroupRender.rect;
|
124
|
-
this.ctx.save();
|
125
|
-
this.ctx.fillStyle = textProps.color;
|
126
|
-
this.ctx.font = textProps.getFont();
|
127
|
-
if (textProps.background) {
|
128
|
-
this.fillRect(x, y, width, height, textProps.background);
|
129
|
-
}
|
130
|
-
if (textProps.linethrough) {
|
131
|
-
this.drawLine(x, y + (Math.ceil(height / 2)), width, textProps.color, 1);
|
132
|
-
}
|
133
|
-
if (textProps.underline) {
|
134
|
-
this.drawLine(x, y + height, width, textProps.color, 1);
|
135
|
-
}
|
136
|
-
if (textProps.overline) {
|
137
|
-
this.drawLine(x, y, width, textProps.color, 1);
|
138
|
-
}
|
139
|
-
let horX = 0;
|
140
|
-
let vertHeight = height - (height / 7);
|
141
|
-
if (textProps.vertAlign === 'superscript') {
|
142
|
-
//到top
|
143
|
-
vertHeight -= textProps.fontSize * 2 / 5;
|
144
|
-
//top在向上收缩 -top行间距
|
145
|
-
//vertHeight -= textProps.fontSize * this.getParaLineHeight(textEle) / 20
|
146
|
-
}
|
147
|
-
for (let i = 0; i < textGroupRender.textMeasures.length; i++) {
|
148
|
-
const unit = textGroupRender.textMeasures[i];
|
149
|
-
this.ctx.fillText(unit.char, x + horX, y + vertHeight);
|
150
|
-
horX += unit.actualSize;
|
151
|
-
}
|
152
|
-
this.ctx.restore();
|
153
|
-
}
|
154
|
-
getParaLineHeight(textEle) {
|
155
|
-
const para = ElementUtil.getParentByType(textEle, ParagraphElement);
|
156
|
-
if (!para) {
|
157
|
-
throw new Error('未能找到父级段落元素');
|
158
|
-
}
|
159
|
-
return para.props.lineHeight;
|
160
|
-
}
|
161
|
-
measureText(text, textProps) {
|
162
|
-
this.ctx.fillStyle = textProps.color;
|
163
|
-
this.ctx.font = textProps.getFont();
|
164
|
-
const textMeasure = this.ctx.measureText(text);
|
165
|
-
return { width: textMeasure.width, height: textProps.fontSize };
|
166
|
-
}
|
167
|
-
measureTextUnits(units, textProps) {
|
168
|
-
this.ctx.font = textProps.getFont();
|
169
|
-
const letterSpace = textProps.letterSpace ?? 0;
|
170
|
-
for (let i = 0; i < units.length; i++) {
|
171
|
-
const char = units[i];
|
172
|
-
const textMeasure = this.ctx.measureText(char.char);
|
173
|
-
char.actualSize = textMeasure.width + letterSpace;
|
174
|
-
char.sourceSize = textMeasure.width;
|
175
|
-
}
|
176
|
-
}
|
177
|
-
clearRect(x, y, width, height) {
|
178
|
-
this.ctx.clearRect(x, y, width, height);
|
179
|
-
}
|
180
|
-
save() {
|
181
|
-
this.ctx.save();
|
182
|
-
}
|
183
|
-
restore() {
|
184
|
-
this.ctx.restore();
|
185
|
-
}
|
186
|
-
strokeRect(x, y, width, height, strokeColor = 'black', strokeWidth = 1) {
|
187
|
-
x = Math.ceil(x);
|
188
|
-
y = Math.ceil(y);
|
189
|
-
x += 0.5;
|
190
|
-
y += 0.5;
|
191
|
-
this.ctx.save();
|
192
|
-
this.ctx.lineWidth = strokeWidth;
|
193
|
-
this.ctx.strokeStyle = strokeColor;
|
194
|
-
this.ctx.strokeRect(x, y, width, height);
|
195
|
-
this.ctx.restore();
|
196
|
-
//this.strokeLines([{ x, y }, { x: x + width, y }, { x: x + width, y: y + height }, { x, y: y + height }, { x, y }], strokeWidth, strokeColor);
|
197
|
-
}
|
198
|
-
//strokeRectImageData(x:number)
|
199
|
-
drawLine(x, y, width, lineColor = 'black', lineWidth = 1) {
|
200
|
-
x = Math.ceil(x);
|
201
|
-
y = Math.ceil(y);
|
202
|
-
x += 0.5;
|
203
|
-
y += 0.5;
|
204
|
-
this.ctx.save();
|
205
|
-
this.ctx.strokeStyle = lineColor;
|
206
|
-
this.ctx.lineWidth = lineWidth;
|
207
|
-
this.ctx.beginPath();
|
208
|
-
this.ctx.moveTo(x, y);
|
209
|
-
this.ctx.lineTo(x + width, y);
|
210
|
-
this.ctx.stroke();
|
211
|
-
this.ctx.closePath();
|
212
|
-
this.ctx.restore();
|
213
|
-
}
|
214
|
-
fillRect(x, y, width, height, fillColor = 'white', shadowBlur = 0, shadowColor = 'black') {
|
215
|
-
x = Math.ceil(x);
|
216
|
-
y = Math.ceil(y);
|
217
|
-
x += 0.5;
|
218
|
-
y += 0.5;
|
219
|
-
this.ctx.save();
|
220
|
-
this.ctx.fillStyle = fillColor;
|
221
|
-
this.ctx.shadowBlur = shadowBlur;
|
222
|
-
this.ctx.shadowColor = shadowColor;
|
223
|
-
this.ctx.beginPath();
|
224
|
-
this.ctx.moveTo(x, y);
|
225
|
-
this.ctx.lineTo(x + width, y);
|
226
|
-
this.ctx.lineTo(x + width, y + height);
|
227
|
-
this.ctx.lineTo(x, y + height);
|
228
|
-
this.ctx.lineTo(x, y);
|
229
|
-
this.ctx.fill();
|
230
|
-
this.ctx.closePath();
|
231
|
-
this.ctx.restore();
|
232
|
-
}
|
233
|
-
strokeLines(lines, width = 1, strokeColor = 'black') {
|
234
|
-
this.ctx.save();
|
235
|
-
this.ctx.strokeStyle = strokeColor;
|
236
|
-
this.ctx.lineWidth = width;
|
237
|
-
this.ctx.lineCap = 'round';
|
238
|
-
this.ctx.beginPath();
|
239
|
-
for (let i = 0; i < lines.length; i++) {
|
240
|
-
let { x, y } = lines[i];
|
241
|
-
x = Math.ceil(x);
|
242
|
-
y = Math.ceil(y);
|
243
|
-
x += 0.5;
|
244
|
-
y += 0.5;
|
245
|
-
if (i === 0) {
|
246
|
-
this.ctx.moveTo(x, y);
|
247
|
-
}
|
248
|
-
else {
|
249
|
-
this.ctx.lineTo(x, y);
|
250
|
-
}
|
251
|
-
}
|
252
|
-
this.ctx.stroke();
|
253
|
-
this.ctx.closePath();
|
254
|
-
this.ctx.restore();
|
255
|
-
}
|
256
|
-
fillLines(lines, width = 1, fillColor = 'black') {
|
257
|
-
this.ctx.save();
|
258
|
-
this.ctx.beginPath();
|
259
|
-
this.ctx.fillStyle = fillColor;
|
260
|
-
this.ctx.lineWidth = width;
|
261
|
-
for (let i = 0; i < lines.length; i++) {
|
262
|
-
let { x, y } = lines[i];
|
263
|
-
x = Math.ceil(x);
|
264
|
-
y = Math.ceil(y);
|
265
|
-
x += 0.5;
|
266
|
-
y += 0.5;
|
267
|
-
if (i === 0) {
|
268
|
-
this.ctx.moveTo(x, y);
|
269
|
-
}
|
270
|
-
else {
|
271
|
-
this.ctx.lineTo(x, y);
|
272
|
-
}
|
273
|
-
}
|
274
|
-
this.ctx.stroke();
|
275
|
-
this.ctx.closePath();
|
276
|
-
this.ctx.restore();
|
277
|
-
}
|
278
|
-
drawCheckBox(x, y, width, height, isChecked) {
|
279
|
-
this.strokeRect(x, y, width, height, 'black', 1);
|
280
|
-
if (isChecked) {
|
281
|
-
const lines = [];
|
282
|
-
lines.push({ x: x + (Math.ceil(width / 4)), y: y + (Math.ceil(height / 2)) });
|
283
|
-
lines.push({ x: x + (Math.ceil(width / 2)), y: y + (Math.floor(height * 3 / 4)) });
|
284
|
-
lines.push({ x: x + (Math.ceil(width * 3 / 4)), y: y + (Math.ceil(height / 4)) });
|
285
|
-
this.strokeLines(lines, 2, 'red');
|
286
|
-
}
|
287
|
-
}
|
288
|
-
drawRadioBox(x, y, width, height, isChecked) {
|
289
|
-
x = x + Math.floor(width / 2);
|
290
|
-
y = y + Math.floor(height / 2);
|
291
|
-
width = Math.floor(width / 2);
|
292
|
-
this.ctx.save();
|
293
|
-
this.ctx.strokeStyle = 'black';
|
294
|
-
this.ctx.beginPath();
|
295
|
-
this.ctx.arc(x, y, width, 0, 2 * Math.PI);
|
296
|
-
this.ctx.stroke();
|
297
|
-
this.ctx.closePath();
|
298
|
-
if (isChecked) {
|
299
|
-
this.ctx.fillStyle = 'black';
|
300
|
-
this.ctx.beginPath();
|
301
|
-
this.ctx.arc(x, y, Math.floor(width / 5 * 3), 0, 2 * Math.PI);
|
302
|
-
this.ctx.closePath();
|
303
|
-
this.ctx.fill();
|
304
|
-
}
|
305
|
-
this.ctx.restore();
|
306
|
-
}
|
307
|
-
/**
|
308
|
-
* 绘制图片
|
309
|
-
* @param image
|
310
|
-
* @param sx image的矩形(裁剪)选择框的左上角 X 轴坐标
|
311
|
-
* @param sy image的矩形(裁剪)选择框的左上角 Y 轴坐标
|
312
|
-
* @param sWidth image的矩形(裁剪)选择框的宽度
|
313
|
-
* @param sHeight image的矩形(裁剪)选择框的高度
|
314
|
-
* @param dx image的左上角在目标canvas上 X 轴坐标
|
315
|
-
* @param dy image的左上角在目标canvas上 Y 轴坐标
|
316
|
-
* @param dWidth image在目标canvas上绘制的宽度
|
317
|
-
* @param dHeight image在目标canvas上绘制的高度
|
318
|
-
*/
|
319
|
-
drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {
|
320
|
-
this.ctx.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
|
321
|
-
}
|
322
|
-
drawDashLine(points, lineDash, lineColor = 'black', lineWidth = 1) {
|
323
|
-
this.ctx.save();
|
324
|
-
this.ctx.setLineDash(lineDash);
|
325
|
-
this.ctx.strokeStyle = lineColor;
|
326
|
-
this.ctx.lineWidth = lineWidth;
|
327
|
-
this.ctx.beginPath();
|
328
|
-
for (let i = 0; i < points.length; i++) {
|
329
|
-
let { x, y } = points[i];
|
330
|
-
x += 0.5;
|
331
|
-
y += 0.5;
|
332
|
-
if (i === 0) {
|
333
|
-
this.ctx.moveTo(x, y);
|
334
|
-
}
|
335
|
-
else {
|
336
|
-
this.ctx.lineTo(x, y);
|
337
|
-
}
|
338
|
-
}
|
339
|
-
this.ctx.stroke();
|
340
|
-
this.ctx.closePath();
|
341
|
-
this.ctx.restore();
|
342
|
-
}
|
343
|
-
roundRect(x, y, width, height, radius, fill, stroke) {
|
344
|
-
x += 0.5;
|
345
|
-
y += 0.5;
|
346
|
-
if (typeof stroke === 'undefined') {
|
347
|
-
stroke = true;
|
348
|
-
}
|
349
|
-
if (typeof radius === 'number') {
|
350
|
-
radius = { tl: radius, tr: radius, br: radius, bl: radius };
|
351
|
-
}
|
352
|
-
else {
|
353
|
-
var defaultRadius = { tl: 0, tr: 0, br: 0, bl: 0 };
|
354
|
-
for (var side in defaultRadius) {
|
355
|
-
radius[side] = radius[side] || defaultRadius[side];
|
356
|
-
}
|
357
|
-
}
|
358
|
-
this.ctx.beginPath();
|
359
|
-
this.ctx.lineWidth = 1;
|
360
|
-
this.ctx.moveTo(x + radius.tl, y);
|
361
|
-
this.ctx.lineTo(x + width - radius.tr, y);
|
362
|
-
this.ctx.quadraticCurveTo(x + width, y, x + width, y + radius.tr);
|
363
|
-
this.ctx.lineTo(x + width, y + height - radius.br);
|
364
|
-
this.ctx.quadraticCurveTo(x + width, y + height, x + width - radius.br, y + height);
|
365
|
-
this.ctx.lineTo(x + radius.bl, y + height);
|
366
|
-
this.ctx.quadraticCurveTo(x, y + height, x, y + height - radius.bl);
|
367
|
-
this.ctx.lineTo(x, y + radius.tl);
|
368
|
-
this.ctx.quadraticCurveTo(x, y, x + radius.tl, y);
|
369
|
-
this.ctx.closePath();
|
370
|
-
if (fill) {
|
371
|
-
this.ctx.fill();
|
372
|
-
}
|
373
|
-
if (stroke) {
|
374
|
-
this.ctx.stroke();
|
375
|
-
}
|
376
|
-
}
|
377
|
-
clip(x, y, width, height) {
|
378
|
-
this.ctx.save();
|
379
|
-
this.ctx.beginPath();
|
380
|
-
this.ctx.rect(x, y, width, height);
|
381
|
-
this.ctx.clip();
|
382
|
-
}
|
383
|
-
}
|
384
|
-
//# sourceMappingURL=render-context.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"render-context.js","sourceRoot":"lib/","sources":["framework/render-context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAmB3D,MAAM,OAAO,cAAc;IAOJ;IAA0C;IAAiC;IAN9F,cAAc,CAAgB;IAC9B,eAAe,CAAgB;IAC/B,QAAQ,GAAqB,MAAM,CAAC;IAC5B,gBAAgB,CAAqB;IACrC,gBAAgB,CAAqB;IAE7C,YAAmB,OAAiC,EAAS,WAAwB,EAAS,MAAqB;QAAhG,YAAO,GAAP,OAAO,CAA0B;QAAS,gBAAW,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,EAAE,CAAC,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QACrB,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACnB;QACD,IAAI,MAAM,EAAE;YACR,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;SACrB;IAEL,CAAC;IAED,IAAI,CAAC,CAAS,EAAE,CAAS,EAAE,KAAa,EAAE,MAAc;QACpD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAChB,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;CAEJ","sourcesContent":["import { EditorContext } from \"./document-context\";\nimport { Position, ViewOptions } from \"./element-define\";\nimport { TextProps } from \"./element-props\";\nimport { ElementUtil } from \"./element-util\";\nimport { DocumentRenderObject } from \"./impl/document/doc-impl\";\nimport { ParagraphElement } from \"./impl/paragraph/p-impl\";\nimport { TextGroupElement, TextGroupRenderObject } from \"./impl/text/text-impl\";\n\nexport interface TextUnits {\n sourceSize: number,\n actualSize: number,\n char: string\n}\n\nexport type RenderContenxtType = {\n contentContext: PaintContent;\n overlaysContext: PaintContent;\n drawMode: 'view' | 'print';\n clear(): void;\n viewOptions: ViewOptions;\n docCtx: EditorContext;\n commit(pageSetting: { width: number, height: number } | null): void\n};\n\nexport class RenderContenxt {\n contentContext!: PaintContent;\n overlaysContext!: PaintContent;\n drawMode: 'view' | 'print' = 'view';\n private contentOffCanvas!: HTMLCanvasElement;\n private overlayOffCanvas!: HTMLCanvasElement;\n\n constructor(public mainCtx: CanvasRenderingContext2D, public viewOptions: ViewOptions, public docCtx: EditorContext) {\n this.createNativeCanvas();\n }\n\n private createNativeCanvas() {\n this.contentOffCanvas = document.createElement('canvas');\n this.overlayOffCanvas = document.createElement('canvas');\n this.contentContext = new PaintContent(this.contentOffCanvas.getContext('2d') as CanvasRenderingContext2D, this.viewOptions);\n this.overlaysContext = new PaintContent(this.overlayOffCanvas.getContext('2d') as CanvasRenderingContext2D, this.viewOptions);\n this.setCanvasProps();\n }\n\n // private createOffscreenCanvas() {\n // this.contentOffCanvas = new OffscreenCanvas(250, 250);\n // this.overlayOffCanvas = new OffscreenCanvas(250, 250);\n // this.contentContext = new PaintContent(this.contentOffCanvas.getContext('2d') as OffscreenCanvasRenderingContext2D, this.viewOptions);\n // this.overlaysContext = new PaintContent(this.overlayOffCanvas.getContext('2d') as OffscreenCanvasRenderingContext2D, this.viewOptions);\n // this.setCanvasProps();\n // }\n\n setCanvasProps(pageSetting: { width: number, height: number } | null = null): void {\n if (!pageSetting) {\n pageSetting = { width: this.viewOptions.viewSettings.width, height: this.viewOptions.viewPaintHeight }\n if (this.viewOptions.showReviewWindow) {\n pageSetting.width += this.viewOptions.reviewWindowWidth;\n }\n }\n pageSetting = pageSetting || {\n width: this.viewOptions.viewSettings.width,\n height: this.viewOptions.viewPaintHeight\n };\n ElementUtil.setCanvasProps(this.contentOffCanvas, this.contentContext.ctx, pageSetting, this.viewOptions.scale)\n ElementUtil.setCanvasProps(this.overlayOffCanvas, this.overlaysContext.ctx, pageSetting, this.viewOptions.scale)\n ElementUtil.setCanvasProps(this.mainCtx.canvas, this.mainCtx, pageSetting, this.viewOptions.scale)\n }\n\n clear(): void {\n this.contentContext.clear();\n this.overlaysContext.clear();\n this.mainCtx.clearRect(0, 0, this.mainCtx.canvas.width, this.mainCtx.canvas.height);\n }\n\n commit(pageSetting: { width: number, height: number } | null = null): void {\n //pageSetting = pageSetting || { width: this.viewOptions.viewSettings.width, height: this.viewOptions.viewPaintHeight };\n if (!pageSetting) {\n pageSetting = { width: this.viewOptions.viewSettings.width, height: this.viewOptions.viewPaintHeight }\n if (this.viewOptions.showReviewWindow) {\n pageSetting.width += this.viewOptions.reviewWindowWidth;\n }\n }\n let { width, height } = pageSetting;\n //this.mainCtx.clearRect(0, 0, this.mainCtx.canvas.width, this.mainCtx.canvas.height);\n if (!this.overlayOffCanvas.width || !this.overlayOffCanvas.height) {\n return;\n }\n\n this.mainCtx.drawImage(this.overlayOffCanvas, 0, 0, ElementUtil.getDprNumber(width, this.viewOptions.scale), ElementUtil.getDprNumber(height));\n //console.time('drawImage');\n this.mainCtx.drawImage(this.contentOffCanvas, 0, 0, ElementUtil.getDprNumber(width, this.viewOptions.scale), ElementUtil.getDprNumber(height));\n //console.timeEnd('drawImage');\n }\n\n}\n\nexport class PaintContent {\n constructor(public ctx: CanvasRenderingContext2D, private viewOptions: ViewOptions) {\n this.init();\n }\n\n init(): void {\n this.ctx.textBaseline = 'alphabetic';\n }\n\n setGlobalAlpha(alpha: number): void {\n this.ctx.globalAlpha = alpha;\n }\n\n getGlobalAlpha(): number {\n return this.ctx.globalAlpha;\n }\n\n clear(): void {\n this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);\n this.init();\n }\n\n drawText(text: string, textProps: TextProps, x: number, y: number, width: number, height: number): void {\n if (textProps.background) {\n this.fillRect(x, y, width, height, textProps.background);\n }\n this.ctx.save();\n this.ctx.fillStyle = textProps.color;\n this.ctx.font = textProps.getFont();\n const vertHeight = textProps.vertAlign === 'superscript' ? 0 : height;\n this.ctx.fillText(text, x, y + vertHeight - height / 7);\n this.ctx.restore();\n if (textProps.linethrough) {\n this.drawLine(x, y + (Math.ceil(height / 2)), width, textProps.color, 1);\n }\n if (textProps.underline) {\n this.drawLine(x, y + height, width, textProps.color, 1);\n }\n if (textProps.overline) {\n this.drawLine(x, y, width, textProps.color, 1);\n }\n }\n\n fillCircular(x: number, y: number, r: number, color: string = 'black'): void {\n this.ctx.save();\n this.ctx.beginPath();\n this.ctx.fillStyle = color;\n this.ctx.arc(x, y, r, 0, 2 * Math.PI);\n this.ctx.fill();\n this.ctx.restore();\n }\n\n drawTextUnits(textGroupRender: TextGroupRenderObject, x: number, y: number): void {\n const textEle = textGroupRender.element as TextGroupElement;\n const textProps = textEle.props;\n const { width, height } = textGroupRender.rect;\n this.ctx.save();\n this.ctx.fillStyle = textProps.color;\n this.ctx.font = textProps.getFont();\n if (textProps.background) {\n this.fillRect(x, y, width, height, textProps.background);\n }\n if (textProps.linethrough) {\n this.drawLine(x, y + (Math.ceil(height / 2)), width, textProps.color, 1);\n }\n if (textProps.underline) {\n this.drawLine(x, y + height, width, textProps.color, 1);\n }\n if (textProps.overline) {\n this.drawLine(x, y, width, textProps.color, 1);\n }\n let horX = 0;\n let vertHeight = height - (height / 7);\n if (textProps.vertAlign === 'superscript') {\n //到top\n vertHeight -= textProps.fontSize * 2 / 5;\n //top在向上收缩 -top行间距\n //vertHeight -= textProps.fontSize * this.getParaLineHeight(textEle) / 20\n }\n for (let i = 0; i < textGroupRender.textMeasures.length; i++) {\n const unit = textGroupRender.textMeasures[i];\n this.ctx.fillText(unit.char, x + horX, y + vertHeight);\n horX += unit.actualSize;\n }\n this.ctx.restore();\n }\n\n getParaLineHeight(textEle: TextGroupElement): number {\n const para = ElementUtil.getParentByType(textEle, ParagraphElement);\n if (!para) {\n throw new Error('未能找到父级段落元素')\n }\n return para.props.lineHeight;\n }\n\n measureText(text: string, textProps: TextProps): { width: number, height: number } {\n this.ctx.fillStyle = textProps.color;\n this.ctx.font = textProps.getFont();\n const textMeasure = this.ctx.measureText(text);\n return { width: textMeasure.width, height: textProps.fontSize };\n }\n\n\n measureTextUnits(units: Array<TextUnits>, textProps: TextProps): void {\n this.ctx.font = textProps.getFont();\n const letterSpace = textProps.letterSpace ?? 0;\n for (let i = 0; i < units.length; i++) {\n const char = units[i];\n const textMeasure = this.ctx.measureText(char.char);\n char.actualSize = textMeasure.width + letterSpace;\n char.sourceSize = textMeasure.width;\n }\n }\n\n clearRect(x: number, y: number, width: number, height: number): void {\n this.ctx.clearRect(x, y, width, height);\n }\n\n save(): void {\n this.ctx.save();\n }\n\n restore(): void {\n this.ctx.restore();\n }\n\n\n strokeRect(x: number, y: number, width: number, height: number, strokeColor = 'black', strokeWidth = 1): void {\n x = Math.ceil(x);\n y = Math.ceil(y);\n x += 0.5;\n y += 0.5;\n this.ctx.save();\n this.ctx.lineWidth = strokeWidth;\n this.ctx.strokeStyle = strokeColor;\n this.ctx.strokeRect(x, y, width, height);\n this.ctx.restore();\n //this.strokeLines([{ x, y }, { x: x + width, y }, { x: x + width, y: y + height }, { x, y: y + height }, { x, y }], strokeWidth, strokeColor);\n }\n\n //strokeRectImageData(x:number)\n\n drawLine(x: number, y: number, width: number, lineColor = 'black', lineWidth = 1): void {\n x = Math.ceil(x);\n y = Math.ceil(y);\n x += 0.5;\n y += 0.5;\n this.ctx.save();\n this.ctx.strokeStyle = lineColor;\n this.ctx.lineWidth = lineWidth;\n this.ctx.beginPath();\n this.ctx.moveTo(x, y);\n this.ctx.lineTo(x + width, y);\n this.ctx.stroke();\n this.ctx.closePath();\n this.ctx.restore();\n }\n\n fillRect(x: number, y: number, width: number, height: number, fillColor = 'white', shadowBlur = 0, shadowColor = 'black'): void {\n x = Math.ceil(x);\n y = Math.ceil(y);\n x += 0.5;\n y += 0.5;\n this.ctx.save();\n this.ctx.fillStyle = fillColor;\n this.ctx.shadowBlur = shadowBlur;\n this.ctx.shadowColor = shadowColor;\n this.ctx.beginPath();\n this.ctx.moveTo(x, y);\n this.ctx.lineTo(x + width, y);\n this.ctx.lineTo(x + width, y + height);\n this.ctx.lineTo(x, y + height);\n this.ctx.lineTo(x, y);\n this.ctx.fill();\n this.ctx.closePath();\n this.ctx.restore();\n }\n\n strokeLines(lines: Array<Position>, width = 1, strokeColor = 'black'): void {\n this.ctx.save();\n this.ctx.strokeStyle = strokeColor;\n this.ctx.lineWidth = width;\n this.ctx.lineCap = 'round';\n this.ctx.beginPath();\n for (let i = 0; i < lines.length; i++) {\n let { x, y } = lines[i];\n x = Math.ceil(x);\n y = Math.ceil(y);\n x += 0.5;\n y += 0.5;\n if (i === 0) {\n this.ctx.moveTo(x, y);\n } else {\n this.ctx.lineTo(x, y);\n }\n }\n this.ctx.stroke();\n this.ctx.closePath();\n this.ctx.restore();\n }\n\n fillLines(lines: Array<Position>, width = 1, fillColor = 'black'): void {\n this.ctx.save();\n this.ctx.beginPath();\n this.ctx.fillStyle = fillColor;\n this.ctx.lineWidth = width;\n for (let i = 0; i < lines.length; i++) {\n let { x, y } = lines[i];\n x = Math.ceil(x);\n y = Math.ceil(y);\n x += 0.5;\n y += 0.5;\n if (i === 0) {\n this.ctx.moveTo(x, y);\n } else {\n this.ctx.lineTo(x, y);\n }\n }\n this.ctx.stroke();\n this.ctx.closePath();\n this.ctx.restore();\n }\n\n\n drawCheckBox(x: number, y: number, width: number, height: number, isChecked: boolean): void {\n this.strokeRect(x, y, width, height, 'black', 1);\n if (isChecked) {\n const lines: Array<Position> = [];\n lines.push({ x: x + (Math.ceil(width / 4)), y: y + (Math.ceil(height / 2)) });\n lines.push({ x: x + (Math.ceil(width / 2)), y: y + (Math.floor(height * 3 / 4)) });\n lines.push({ x: x + (Math.ceil(width * 3 / 4)), y: y + (Math.ceil(height / 4)) });\n this.strokeLines(lines, 2, 'red');\n }\n }\n\n drawRadioBox(x: number, y: number, width: number, height: number, isChecked: boolean): void {\n x = x + Math.floor(width / 2);\n y = y + Math.floor(height / 2);\n width = Math.floor(width / 2);\n this.ctx.save();\n this.ctx.strokeStyle = 'black';\n this.ctx.beginPath();\n this.ctx.arc(x, y, width, 0, 2 * Math.PI);\n this.ctx.stroke();\n this.ctx.closePath();\n if (isChecked) {\n this.ctx.fillStyle = 'black';\n this.ctx.beginPath();\n this.ctx.arc(x, y, Math.floor(width / 5 * 3), 0, 2 * Math.PI);\n this.ctx.closePath();\n this.ctx.fill();\n }\n this.ctx.restore();\n }\n\n\n /**\n * 绘制图片\n * @param image\n * @param sx image的矩形(裁剪)选择框的左上角 X 轴坐标\n * @param sy image的矩形(裁剪)选择框的左上角 Y 轴坐标\n * @param sWidth image的矩形(裁剪)选择框的宽度\n * @param sHeight image的矩形(裁剪)选择框的高度\n * @param dx image的左上角在目标canvas上 X 轴坐标\n * @param dy image的左上角在目标canvas上 Y 轴坐标\n * @param dWidth image在目标canvas上绘制的宽度\n * @param dHeight image在目标canvas上绘制的高度\n */\n drawImage(image: HTMLImageElement, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number): void {\n this.ctx.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);\n }\n\n drawDashLine(points: Array<Position>, lineDash: Array<number>, lineColor = 'black', lineWidth = 1): void {\n this.ctx.save();\n this.ctx.setLineDash(lineDash);\n this.ctx.strokeStyle = lineColor;\n this.ctx.lineWidth = lineWidth;\n this.ctx.beginPath();\n for (let i = 0; i < points.length; i++) {\n let { x, y } = points[i];\n x += 0.5;\n y += 0.5;\n if (i === 0) {\n this.ctx.moveTo(x, y);\n } else {\n this.ctx.lineTo(x, y);\n }\n }\n this.ctx.stroke();\n this.ctx.closePath();\n this.ctx.restore();\n }\n\n roundRect(x: number, y: number, width: number, height: number, radius: number | { tl: number, tr: number, br: number, bl: number }, fill: boolean, stroke: boolean) {\n x += 0.5;\n y += 0.5;\n if (typeof stroke === 'undefined') {\n stroke = true;\n }\n if (typeof radius === 'number') {\n radius = { tl: radius, tr: radius, br: radius, bl: radius };\n } else {\n var defaultRadius = { tl: 0, tr: 0, br: 0, bl: 0 };\n for (var side in defaultRadius) {\n radius[side] = radius[side] || defaultRadius[side];\n }\n }\n this.ctx.beginPath();\n this.ctx.lineWidth = 1;\n this.ctx.moveTo(x + radius.tl, y);\n this.ctx.lineTo(x + width - radius.tr, y);\n this.ctx.quadraticCurveTo(x + width, y, x + width, y + radius.tr);\n this.ctx.lineTo(x + width, y + height - radius.br);\n this.ctx.quadraticCurveTo(x + width, y + height, x + width - radius.br, y + height);\n this.ctx.lineTo(x + radius.bl, y + height);\n this.ctx.quadraticCurveTo(x, y + height, x, y + height - radius.bl);\n this.ctx.lineTo(x, y + radius.tl);\n this.ctx.quadraticCurveTo(x, y, x + radius.tl, y);\n this.ctx.closePath();\n if (fill) {\n this.ctx.fill();\n }\n if (stroke) {\n this.ctx.stroke();\n }\n\n }\n\n clip(x: number, y: number, width: number, height: number): void {\n this.ctx.save();\n this.ctx.beginPath();\n this.ctx.rect(x, y, width, height);\n this.ctx.clip();\n }\n\n}\n"]}
|
@@ -1,195 +0,0 @@
|
|
1
|
-
import { Rect, MarginProps, PaddingProps } from './element-define';
|
2
|
-
/**
|
3
|
-
* 定义组件的UI形式的渲染
|
4
|
-
*/
|
5
|
-
export class RenderObject {
|
6
|
-
element;
|
7
|
-
margin;
|
8
|
-
padding;
|
9
|
-
rect = new Rect();
|
10
|
-
parent;
|
11
|
-
/**
|
12
|
-
* 可点击性,例如:null-text 占位符元素不具备可点击能力
|
13
|
-
*/
|
14
|
-
disableClick;
|
15
|
-
constructor(element) {
|
16
|
-
this.element = element;
|
17
|
-
this.margin = new MarginProps();
|
18
|
-
this.padding = new PaddingProps();
|
19
|
-
}
|
20
|
-
pagePaintCompleted(ctx, position) { }
|
21
|
-
destroy() {
|
22
|
-
//this.parent = null;
|
23
|
-
//this.margin = null;
|
24
|
-
//this.padding = null;
|
25
|
-
//this.rect = null;
|
26
|
-
//this.element = null;
|
27
|
-
}
|
28
|
-
/**
|
29
|
-
* 获取内容区域框体
|
30
|
-
* @param render
|
31
|
-
* @returns
|
32
|
-
*/
|
33
|
-
getInnnerRect() {
|
34
|
-
const { padding } = this;
|
35
|
-
const rect = new Rect();
|
36
|
-
rect.x = padding.left;
|
37
|
-
rect.y = padding.top;
|
38
|
-
rect.maxWidth = this.rect.maxWidth - padding.left - padding.right;
|
39
|
-
if (this.rect.maxHeight) {
|
40
|
-
rect.maxHeight = this.rect.maxHeight - padding.top - padding.bottom;
|
41
|
-
}
|
42
|
-
return rect;
|
43
|
-
}
|
44
|
-
getInnerMaxWidth() {
|
45
|
-
if (!this.rect.maxWidth) {
|
46
|
-
throw new Error('this.rect.maxWidth is null');
|
47
|
-
}
|
48
|
-
const { padding, margin } = this;
|
49
|
-
return this.rect.maxWidth - padding.left - padding.right - margin.left - margin.bottom;
|
50
|
-
}
|
51
|
-
/**
|
52
|
-
* 根据内框内容高度,更新外框框体高度
|
53
|
-
* @param render
|
54
|
-
* @param innerRect
|
55
|
-
*/
|
56
|
-
updateRenderHeight(innerRect) {
|
57
|
-
const innnerHeight = typeof innerRect === 'number' ? innerRect : innerRect.height;
|
58
|
-
const { padding, margin } = this;
|
59
|
-
//外层容器高度等于内容高度+外边距+内边距
|
60
|
-
this.rect.height = innnerHeight + padding.top + padding.bottom;
|
61
|
-
}
|
62
|
-
getIndex() {
|
63
|
-
if (this.parent) {
|
64
|
-
return this.parent.getChildIndex(this);
|
65
|
-
}
|
66
|
-
else {
|
67
|
-
return 0;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
/**
|
72
|
-
* 叶子节点渲染元素
|
73
|
-
*/
|
74
|
-
export class LeafRenderObject extends RenderObject {
|
75
|
-
constructor(element) {
|
76
|
-
super(element);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
/**
|
80
|
-
* 枝干节点渲染元素
|
81
|
-
*/
|
82
|
-
export class BranchRenderObject extends RenderObject {
|
83
|
-
constructor(element) {
|
84
|
-
super(element);
|
85
|
-
}
|
86
|
-
chilren = [];
|
87
|
-
getItems() {
|
88
|
-
return this.chilren;
|
89
|
-
}
|
90
|
-
addChild(...items) {
|
91
|
-
for (let i = 0; i < items.length; i++) {
|
92
|
-
const item = items[i];
|
93
|
-
item.parent = this;
|
94
|
-
this.chilren.push(item);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
insertChild(item, index) {
|
98
|
-
this.chilren.splice(index, 0, item);
|
99
|
-
item.parent = this;
|
100
|
-
}
|
101
|
-
removeChild(child) {
|
102
|
-
const index = this.chilren.indexOf(child);
|
103
|
-
if (index < 0) {
|
104
|
-
throw new Error('为查找到当前元素');
|
105
|
-
}
|
106
|
-
if (child.parent === this) {
|
107
|
-
//child.parent = null;
|
108
|
-
}
|
109
|
-
this.chilren.splice(index, 1);
|
110
|
-
}
|
111
|
-
removeChildByIndex(index) {
|
112
|
-
const child = this.chilren[index];
|
113
|
-
if (child) {
|
114
|
-
this.chilren.splice(index, 1);
|
115
|
-
//child.parent = null;
|
116
|
-
}
|
117
|
-
else {
|
118
|
-
throw new Error('为查找到当前元素');
|
119
|
-
}
|
120
|
-
}
|
121
|
-
clear() {
|
122
|
-
const items = [...this.chilren];
|
123
|
-
for (let i = items.length - 1; i >= 0; i--) {
|
124
|
-
this.removeChildByIndex(i);
|
125
|
-
}
|
126
|
-
}
|
127
|
-
get length() {
|
128
|
-
return this.chilren.length;
|
129
|
-
}
|
130
|
-
getChild(index) {
|
131
|
-
return this.chilren[index];
|
132
|
-
}
|
133
|
-
getChildIndex(child) {
|
134
|
-
return this.chilren.indexOf(child);
|
135
|
-
}
|
136
|
-
destroy() {
|
137
|
-
super.destroy();
|
138
|
-
const len = this.length;
|
139
|
-
for (let i = len - 1; i >= 0; i--) {
|
140
|
-
const child = this.getChild(i);
|
141
|
-
child.destroy();
|
142
|
-
//this.removeChild(child);
|
143
|
-
}
|
144
|
-
this.chilren.length = 0;
|
145
|
-
//this.chilren = null;
|
146
|
-
}
|
147
|
-
}
|
148
|
-
/**
|
149
|
-
* 块级渲染元素
|
150
|
-
*/
|
151
|
-
export class BlockContentRenderObject extends BranchRenderObject {
|
152
|
-
setRenderWidth(maxWidth) {
|
153
|
-
this.rect.maxWidth = maxWidth;
|
154
|
-
this.rect.width = maxWidth;
|
155
|
-
}
|
156
|
-
}
|
157
|
-
export class InlineGroupRenderObject extends BranchRenderObject {
|
158
|
-
}
|
159
|
-
/**
|
160
|
-
* 包含块级渲染元素的容器元素,例如body、table-cell等
|
161
|
-
*/
|
162
|
-
export class BlockContainerRenderObject extends BranchRenderObject {
|
163
|
-
setRenderWidth(maxWidth) {
|
164
|
-
this.rect.maxWidth = maxWidth;
|
165
|
-
this.rect.width = maxWidth;
|
166
|
-
}
|
167
|
-
}
|
168
|
-
/**
|
169
|
-
* 多级 ‘BlockLineRectRenderObject’ 包裹元素,例如 p、table
|
170
|
-
*/
|
171
|
-
export class MuiltBlockLineRenderObject extends BlockContentRenderObject {
|
172
|
-
}
|
173
|
-
/**
|
174
|
-
* 容器-子内容为多个行内块级元素,例如table-row
|
175
|
-
*/
|
176
|
-
export class InlineBlockContainer extends MuiltBlockLineRenderObject {
|
177
|
-
}
|
178
|
-
/**
|
179
|
-
* 服务于table-cell
|
180
|
-
* 可被多级拆分的元素
|
181
|
-
*/
|
182
|
-
export class InlineMuiltBlockLineRenderObject extends MuiltBlockLineRenderObject {
|
183
|
-
}
|
184
|
-
/**
|
185
|
-
* 最小不可分割单位的块级行框,例如 p-line
|
186
|
-
* 一行不可存在于两个页面中,块级行框不能分布在两个页面中
|
187
|
-
*/
|
188
|
-
export class BlockLineRectRenderObject extends BlockContentRenderObject {
|
189
|
-
}
|
190
|
-
export var RenderObjectType;
|
191
|
-
(function (RenderObjectType) {
|
192
|
-
RenderObjectType[RenderObjectType["Branch"] = 0] = "Branch";
|
193
|
-
RenderObjectType[RenderObjectType["Leaf"] = 1] = "Leaf";
|
194
|
-
})(RenderObjectType || (RenderObjectType = {}));
|
195
|
-
//# sourceMappingURL=render-define.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"render-define.js","sourceRoot":"lib/","sources":["framework/render-define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAW,WAAW,EAAE,YAAY,EAAY,MAAM,kBAAkB,CAAA;AAErF;;GAEG;AACH,MAAM,OAAgB,YAAY;IASX;IARnB,MAAM,CAAe;IACrB,OAAO,CAAgB;IACvB,IAAI,GAAS,IAAI,IAAI,EAAE,CAAC;IACxB,MAAM,CAAsB;IAC5B;;MAEE;IACF,YAAY,CAAW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,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B","sourcesContent":["import { Rect, Element, MarginProps, PaddingProps, Position } from './element-define'\nimport { RenderContenxtType } from './render-context';\n/**\n * 定义组件的UI形式的渲染\n */\nexport abstract class RenderObject<T extends Element = Element> {\n margin!: MarginProps;\n padding!: PaddingProps;\n rect: Rect = new Rect();\n parent!: BranchRenderObject;\n /**\n * 可点击性,例如:null-text 占位符元素不具备可点击能力\n */\n disableClick!: boolean;\n constructor(public element: T) {\n this.margin = new MarginProps();\n this.padding = new PaddingProps();\n }\n abstract clone(): RenderObject;\n pagePaintCompleted(ctx: RenderContenxtType, position: Position): void { }\n destroy(): void {\n //this.parent = null;\n //this.margin = null;\n //this.padding = null;\n //this.rect = null;\n //this.element = null;\n }\n\n /**\n * 获取内容区域框体\n * @param render \n * @returns \n */\n getInnnerRect(): Rect {\n const { padding } = this;\n const rect = new Rect();\n rect.x = padding.left;\n rect.y = padding.top;\n rect.maxWidth = this.rect.maxWidth - padding.left - padding.right;\n if (this.rect.maxHeight) {\n rect.maxHeight = this.rect.maxHeight - padding.top - padding.bottom;\n }\n return rect;\n }\n\n getInnerMaxWidth(): number {\n if (!this.rect.maxWidth) {\n throw new Error('this.rect.maxWidth is null')\n }\n const { padding, margin } = this;\n return this.rect.maxWidth - padding.left - padding.right - margin.left - margin.bottom;\n }\n\n /**\n * 根据内框内容高度,更新外框框体高度\n * @param render \n * @param innerRect \n */\n updateRenderHeight(innerRect: Rect | number): void {\n const innnerHeight = typeof innerRect === 'number' ? innerRect : (<Rect>innerRect).height;\n const { padding, margin } = this;\n //外层容器高度等于内容高度+外边距+内边距\n this.rect.height = innnerHeight + padding.top + padding.bottom;\n }\n\n getIndex(): number {\n if (this.parent) {\n return this.parent.getChildIndex(this);\n } else {\n return 0;\n }\n }\n}\n\n/**\n * 叶子节点渲染元素\n */\nexport abstract class LeafRenderObject<T extends Element = Element> extends RenderObject<T> {\n constructor(element: T | null) {\n super(element as T);\n }\n abstract render(ctx: RenderContenxtType, position: { x: number, y: number }): void;\n\n}\n\n/**\n * 枝干节点渲染元素\n */\nexport abstract class BranchRenderObject<T extends Element = Element> extends RenderObject<T> {\n constructor(element: T | null) {\n super(element as T);\n }\n private chilren: Array<RenderObject> = [];\n getItems(): Array<RenderObject> {\n return this.chilren;\n }\n\n addChild(...items: Array<RenderObject>): void {\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n item.parent = this;\n this.chilren.push(item);\n }\n }\n\n insertChild(item: RenderObject, index: number): void {\n this.chilren.splice(index, 0, item);\n item.parent = this;\n }\n\n removeChild(child: RenderObject): void {\n const index = this.chilren.indexOf(child);\n if (index < 0) {\n throw new Error('为查找到当前元素');\n }\n if (child.parent === this) {\n //child.parent = null;\n }\n this.chilren.splice(index, 1);\n }\n\n removeChildByIndex(index: number): void {\n const child = this.chilren[index];\n if (child) {\n this.chilren.splice(index, 1);\n //child.parent = null;\n } else {\n throw new Error('为查找到当前元素');\n }\n }\n\n clear(): void {\n const items = [...this.chilren];\n for (let i = items.length - 1; i >= 0; i--) {\n this.removeChildByIndex(i);\n }\n }\n get length() {\n return this.chilren.length;\n }\n\n\n getChild<T extends RenderObject = RenderObject>(index: number): T {\n return this.chilren[index] as T;\n }\n\n getChildIndex(child: RenderObject): number {\n return this.chilren.indexOf(child);\n }\n\n abstract beginRender(ctx: RenderContenxtType, position: Position): void;\n abstract endRender(ctx: RenderContenxtType, position: Position): void;\n\n destroy(): void {\n super.destroy();\n const len = this.length;\n for (let i = len - 1; i >= 0; i--) {\n const child = this.getChild(i);\n child.destroy();\n //this.removeChild(child);\n }\n this.chilren.length = 0;\n //this.chilren = null;\n }\n}\n\n\n/**\n * 块级渲染元素\n */\nexport abstract class BlockContentRenderObject<T extends Element = Element> extends BranchRenderObject<T> {\n setRenderWidth(maxWidth: number): void {\n this.rect.maxWidth = maxWidth;\n this.rect.width = maxWidth;\n }\n}\n\nexport abstract class InlineGroupRenderObject<T extends Element = Element> extends BranchRenderObject<T> {\n}\n\n/**\n * 包含块级渲染元素的容器元素,例如body、table-cell等\n */\nexport abstract class BlockContainerRenderObject<T extends Element = Element> extends BranchRenderObject<T> {\n setRenderWidth(maxWidth: number): void {\n this.rect.maxWidth = maxWidth;\n this.rect.width = maxWidth;\n }\n}\n\n/**\n * 多级 ‘BlockLineRectRenderObject’ 包裹元素,例如 p、table\n */\nexport abstract class MuiltBlockLineRenderObject<T extends Element = Element> extends BlockContentRenderObject<T> { }\n\n/**\n * 容器-子内容为多个行内块级元素,例如table-row\n */\nexport abstract class InlineBlockContainer extends MuiltBlockLineRenderObject { }\n\n/**\n * 服务于table-cell\n * 可被多级拆分的元素\n */\nexport abstract class InlineMuiltBlockLineRenderObject extends MuiltBlockLineRenderObject { }\n\n/**\n * 最小不可分割单位的块级行框,例如 p-line\n * 一行不可存在于两个页面中,块级行框不能分布在两个页面中\n */\nexport abstract class BlockLineRectRenderObject extends BlockContentRenderObject { }\n\n\nexport type BorderType = 'left' | 'right' | 'top' | 'bottom' | 'left-middle' | 'right-middle' | 'top-middle' | 'bottom-middle' | 'none' | 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom';\nexport type CursorType = 'text' | 'row-resize' | 'col-resize' | 'none' | 'default' | 'move' | 'pointer' | 'w-resize' | 's-resize' | 'se-resize' | 'ne-resize';\nexport enum RenderObjectType {\n Branch = 0,\n Leaf = 1\n}\n\nexport interface IMeasureRenderStruct<T> {\n rect: Rect,\n render: T\n}\n"]}
|