@hailin-zheng/editor-core 1.1.5 → 1.1.7
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/controls/Canvas.d.ts +2 -5
- package/controls/Node.d.ts +15 -0
- package/controls/Text.d.ts +3 -2
- package/controls/ViewPaint.d.ts +9 -0
- package/index-cjs.js +194 -105
- package/index-cjs.js.map +1 -1
- package/index.js +194 -105
- package/index.js.map +1 -1
- package/med_editor/framework/element-serialize.d.ts +5 -0
- package/med_editor/framework/paragraph-arrange.d.ts +4 -0
- package/med_editor/texteditor.d.ts +14 -4
- package/package.json +1 -1
- package/timeline/TimeLineControl.d.ts +46 -0
- package/timeline/TimeValueGridControl.d.ts +96 -0
- package/timeline/TimelineConfig.d.ts +67 -0
- package/timeline/TimelineScrollbar.d.ts +25 -0
- package/timeline/TimelineStatus.d.ts +61 -0
- package/timeline/TimelineTick.d.ts +63 -0
- package/timeline/example.d.ts +2 -0
- package/timeline/timezone.d.ts +0 -2
package/controls/Canvas.d.ts
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { AbsolutePanel, IRenderData } from "./Node";
|
2
2
|
/**
|
3
3
|
* 采用绝对布局系统的容器
|
4
4
|
*/
|
5
|
-
export declare class Canvas extends
|
6
|
-
constructor();
|
7
|
-
measureOverride(e: IMeasureEvent, availableSize: Size): Size;
|
8
|
-
protected arrangeOverride(e: IArrangeEvent, finalSize: Size): Size;
|
5
|
+
export declare class Canvas extends AbsolutePanel {
|
9
6
|
render(e: IRenderData): void;
|
10
7
|
}
|
package/controls/Node.d.ts
CHANGED
@@ -42,6 +42,8 @@ export interface IAppState {
|
|
42
42
|
export declare abstract class NodeCore {
|
43
43
|
enableClip: boolean;
|
44
44
|
pointEvent: boolean;
|
45
|
+
allowHitTest: boolean;
|
46
|
+
hitTest(hitPos: Position, currPos: Position): boolean;
|
45
47
|
get enable(): boolean;
|
46
48
|
set enable(value: boolean);
|
47
49
|
private _enable;
|
@@ -171,6 +173,7 @@ export declare abstract class NodeItems extends NodeCore {
|
|
171
173
|
eventMap: WeakMap<NodeCore, Array<Subscription>>;
|
172
174
|
absoluteItems: boolean;
|
173
175
|
containerPropName: string;
|
176
|
+
constructor();
|
174
177
|
addChild(control: NodeCore, index?: number): void;
|
175
178
|
getRenderItems(): Array<NodeCore>;
|
176
179
|
removeChild(index: number | NodeCore): void;
|
@@ -184,6 +187,14 @@ export declare abstract class NodeItems extends NodeCore {
|
|
184
187
|
}
|
185
188
|
export declare abstract class Panel extends NodeItems {
|
186
189
|
}
|
190
|
+
/**
|
191
|
+
* 子内容采用绝对定位的容器
|
192
|
+
*/
|
193
|
+
export declare abstract class AbsolutePanel extends NodeItems {
|
194
|
+
protected constructor();
|
195
|
+
measureOverride(e: IMeasureEvent, availableSize: Size): Size;
|
196
|
+
protected arrangeOverride(e: IArrangeEvent, finalSize: Size): Size;
|
197
|
+
}
|
187
198
|
export interface ActiveAppContext {
|
188
199
|
root: SurfaceView;
|
189
200
|
render: () => void;
|
@@ -199,6 +210,10 @@ export declare function renderNode(node: NodeCore, renderCtx: ViewPaint, appStat
|
|
199
210
|
* @param renderCtx
|
200
211
|
*/
|
201
212
|
export declare function drawBorderline(node: NodeCore, renderCtx: ViewPaint): void;
|
213
|
+
/**
|
214
|
+
* 绘制外轮廓
|
215
|
+
*/
|
216
|
+
export declare function drawOutline(node: NodeCore, renderCtx: ViewPaint): void;
|
202
217
|
export declare function clipContent(node: NodeCore, renderCtx: ViewPaint): void;
|
203
218
|
export declare function translate(renderCtx: ViewPaint, x: number, y: number): void;
|
204
219
|
export declare function getParents(node: NodeCore): Array<NodeCore>;
|
package/controls/Text.d.ts
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
import { Size, IRenderData, IMeasureEvent, IArrangeEvent } from "./Node";
|
2
2
|
import { TextBase } from "./TextBase";
|
3
|
-
export declare type TextVertAlign = 'superscript' | 'subscript';
|
4
3
|
/**
|
5
4
|
* 文本元素尺寸默认按照横向排列进行测量,内容高度等于字体大小
|
6
5
|
* 如果有默认宽度限制,而且支持换行显示,则内容高度等于多行累计高度
|
7
6
|
*/
|
8
7
|
export declare class LabelNode extends TextBase {
|
8
|
+
constructor();
|
9
9
|
private _textWrapping;
|
10
10
|
get textWrapping(): "wrap" | "no";
|
11
11
|
set textWrapping(value: "wrap" | "no");
|
12
12
|
protected cacheTextRect: TextMeasureRect;
|
13
|
-
private
|
13
|
+
private lines;
|
14
14
|
measureOverride(e: IMeasureEvent, availableSize: Size): Size;
|
15
|
+
private getMuiltLines;
|
15
16
|
protected arrangeOverride(e: IArrangeEvent, finalSize: Size): Size;
|
16
17
|
private getTextProps;
|
17
18
|
private measureTextRect;
|
package/controls/ViewPaint.d.ts
CHANGED
@@ -17,11 +17,20 @@ export declare class ViewPaint {
|
|
17
17
|
getGlobalAlpha(): number;
|
18
18
|
clear(): void;
|
19
19
|
drawText(text: string, textProps: TextProps, x: number, y: number, width: number, height: number): void;
|
20
|
+
drawText2(text: string, textProps: {
|
21
|
+
color: string;
|
22
|
+
fontSize: number;
|
23
|
+
fontName: string;
|
24
|
+
}, x: number, y: number): void;
|
20
25
|
fillCircular(x: number, y: number, r: number, color?: string): void;
|
21
26
|
measureText(text: string, textProps: TextProps): {
|
22
27
|
width: number;
|
23
28
|
height: number;
|
24
29
|
};
|
30
|
+
measureText2(text: string, font: {
|
31
|
+
fontSize: number;
|
32
|
+
fontName: string;
|
33
|
+
}): number;
|
25
34
|
measureTextUnits(units: Array<TextUnits>, textProps: TextProps): void;
|
26
35
|
clearRect(x: number, y: number, width: number, height: number): void;
|
27
36
|
save(): void;
|
package/index-cjs.js
CHANGED
@@ -4201,15 +4201,10 @@ class TableUtil {
|
|
4201
4201
|
const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
|
4202
4202
|
if (vMergeEndIndex > rowIndex) {
|
4203
4203
|
const nextRow = tb.getChild(rowIndex + 1);
|
4204
|
-
nextRow.getChild(i).props.vMerge = vMergeEndIndex - rowIndex >
|
4204
|
+
nextRow.getChild(i).props.vMerge = vMergeEndIndex - rowIndex > 1 ? 'restart' : null;
|
4205
4205
|
}
|
4206
4206
|
}
|
4207
4207
|
else if (cell.props.vMerge === 'continue') {
|
4208
|
-
// const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
|
4209
|
-
// if (vMergeEndIndex > rowIndex) {
|
4210
|
-
// const nextRow = tb.getChild<TableRowElement>(rowIndex + 1);
|
4211
|
-
// nextRow.getChild<TableCellElement>(i).cellProps.vMerge = 'continue';
|
4212
|
-
// }
|
4213
4208
|
const vMergeStartIndex = this.getVMergeStartIndex(tb, rowIndex, i);
|
4214
4209
|
const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
|
4215
4210
|
//当前单元格处于合并行的最后一行,并且合并的行数为2行
|
@@ -4261,7 +4256,6 @@ class TableUtil {
|
|
4261
4256
|
if (!ss.startControl) {
|
4262
4257
|
return;
|
4263
4258
|
}
|
4264
|
-
ss.clear();
|
4265
4259
|
const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
4266
4260
|
if (!startCell?.parent) {
|
4267
4261
|
throw new Error('parent is null');
|
@@ -4272,6 +4266,7 @@ class TableUtil {
|
|
4272
4266
|
if (tb.length === 0) {
|
4273
4267
|
tb.remove();
|
4274
4268
|
}
|
4269
|
+
ss.clear();
|
4275
4270
|
}
|
4276
4271
|
/**
|
4277
4272
|
* 移除光标所在的当前列
|
@@ -5196,6 +5191,11 @@ class TextGroupFactory extends ElementFactory {
|
|
5196
5191
|
}
|
5197
5192
|
|
5198
5193
|
class ElementSerialize {
|
5194
|
+
/**
|
5195
|
+
* 将当前文档对象构建并输出到标准的JSON对象
|
5196
|
+
* @param element
|
5197
|
+
* @param viewOptions
|
5198
|
+
*/
|
5199
5199
|
static serialize(element, viewOptions) {
|
5200
5200
|
if (element instanceof BranchElement) {
|
5201
5201
|
const result = element.serialize(viewOptions);
|
@@ -7996,7 +7996,7 @@ class DataElementDate extends DataElementInlineGroup {
|
|
7996
7996
|
return res;
|
7997
7997
|
}
|
7998
7998
|
const format = this.props.format ?? 'YYYY-MM-DD';
|
7999
|
-
const date = moment__default["default"](this.getValue(), format);
|
7999
|
+
const date = moment__default["default"](this.getValue(), format, true);
|
8000
8000
|
if (!date.isValid()) {
|
8001
8001
|
return '日期格式不正确';
|
8002
8002
|
}
|
@@ -11193,6 +11193,7 @@ class ParagraphMeasure {
|
|
11193
11193
|
*/
|
11194
11194
|
measureParagraph(p, limitWidth) {
|
11195
11195
|
ElementUtil.fixParagraphContent(p);
|
11196
|
+
this.verifyPara(p, limitWidth);
|
11196
11197
|
p.cacheRender = null;
|
11197
11198
|
const paraModels = [];
|
11198
11199
|
let currRenderLine;
|
@@ -11313,6 +11314,17 @@ class ParagraphMeasure {
|
|
11313
11314
|
}
|
11314
11315
|
return paraRenders;
|
11315
11316
|
}
|
11317
|
+
/**
|
11318
|
+
* 校验当前段落属性
|
11319
|
+
*/
|
11320
|
+
verifyPara(p, limitWidth) {
|
11321
|
+
if (p.props.indent > 0 && p.props.indent + 20 > limitWidth) {
|
11322
|
+
p.props.indent = limitWidth - 20;
|
11323
|
+
}
|
11324
|
+
if (p.props.hanging > 0 && p.props.hanging + 20 > limitWidth) {
|
11325
|
+
p.props.hanging = limitWidth - 20;
|
11326
|
+
}
|
11327
|
+
}
|
11316
11328
|
/**
|
11317
11329
|
* 获取段落行布局横向坐标起始位置,被段落text-align影响
|
11318
11330
|
*/
|
@@ -13699,24 +13711,6 @@ class DocumentEvent {
|
|
13699
13711
|
this.editor.addEventListener('contextmenu', evt => {
|
13700
13712
|
this.contextMenu.next(evt.sourceEvt);
|
13701
13713
|
});
|
13702
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'mousedown').subscribe((evt) => {
|
13703
|
-
// this.mousedown(evt);
|
13704
|
-
// }));
|
13705
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'mouseup').subscribe((evt) => {
|
13706
|
-
// this.mouseup(evt);
|
13707
|
-
// }));
|
13708
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'click').subscribe((evt) => {
|
13709
|
-
// this.mouseClickHandle(evt);
|
13710
|
-
// }));
|
13711
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'contextmenu').subscribe((evt) => {
|
13712
|
-
// this.contextMenu.next(evt);
|
13713
|
-
// }));
|
13714
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'mousemove').subscribe((evt) => {
|
13715
|
-
// this.mousemove(evt);
|
13716
|
-
// }));
|
13717
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'dblclick').subscribe((evt) => {
|
13718
|
-
// this.mouseDblClickHandle(evt);
|
13719
|
-
// }));
|
13720
13714
|
this.documentInput.onLeftEvent.subscribe(() => {
|
13721
13715
|
this.moveCursorToLeft();
|
13722
13716
|
});
|
@@ -14460,17 +14454,27 @@ class DocumentEvent {
|
|
14460
14454
|
const moveDistanceX = this.currentPos.x - mousedownPos.x;
|
14461
14455
|
const moveDistanceY = this.currentPos.y - mousedownPos.y;
|
14462
14456
|
const row = cellElement.parent;
|
14457
|
+
const minColWidth = 20;
|
14463
14458
|
const table = row?.parent;
|
14464
14459
|
if (!row || !table) {
|
14465
14460
|
throw new Error('row | table is null');
|
14466
14461
|
}
|
14467
14462
|
const cellIndex = row.getChildIndex(cellElement);
|
14468
14463
|
let cellWidth = table.getCellWidth(cellIndex);
|
14469
|
-
table.getColsCount();
|
14470
14464
|
if (['left', 'right'].includes(border)) {
|
14471
14465
|
if (cellIndex === 0 && border === 'left') {
|
14472
14466
|
return;
|
14473
14467
|
}
|
14468
|
+
//当前操作的是表格的最后一列
|
14469
|
+
if (cellIndex === table.getColsCount() - 1 && border === 'right') {
|
14470
|
+
cellWidth += moveDistanceX;
|
14471
|
+
if (cellWidth < minColWidth) {
|
14472
|
+
return;
|
14473
|
+
}
|
14474
|
+
table.setCellWidth(cellIndex, cellWidth);
|
14475
|
+
this.edgeRenderInfo.mousedownPos = this.currentPos;
|
14476
|
+
return;
|
14477
|
+
}
|
14474
14478
|
let resizeColWidth = 0;
|
14475
14479
|
let resizeColIndex = 0;
|
14476
14480
|
if (border === 'left') {
|
@@ -14488,14 +14492,13 @@ class DocumentEvent {
|
|
14488
14492
|
}
|
14489
14493
|
cellWidth += moveDistanceX;
|
14490
14494
|
}
|
14491
|
-
if (resizeColWidth <
|
14495
|
+
if (resizeColWidth < minColWidth || cellWidth < minColWidth) {
|
14492
14496
|
return;
|
14493
14497
|
}
|
14494
14498
|
console.log(resizeColWidth, cellWidth);
|
14495
14499
|
table.setCellWidth(resizeColIndex, resizeColWidth);
|
14496
14500
|
table.setCellWidth(cellIndex, cellWidth);
|
14497
14501
|
this.edgeRenderInfo.mousedownPos = this.currentPos;
|
14498
|
-
table.pubOnChange('self');
|
14499
14502
|
}
|
14500
14503
|
else if (['bottom', 'top'].includes(border)) {
|
14501
14504
|
let rowIndex = row.getIndex();
|
@@ -17149,6 +17152,10 @@ var ModifyFlag;
|
|
17149
17152
|
class NodeCore {
|
17150
17153
|
enableClip = true;
|
17151
17154
|
pointEvent = true;
|
17155
|
+
allowHitTest = false;
|
17156
|
+
hitTest(hitPos, currPos) {
|
17157
|
+
return false;
|
17158
|
+
}
|
17152
17159
|
get enable() {
|
17153
17160
|
return this._enable;
|
17154
17161
|
}
|
@@ -17478,6 +17485,9 @@ class NodeItems extends NodeCore {
|
|
17478
17485
|
eventMap = new WeakMap();
|
17479
17486
|
absoluteItems = false;
|
17480
17487
|
containerPropName;
|
17488
|
+
constructor() {
|
17489
|
+
super();
|
17490
|
+
}
|
17481
17491
|
addChild(control, index = -1) {
|
17482
17492
|
if (this.containerPropName) {
|
17483
17493
|
this[this.containerPropName].addChild(control, index);
|
@@ -17549,6 +17559,33 @@ class NodeItems extends NodeCore {
|
|
17549
17559
|
return this.controls.length;
|
17550
17560
|
}
|
17551
17561
|
}
|
17562
|
+
/**
|
17563
|
+
* 子内容采用绝对定位的容器
|
17564
|
+
*/
|
17565
|
+
class AbsolutePanel extends NodeItems {
|
17566
|
+
constructor() {
|
17567
|
+
super();
|
17568
|
+
this.absoluteItems = true;
|
17569
|
+
}
|
17570
|
+
measureOverride(e, availableSize) {
|
17571
|
+
this.controls.forEach(item => {
|
17572
|
+
item.measure(e, availableSize);
|
17573
|
+
});
|
17574
|
+
return super.measureOverride(e, availableSize);
|
17575
|
+
}
|
17576
|
+
arrangeOverride(e, finalSize) {
|
17577
|
+
this.controls.forEach(item => {
|
17578
|
+
const itemRect = {
|
17579
|
+
x: item.x,
|
17580
|
+
y: item.y,
|
17581
|
+
width: item.desiredSize.width,
|
17582
|
+
height: item.desiredSize.height
|
17583
|
+
};
|
17584
|
+
item.arrange(e, itemRect);
|
17585
|
+
});
|
17586
|
+
return super.arrangeOverride(e, finalSize);
|
17587
|
+
}
|
17588
|
+
}
|
17552
17589
|
let currentActiveAppContext = null;
|
17553
17590
|
function getCurrentActiveAppContext() {
|
17554
17591
|
return currentActiveAppContext;
|
@@ -17666,7 +17703,7 @@ function drawBorderline(node, renderCtx) {
|
|
17666
17703
|
if (!node.border) {
|
17667
17704
|
return;
|
17668
17705
|
}
|
17669
|
-
let { x, y,
|
17706
|
+
let { finalRect: { x, y, width, height } } = node;
|
17670
17707
|
const ctx = renderCtx.ctx;
|
17671
17708
|
ctx.save();
|
17672
17709
|
ctx.fillStyle = node.borderColor;
|
@@ -18230,7 +18267,7 @@ class NodeEvent {
|
|
18230
18267
|
};
|
18231
18268
|
mouseleaveRenders.forEach(item => {
|
18232
18269
|
onMouseoutEvent.target = item;
|
18233
|
-
invokeEvent(onMouseoutEvent, '
|
18270
|
+
invokeEvent(onMouseoutEvent, 'mouseout', item, false);
|
18234
18271
|
});
|
18235
18272
|
const onMouseoverEvent = {
|
18236
18273
|
pos: this.appState.pos,
|
@@ -18396,7 +18433,8 @@ class NodeEvent {
|
|
18396
18433
|
width: width,
|
18397
18434
|
height: height
|
18398
18435
|
};
|
18399
|
-
|
18436
|
+
const hitTest = node.allowHitTest ? node.hitTest(hitPos, currRect) : isInsideRectByPosition(currRect, hitPos);
|
18437
|
+
if (hitTest) {
|
18400
18438
|
//有边框和内边距,所以在计算子节点的时候,需要考虑
|
18401
18439
|
const innerPos = {
|
18402
18440
|
x: currRect.x + node.border + node.padding,
|
@@ -18558,6 +18596,13 @@ class ViewPaint {
|
|
18558
18596
|
this.drawHoriLine(x, y, width, textProps.color, 1);
|
18559
18597
|
}
|
18560
18598
|
}
|
18599
|
+
drawText2(text, textProps, x, y) {
|
18600
|
+
this.ctx.save();
|
18601
|
+
this.ctx.fillStyle = textProps.color;
|
18602
|
+
this.ctx.font = `${textProps.fontSize}px ${textProps.fontName}`;
|
18603
|
+
this.ctx.fillText(text, x, y + textProps.fontSize / 7);
|
18604
|
+
this.ctx.restore();
|
18605
|
+
}
|
18561
18606
|
fillCircular(x, y, r, color = 'black') {
|
18562
18607
|
this.ctx.save();
|
18563
18608
|
this.ctx.beginPath();
|
@@ -18572,6 +18617,10 @@ class ViewPaint {
|
|
18572
18617
|
const textMeasure = this.ctx.measureText(text);
|
18573
18618
|
return { width: textMeasure.width, height: textProps.fontSize };
|
18574
18619
|
}
|
18620
|
+
measureText2(text, font) {
|
18621
|
+
this.ctx.font = font.fontSize + 'px ' + font.fontName;
|
18622
|
+
return this.ctx.measureText(text).width;
|
18623
|
+
}
|
18575
18624
|
measureTextUnits(units, textProps) {
|
18576
18625
|
this.ctx.font = textProps.getFont();
|
18577
18626
|
const letterSpace = textProps.letterSpace ?? 0;
|
@@ -18988,6 +19037,11 @@ class SurfaceView extends NodeItems {
|
|
18988
19037
|
* 如果有默认宽度限制,而且支持换行显示,则内容高度等于多行累计高度
|
18989
19038
|
*/
|
18990
19039
|
class LabelNode extends TextBase {
|
19040
|
+
constructor() {
|
19041
|
+
super();
|
19042
|
+
this.border = 1;
|
19043
|
+
this.borderColor = '#000';
|
19044
|
+
}
|
18991
19045
|
_textWrapping = 'no';
|
18992
19046
|
get textWrapping() {
|
18993
19047
|
return this._textWrapping;
|
@@ -18997,34 +19051,54 @@ class LabelNode extends TextBase {
|
|
18997
19051
|
this._textWrapping = value;
|
18998
19052
|
}
|
18999
19053
|
cacheTextRect;
|
19000
|
-
textUnits
|
19054
|
+
//private textUnits!: Array<TextUnits>;
|
19055
|
+
lines = [];
|
19001
19056
|
measureOverride(e, availableSize) {
|
19002
|
-
|
19003
|
-
this.
|
19004
|
-
|
19057
|
+
this.getTextProps();
|
19058
|
+
this.lines = this.getMuiltLines(this.text, e);
|
19059
|
+
// this.textUnits = this.text.split('').map<TextUnits>(char => ({char, actualSize: 0, sourceSize: 0}));
|
19060
|
+
// e.render.measureTextUnits(this.textUnits, textProps);
|
19005
19061
|
//没有宽度限制,测量横向排列的尺寸大小,此时不需要考虑换行
|
19006
|
-
if (Number.isNaN(this._width)) {
|
19007
|
-
|
19008
|
-
|
19009
|
-
|
19010
|
-
|
19011
|
-
|
19012
|
-
|
19013
|
-
|
19014
|
-
|
19015
|
-
}
|
19016
|
-
|
19062
|
+
// if (Number.isNaN(this._width)) {
|
19063
|
+
// // return {
|
19064
|
+
// // width: this.lines[0].textUnits.reduce((prev, curr) => {
|
19065
|
+
// // return prev + curr.sourceSize
|
19066
|
+
// // }, 0), height: this.fontSize
|
19067
|
+
// // };
|
19068
|
+
// return this.measureTextRect(this.lines, {
|
19069
|
+
// width: availableSize.width,
|
19070
|
+
// height: this.getPercentHeight(availableSize.height)
|
19071
|
+
// });
|
19072
|
+
// }
|
19073
|
+
// if (this._textWrapping === 'no') {
|
19074
|
+
// return {width: this.getPercentWidth(availableSize.width), height: this.fontSize};
|
19075
|
+
// }
|
19076
|
+
return this.measureTextRect(this.lines, {
|
19017
19077
|
width: availableSize.width,
|
19018
19078
|
height: this.getPercentHeight(availableSize.height)
|
19019
19079
|
});
|
19020
19080
|
}
|
19021
|
-
|
19022
|
-
|
19023
|
-
|
19024
|
-
|
19025
|
-
|
19026
|
-
|
19081
|
+
getMuiltLines(text, e) {
|
19082
|
+
const lineRects = [];
|
19083
|
+
const lines = this.text.split('\r\n');
|
19084
|
+
for (let i = 0; i < lines.length; i++) {
|
19085
|
+
const units = lines[i].split('').map(char => ({ char, actualSize: 0, sourceSize: 0 }));
|
19086
|
+
e.render.measureTextUnits(units, this.getTextProps());
|
19087
|
+
lineRects.push({ textUnits: units });
|
19027
19088
|
}
|
19089
|
+
return lineRects;
|
19090
|
+
}
|
19091
|
+
arrangeOverride(e, finalSize) {
|
19092
|
+
// if (!Number.isNaN(this._width) && this._textWrapping === 'wrap') {
|
19093
|
+
// this.measureTextRect(this.lines, {
|
19094
|
+
// width: finalSize.width,
|
19095
|
+
// height: finalSize.height
|
19096
|
+
// });
|
19097
|
+
// }
|
19098
|
+
this.measureTextRect(this.lines, {
|
19099
|
+
width: finalSize.width,
|
19100
|
+
height: finalSize.height
|
19101
|
+
});
|
19028
19102
|
return super.arrangeOverride(e, finalSize);
|
19029
19103
|
}
|
19030
19104
|
getTextProps() {
|
@@ -19034,54 +19108,56 @@ class LabelNode extends TextBase {
|
|
19034
19108
|
textProps.color = this.color ?? '#000';
|
19035
19109
|
return textProps;
|
19036
19110
|
}
|
19037
|
-
measureTextRect(
|
19038
|
-
const sumWidth = textUnits.reduce((prev, curr) => {
|
19039
|
-
return curr.sourceSize + prev;
|
19040
|
-
}, 0);
|
19111
|
+
measureTextRect(lines, availableSize, final = false) {
|
19041
19112
|
//总宽度大于可用宽度,换行计算
|
19042
19113
|
const cacheLines = [];
|
19043
19114
|
const { width: limitWidth, height: limitHeight } = availableSize;
|
19044
|
-
let
|
19045
|
-
|
19046
|
-
|
19047
|
-
|
19048
|
-
|
19049
|
-
|
19050
|
-
|
19051
|
-
|
19052
|
-
|
19053
|
-
|
19054
|
-
|
19055
|
-
|
19115
|
+
for (let i = 0; i < lines.length; i++) {
|
19116
|
+
const lineText = lines[i];
|
19117
|
+
let line = { lineUnits: [], x: 0, y: 0, width: 0, height: 0 };
|
19118
|
+
cacheLines.push(line);
|
19119
|
+
for (let j = 0; j < lineText.textUnits.length; j++) {
|
19120
|
+
const unit = lineText.textUnits[j];
|
19121
|
+
//至少每行一个字符
|
19122
|
+
if (line.lineUnits.length > 0 && line.width + unit.sourceSize > limitWidth) {
|
19123
|
+
line = { lineUnits: [], x: 0, y: 0, width: 0, height: 0 };
|
19124
|
+
cacheLines.push(line);
|
19125
|
+
}
|
19126
|
+
line.lineUnits.push(unit);
|
19127
|
+
line.width += unit.sourceSize;
|
19128
|
+
line.height = this.fontSize;
|
19129
|
+
}
|
19056
19130
|
}
|
19057
19131
|
let contentHeight = 0;
|
19132
|
+
let maxLineWidth = 0;
|
19058
19133
|
cacheLines.forEach(line => {
|
19059
19134
|
line.y = contentHeight;
|
19060
19135
|
contentHeight += line.height;
|
19136
|
+
maxLineWidth = Math.max(line.width, maxLineWidth);
|
19061
19137
|
});
|
19062
19138
|
//期望高度
|
19063
19139
|
let desiredHeight = final ? limitHeight : contentHeight;
|
19064
19140
|
this.cacheTextRect = {
|
19065
19141
|
lines: cacheLines,
|
19066
|
-
width:
|
19142
|
+
width: maxLineWidth,
|
19067
19143
|
height: contentHeight,
|
19068
19144
|
desiredHeight,
|
19069
19145
|
desiredWidth: limitWidth
|
19070
19146
|
};
|
19071
19147
|
return {
|
19072
|
-
width:
|
19148
|
+
width: maxLineWidth,
|
19073
19149
|
height: desiredHeight
|
19074
19150
|
};
|
19075
19151
|
}
|
19076
19152
|
render(e) {
|
19077
|
-
const textProp = new TextProps();
|
19078
|
-
textProp.fontName = this.fontName;
|
19079
|
-
textProp.fontSize = this.fontSize;
|
19080
|
-
textProp.color = this.color;
|
19081
|
-
if (this.textWrapping === 'no' || Number.isNaN(this._width)) {
|
19082
|
-
|
19083
|
-
|
19084
|
-
}
|
19153
|
+
// const textProp = new TextProps();
|
19154
|
+
// textProp.fontName = this.fontName;
|
19155
|
+
// textProp.fontSize = this.fontSize;
|
19156
|
+
// textProp.color = this.color;
|
19157
|
+
// if (this.textWrapping === 'no' || Number.isNaN(this._width)) {
|
19158
|
+
// e.render.drawText(this.text, textProp, 0, 0, this.finalRect.width, textProp.fontSize);
|
19159
|
+
// return;
|
19160
|
+
// }
|
19085
19161
|
for (let i = 0; i < this.cacheTextRect.lines.length; i++) {
|
19086
19162
|
const line = this.cacheTextRect.lines[i];
|
19087
19163
|
this.drawLine(e, line);
|
@@ -19097,7 +19173,7 @@ class LabelNode extends TextBase {
|
|
19097
19173
|
render.tran(() => {
|
19098
19174
|
const textProps = this.getTextProps();
|
19099
19175
|
render.ctx.font = textProps.getFont();
|
19100
|
-
render.drawText(line.lineUnits.join(''), textProps, 0, line.y, line.width, line.height);
|
19176
|
+
render.drawText(line.lineUnits.map(item => item.char).join(''), textProps, 0, line.y, line.width, line.height);
|
19101
19177
|
});
|
19102
19178
|
}
|
19103
19179
|
}
|
@@ -19347,8 +19423,8 @@ class ScrollView extends NodeItems {
|
|
19347
19423
|
});
|
19348
19424
|
this.addEventListener('wheel', evt => {
|
19349
19425
|
const { deltaY, deltaX } = evt;
|
19350
|
-
this.horBar.updateScrollByCurrent(deltaX
|
19351
|
-
this.verBar.updateScrollByCurrent(deltaX
|
19426
|
+
this.horBar.updateScrollByCurrent(deltaX, deltaY);
|
19427
|
+
this.verBar.updateScrollByCurrent(deltaX, deltaY);
|
19352
19428
|
});
|
19353
19429
|
}
|
19354
19430
|
scrollTo(x, y) {
|
@@ -20067,7 +20143,7 @@ function pointInPoly(pt, poly) {
|
|
20067
20143
|
* 1.在单页模式下,文档最小宽度为单个文档宽度+合适的外边距
|
20068
20144
|
* 2.在多页模式下,文档最小宽度为单个文档宽度+合适的外边距
|
20069
20145
|
*/
|
20070
|
-
class CanvasTextEditor extends
|
20146
|
+
class CanvasTextEditor extends AbsolutePanel {
|
20071
20147
|
editCanvas;
|
20072
20148
|
editInput;
|
20073
20149
|
contentCtx;
|
@@ -20994,6 +21070,13 @@ class CanvasTextEditor extends NodeItems {
|
|
20994
21070
|
const win = new Window();
|
20995
21071
|
win.width = 1000;
|
20996
21072
|
win.height = 800;
|
21073
|
+
//win.content.addChild(timelineScrollbar)
|
21074
|
+
const rule2 = new RuleControl(this.docCtx);
|
21075
|
+
this.rule = rule2;
|
21076
|
+
rule2.width = 700;
|
21077
|
+
rule2.height = 30;
|
21078
|
+
rule2.x = 20;
|
21079
|
+
rule2.y = 500;
|
20997
21080
|
const surface = new SurfaceView(this.editCanvas, this.editInput);
|
20998
21081
|
this.surfaceView = surface;
|
20999
21082
|
surface.width = 1000;
|
@@ -21005,12 +21088,6 @@ class CanvasTextEditor extends NodeItems {
|
|
21005
21088
|
this.resetViewer();
|
21006
21089
|
});
|
21007
21090
|
surface.addChild(scrollView);
|
21008
|
-
const rule2 = new RuleControl(this.docCtx);
|
21009
|
-
this.rule = rule2;
|
21010
|
-
rule2.width = 700;
|
21011
|
-
rule2.height = 30;
|
21012
|
-
rule2.x = 20;
|
21013
|
-
rule2.y = 500;
|
21014
21091
|
surface.addChild(rule2);
|
21015
21092
|
//surface.addChild(win);
|
21016
21093
|
surface.start();
|
@@ -21085,24 +21162,36 @@ class CanvasTextEditor extends NodeItems {
|
|
21085
21162
|
appCtx.root.setInputPosition(caretPos);
|
21086
21163
|
}
|
21087
21164
|
}
|
21088
|
-
|
21089
|
-
|
21090
|
-
|
21091
|
-
|
21092
|
-
|
21165
|
+
generatorDoc(data) {
|
21166
|
+
//根据传入的参数,动态生成病情信息的结构化报告
|
21167
|
+
const para = new ParagraphElement();
|
21168
|
+
//创建患者姓名文本标签
|
21169
|
+
const patNameLabel = new TextGroupElement();
|
21170
|
+
patNameLabel.text = "患者姓名:";
|
21171
|
+
//添加到段落中
|
21172
|
+
para.addChild(patNameLabel);
|
21173
|
+
//创建患者姓名数据元
|
21174
|
+
const patNameDataEle = new DataElementText();
|
21175
|
+
patNameDataEle.props.valueTextProps = new TextProps();
|
21176
|
+
patNameDataEle.props.valueTextProps.fontName = '宋体';
|
21177
|
+
patNameDataEle.props.valueTextProps.fontSize = 16;
|
21178
|
+
//数据元赋值
|
21179
|
+
patNameDataEle.setValue(data.patName);
|
21180
|
+
//添加到段落中
|
21181
|
+
para.addChild(patNameDataEle);
|
21182
|
+
//添加到正文中
|
21183
|
+
this.docCtx.document.bodyElement.addChild(para);
|
21093
21184
|
}
|
21094
|
-
|
21095
|
-
|
21096
|
-
|
21097
|
-
|
21098
|
-
|
21099
|
-
width: item.desiredSize.width,
|
21100
|
-
height: item.desiredSize.height
|
21101
|
-
};
|
21102
|
-
item.arrange(e, itemRect);
|
21103
|
-
});
|
21104
|
-
return super.arrangeOverride(e, finalSize);
|
21185
|
+
/**
|
21186
|
+
* 设置关键字
|
21187
|
+
* 匹配用户输入的关键字,回调到应用业务中处理
|
21188
|
+
*/
|
21189
|
+
setKeywords(keys, cb) {
|
21105
21190
|
}
|
21191
|
+
/**
|
21192
|
+
* 注册编辑器格式读取器
|
21193
|
+
*/
|
21194
|
+
registerReaderFactory(handler) { }
|
21106
21195
|
}
|
21107
21196
|
|
21108
21197
|
/**
|