@hailin-zheng/editor-core 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index-cjs.js CHANGED
@@ -394,6 +394,7 @@ class BlockContentRenderObject extends BranchRenderObject {
394
394
  }
395
395
  }
396
396
  class InlineGroupRenderObject extends BranchRenderObject {
397
+ paintPos;
397
398
  }
398
399
  /**
399
400
  * 包含块级渲染元素的容器元素,例如body、table-cell等
@@ -935,8 +936,10 @@ class Subject$1 extends EventSourceCore$1 {
935
936
  this.addSub(sub);
936
937
  return sub;
937
938
  }
938
- onceSubscribe(listener) {
939
- const sub = this.subscribe(listener);
939
+ }
940
+ class OnceSubject extends Subject$1 {
941
+ subscribe(listener) {
942
+ const sub = super.subscribe(listener);
940
943
  sub.once = true;
941
944
  return sub;
942
945
  }
@@ -1323,13 +1326,23 @@ class BranchElement extends Element {
1323
1326
  }
1324
1327
  else {
1325
1328
  this.modifyFlag = exports.ModifyFlag.Modify;
1326
- for (let i = 0; i < this.length; i++) {
1327
- this.getChild(i).pubOnChange('to-child');
1328
- }
1329
+ clearChildrenRenderCache(this);
1330
+ // for (let i = 0; i < this.length; i++) {
1331
+ // this.getChild(i).pubOnChange('to-child')
1332
+ // }
1329
1333
  }
1330
1334
  this._onChangeEvent.next();
1331
1335
  }
1332
1336
  }
1337
+ function clearChildrenRenderCache(ele) {
1338
+ for (let i = 0; i < ele.length; i++) {
1339
+ const curr = ele.getChild(i);
1340
+ curr.cacheRender = null;
1341
+ if (curr instanceof BranchElement) {
1342
+ clearChildrenRenderCache(curr);
1343
+ }
1344
+ }
1345
+ }
1333
1346
  /**
1334
1347
  * 行内编组元素
1335
1348
  */
@@ -1443,6 +1456,8 @@ class ViewOptions {
1443
1456
  defaultColor = "rgb(0,0,0)";
1444
1457
  selectionOverlaysColor = 'rgb(131,175,155,0.5)';
1445
1458
  dataEleOverlaysColor = 'rgb(131,175,155,0.5)';
1459
+ dataEleFocusedBgColor = 'rgb(131,175,155,0.8)';
1460
+ dataEleErrorBgColor = '#ff4d4f';
1446
1461
  dataEleReadOnlyOverlayColor = '#d9d9d9';
1447
1462
  dataEleOutlineColor = 'rgb(131,175,155,0.7)';
1448
1463
  viewBackcolor = 'rgb(230,230,230)';
@@ -1474,6 +1489,8 @@ class ViewOptions {
1474
1489
  enableDyExpression = false;
1475
1490
  //是否显示标尺
1476
1491
  showRule = true;
1492
+ //是否开启数据元输入验证功能
1493
+ enableDataEleInputValidate = false;
1477
1494
  //整页模式,不分页
1478
1495
  _fullPageView = false;
1479
1496
  get fullPageView() {
@@ -3563,6 +3580,173 @@ function getCalleeName(node) {
3563
3580
  return node['name'];
3564
3581
  }
3565
3582
 
3583
+ class ParagraphElement extends BlockContentElement {
3584
+ constructor() {
3585
+ super('p');
3586
+ this.props = new ParagraphProps();
3587
+ this.addEvent('BackspaceKey', (evt) => {
3588
+ if (evt.selectionState.collapsed) {
3589
+ const pFirstLeafElement = ElementUtil.getFirstLeafElement(this);
3590
+ if (pFirstLeafElement === evt.source && evt.sourceOffset === 0) {
3591
+ if (this.props.numberType >= 0) {
3592
+ this.props.numberType = -1;
3593
+ evt.isCancel = true;
3594
+ }
3595
+ else if (this.props.indent) {
3596
+ this.props.indent = 0;
3597
+ evt.isCancel = true;
3598
+ }
3599
+ }
3600
+ }
3601
+ }, true);
3602
+ this.addEvent('ElementKeyDown', evt => {
3603
+ //当前存在缩进,点击tab
3604
+ if (evt.sourceEvent.keyCode === 9) {
3605
+ const { startControl, startOffset } = evt.selectionState;
3606
+ if (startOffset === 0 && startControl === this.getChild(0)) {
3607
+ const defaultIndent = evt.ctx.viewOptions.defaultIndent;
3608
+ let increaseValue = evt.sourceEvent.shiftKey ? -defaultIndent : defaultIndent;
3609
+ this.props.indent += increaseValue;
3610
+ evt.isCancel = true;
3611
+ evt.sourceEvent.preventDefault();
3612
+ }
3613
+ }
3614
+ }, true);
3615
+ }
3616
+ /**
3617
+ * 设置样式
3618
+ * @param format
3619
+ */
3620
+ setFormat(format) {
3621
+ formatEle(this, format);
3622
+ Object.keys(format).forEach(key => {
3623
+ this.props[key] = format[key];
3624
+ });
3625
+ }
3626
+ createRenderObject() {
3627
+ return new ParagraphRenderObject(this);
3628
+ }
3629
+ createLineRect() {
3630
+ return new ParagraphLineRectRenderObject(null);
3631
+ }
3632
+ serialize(viewOptions) {
3633
+ return {
3634
+ type: 'p',
3635
+ props: {
3636
+ ...this.props.getSerializeProps(viewOptions)
3637
+ }
3638
+ };
3639
+ }
3640
+ clone(data) {
3641
+ const clone = new ParagraphElement();
3642
+ this.props.clone(clone.props);
3643
+ if (data) {
3644
+ for (let i = 0; i < this.length; i++) {
3645
+ clone.addChild(this.getChild(i).clone(true));
3646
+ }
3647
+ }
3648
+ return clone;
3649
+ }
3650
+ static createElement() {
3651
+ return new ParagraphElement();
3652
+ }
3653
+ }
3654
+ class ParagraphRenderObject extends MuiltBlockLineRenderObject {
3655
+ render(e) {
3656
+ e.nextRender();
3657
+ this.drawProjectNumber(e.render, e.docCtx.viewOptions, e);
3658
+ }
3659
+ /**
3660
+ * 绘制项目符号
3661
+ */
3662
+ drawProjectNumber(ctx, viewOptions, e) {
3663
+ const paraElement = this.element;
3664
+ if (paraElement.props.numberType !== exports.ParagraphNumberType.none) {
3665
+ if (paraElement.paintRenders.indexOf(this) > 0) {
3666
+ return;
3667
+ }
3668
+ const line = this.getChild(0);
3669
+ // const firstInlinePaintPos = ElementUtil.getRenderAbsolutePaintPos(firstInline, {
3670
+ // x: 0,
3671
+ // y: -viewOptions.translateY
3672
+ // });
3673
+ const firstInlinePaintPos = {
3674
+ x: e.position.x + line.rect.x,
3675
+ y: e.position.y + line.rect.y
3676
+ };
3677
+ if (paraElement.props.numberType === exports.ParagraphNumberType.ul) {
3678
+ const numberSymbolY = firstInlinePaintPos.y + line.baseTopLine + Math.floor((line.baseBottomLine - line.baseTopLine) / 2);
3679
+ ctx.contentContext.fillCircular(firstInlinePaintPos.x + 4 + paraElement.props.indent, numberSymbolY, 4);
3680
+ }
3681
+ else if (paraElement.props.numberType === exports.ParagraphNumberType.ol) {
3682
+ const parent = paraElement.parent;
3683
+ let i = paraElement.getIndex() - 1;
3684
+ for (; i >= 0; i--) {
3685
+ if (parent.getChild(i) instanceof ParagraphElement) {
3686
+ //紧挨上面的段落
3687
+ const prevSiblingPara = parent.getChild(i);
3688
+ if (prevSiblingPara.props.numberType !== paraElement.props.numberType || prevSiblingPara.props.indent !== paraElement.props.indent) {
3689
+ break;
3690
+ }
3691
+ }
3692
+ }
3693
+ const olText = (paraElement.getIndex() - i) + '.';
3694
+ const textProps = new TextProps();
3695
+ textProps.color = '#000';
3696
+ textProps.fontSize = line.baseBottomLine - line.baseTopLine;
3697
+ textProps.fontName = '宋体';
3698
+ ctx.contentContext.drawText(olText, textProps, firstInlinePaintPos.x, firstInlinePaintPos.y + line.baseTopLine, 40, textProps.fontSize);
3699
+ }
3700
+ }
3701
+ }
3702
+ clone() {
3703
+ const cloneRender = new ParagraphRenderObject(this.element);
3704
+ cloneRender.rect = ElementUtil.cloneRect(this.rect);
3705
+ for (let i = 0; i < this.length; i++) {
3706
+ cloneRender.addChild(this.getChild(i).clone());
3707
+ }
3708
+ return cloneRender;
3709
+ }
3710
+ }
3711
+ class ParagraphFactory extends ElementFactory {
3712
+ match(type) {
3713
+ return type === 'p';
3714
+ }
3715
+ createElement(data) {
3716
+ const paraElement = new ParagraphElement();
3717
+ const props = data.props;
3718
+ paraElement.props.indent = props?.indent ?? 0;
3719
+ paraElement.props.hanging = props?.hanging ?? 0;
3720
+ paraElement.props.textAlign = props?.textAlign ?? 'left';
3721
+ paraElement.props.numberType = props?.numberType ?? -1;
3722
+ paraElement.props.lineHeight = props?.lineHeight ?? this.options.defaultLineHeight;
3723
+ paraElement.props.marginTop = props?.marginTop ?? 0;
3724
+ paraElement.props.marginBottom = props?.marginBottom ?? 0;
3725
+ paraElement.props.tabs = props?.tabs ?? [];
3726
+ return paraElement;
3727
+ }
3728
+ }
3729
+ /**
3730
+ * 段落行框
3731
+ */
3732
+ class ParagraphLineRectRenderObject extends BlockLineRectRenderObject {
3733
+ baseTopLine = 0;
3734
+ baseBottomLine = 0;
3735
+ startX = 0;
3736
+ render(e) {
3737
+ }
3738
+ clone() {
3739
+ const cloneRender = new ParagraphLineRectRenderObject(this.element);
3740
+ cloneRender.rect = ElementUtil.cloneRect(this.rect);
3741
+ cloneRender.baseTopLine = this.baseTopLine;
3742
+ cloneRender.baseBottomLine = this.baseBottomLine;
3743
+ for (let i = 0; i < this.length; i++) {
3744
+ cloneRender.addChild(this.getChild(i).clone());
3745
+ }
3746
+ return cloneRender;
3747
+ }
3748
+ }
3749
+
3566
3750
  /**
3567
3751
  * 所有的数据元继承上述两个抽象类
3568
3752
  */
@@ -3678,8 +3862,12 @@ class InlineGroupInputElement extends InlineGroupElement {
3678
3862
  }
3679
3863
  }
3680
3864
  class DataElementInlineGroup extends InlineGroupInputElement {
3865
+ errorTip;
3681
3866
  constructor(type) {
3682
3867
  super(type);
3868
+ this.onChangeSubject.subscribe(() => {
3869
+ this.onChangedValidate();
3870
+ });
3683
3871
  this.addEvent('ElementMousemove', (evt) => {
3684
3872
  this.isMouseenter = true;
3685
3873
  this.refreshView();
@@ -3743,19 +3931,44 @@ class DataElementInlineGroup extends InlineGroupInputElement {
3743
3931
  this.expressFn = new Function();
3744
3932
  }
3745
3933
  }
3934
+ /**
3935
+ * 数据元发生更改后,进行数据验证
3936
+ */
3937
+ onChangedValidate() {
3938
+ this.errorTip = '';
3939
+ const options = getCurrOptions(this);
3940
+ if (!options || !options.enableDataEleInputValidate) {
3941
+ return;
3942
+ }
3943
+ this.errorTip = this.validate();
3944
+ }
3945
+ }
3946
+ function getCurrOptions(ele) {
3947
+ const doc = ElementUtil.getParent(ele, item => item.type === 'doc');
3948
+ return doc?.viewOptions;
3746
3949
  }
3747
3950
  class DataElementRenderObject extends InlineGroupRenderObject {
3748
3951
  render(e) {
3749
3952
  const { render, position, docCtx: { viewOptions } } = e;
3953
+ this.paintPos = e.position;
3750
3954
  //数据元不打印
3751
3955
  if (!this.element.props.printable && render.drawMode === 'print') {
3752
3956
  return;
3753
3957
  }
3754
3958
  render.contentContext.tran(() => {
3755
3959
  //绘制数据元区域底色
3960
+ let bgColor = '';
3756
3961
  if (this.element.isMouseenter) {
3757
- const overlayColor = this.element.props.editable ? viewOptions.dataEleOverlaysColor : viewOptions.dataEleReadOnlyOverlayColor;
3758
- render.overlaysContext.fillRect(position.x, position.y - 2, this.rect.width, this.rect.height + 4, overlayColor);
3962
+ bgColor = this.element.props.editable ? viewOptions.dataEleOverlaysColor : viewOptions.dataEleReadOnlyOverlayColor;
3963
+ }
3964
+ if (this.element.isFocused) {
3965
+ bgColor = e.docCtx.viewOptions.dataEleFocusedBgColor;
3966
+ }
3967
+ if (this.element.errorTip) {
3968
+ bgColor = viewOptions.dataEleErrorBgColor;
3969
+ }
3970
+ if (bgColor) {
3971
+ render.overlaysContext.fillRect(position.x, position.y - 2, this.rect.width, this.rect.height + 4, bgColor);
3759
3972
  }
3760
3973
  if (this.element.props.secretBrowse && viewOptions.secretBrowse) {
3761
3974
  render.contentContext.ctx.filter = "blur(10px)";
@@ -3770,6 +3983,9 @@ class DataElementRenderObject extends InlineGroupRenderObject {
3770
3983
  e.nextRender();
3771
3984
  this.drawCaption(e);
3772
3985
  });
3986
+ e.render.onRenderCompleted.subscribe(() => {
3987
+ drawDecorator(e, this);
3988
+ });
3773
3989
  }
3774
3990
  /**
3775
3991
  * 绘制数据元标题
@@ -3777,23 +3993,25 @@ class DataElementRenderObject extends InlineGroupRenderObject {
3777
3993
  * @private
3778
3994
  */
3779
3995
  drawCaption(e) {
3780
- const { render, position, docCtx: { viewOptions } } = e;
3781
- //获取到焦点时,绘制数据元标题
3782
- if (render.drawMode === 'view' && this.element.isFocused && this.element.paintRenders.indexOf(this) === 0) {
3783
- const { caption } = this.element.props;
3784
- if (!caption) {
3785
- return;
3996
+ e.render.onRenderCompleted.subscribe(() => {
3997
+ const { render, position, docCtx: { viewOptions } } = e;
3998
+ //获取到焦点时,绘制数据元标题
3999
+ if (render.drawMode === 'view' && this.element.isFocused && this.element.paintRenders.indexOf(this) === 0) {
4000
+ const { caption } = this.element.props;
4001
+ if (!caption) {
4002
+ return;
4003
+ }
4004
+ const textProps = new TextProps();
4005
+ textProps.fontSize = 16;
4006
+ textProps.fontName = viewOptions.defaultFontName;
4007
+ textProps.color = '#fff';
4008
+ const titleWidth = render.contentContext.measureText(caption, textProps).width;
4009
+ const x = position.x;
4010
+ const y = position.y - 20;
4011
+ render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
4012
+ render.contentContext.drawText(caption, textProps, x + 5, y, titleWidth, 20);
3786
4013
  }
3787
- const textProps = new TextProps();
3788
- textProps.fontSize = 16;
3789
- textProps.fontName = viewOptions.defaultFontName;
3790
- textProps.color = '#fff';
3791
- const titleWidth = render.contentContext.measureText(caption, textProps).width;
3792
- const x = position.x;
3793
- const y = position.y - 20;
3794
- render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
3795
- render.contentContext.drawText(caption, textProps, x + 5, y, titleWidth, 20);
3796
- }
4014
+ });
3797
4015
  }
3798
4016
  }
3799
4017
  const validateDataEle = (ele) => {
@@ -3848,6 +4066,57 @@ class DataElementBaseFactory extends ElementFactory {
3848
4066
  }
3849
4067
  }
3850
4068
  }
4069
+ function drawDecorator(e, r) {
4070
+ const { render, docCtx: { viewOptions } } = e;
4071
+ const canPaint = r.element.isMouseenter || r.element.isFocused;
4072
+ if (canPaint && r.element.paintRenders.indexOf(r) === 0) {
4073
+ const currParaRenders = getCurrentParaGroupRenders(r);
4074
+ const verOffset = 3;
4075
+ if (currParaRenders.length > 1) {
4076
+ const secondGroupRenderPos = currParaRenders[1].paintPos;
4077
+ if (secondGroupRenderPos.x + currParaRenders[1].rect.width > r.paintPos.x) {
4078
+ const leftPoints = [];
4079
+ const rightPoints = [];
4080
+ for (let i = 0; i < currParaRenders.length; i++) {
4081
+ const groupRender = currParaRenders[i];
4082
+ const groupRenderPos = groupRender.paintPos;
4083
+ leftPoints.push({ x: groupRenderPos.x, y: groupRenderPos.y - verOffset });
4084
+ rightPoints.push({
4085
+ x: groupRenderPos.x + groupRender.rect.width,
4086
+ y: groupRenderPos.y - verOffset
4087
+ });
4088
+ leftPoints.push({
4089
+ x: groupRenderPos.x,
4090
+ y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
4091
+ });
4092
+ rightPoints.push({
4093
+ x: groupRenderPos.x + groupRender.rect.width,
4094
+ y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
4095
+ });
4096
+ }
4097
+ const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
4098
+ const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
4099
+ render.overlaysContext.strokeLines([...sharpPoints, ...sharpPoints1, sharpPoints[0]], 1, viewOptions.dataGroupColor);
4100
+ return;
4101
+ }
4102
+ }
4103
+ for (let i = 0; i < currParaRenders.length; i++) {
4104
+ const currRen = currParaRenders[i];
4105
+ render.overlaysContext.strokeRect(currRen.paintPos.x, currRen.paintPos.y - verOffset, currRen.rect.width, currRen.rect.height + verOffset * 2, viewOptions.dataGroupColor);
4106
+ }
4107
+ }
4108
+ }
4109
+ function getCurrentParaGroupRenders(r) {
4110
+ const renders = [];
4111
+ const currParaRender = ElementUtil.getParentRender(r, ParagraphRenderObject);
4112
+ for (let i = 0; i < r.element.paintRenders.length; i++) {
4113
+ const paraRender = ElementUtil.getParentRender(r.element.paintRenders[i], ParagraphRenderObject);
4114
+ if (paraRender === currParaRender) {
4115
+ renders.push(r.element.paintRenders[i]);
4116
+ }
4117
+ }
4118
+ return renders;
4119
+ }
3851
4120
 
3852
4121
  class DocumentElement extends BlockContainerElement {
3853
4122
  //props: DocumentProps;
@@ -4309,173 +4578,6 @@ class DocumentHeaderFactory extends ElementFactory {
4309
4578
  }
4310
4579
  }
4311
4580
 
4312
- class ParagraphElement extends BlockContentElement {
4313
- constructor() {
4314
- super('p');
4315
- this.props = new ParagraphProps();
4316
- this.addEvent('BackspaceKey', (evt) => {
4317
- if (evt.selectionState.collapsed) {
4318
- const pFirstLeafElement = ElementUtil.getFirstLeafElement(this);
4319
- if (pFirstLeafElement === evt.source && evt.sourceOffset === 0) {
4320
- if (this.props.numberType >= 0) {
4321
- this.props.numberType = -1;
4322
- evt.isCancel = true;
4323
- }
4324
- else if (this.props.indent) {
4325
- this.props.indent = 0;
4326
- evt.isCancel = true;
4327
- }
4328
- }
4329
- }
4330
- }, true);
4331
- this.addEvent('ElementKeyDown', evt => {
4332
- //当前存在缩进,点击tab
4333
- if (evt.sourceEvent.keyCode === 9) {
4334
- const { startControl, startOffset } = evt.selectionState;
4335
- if (startOffset === 0 && startControl === this.getChild(0)) {
4336
- const defaultIndent = evt.ctx.viewOptions.defaultIndent;
4337
- let increaseValue = evt.sourceEvent.shiftKey ? -defaultIndent : defaultIndent;
4338
- this.props.indent += increaseValue;
4339
- evt.isCancel = true;
4340
- evt.sourceEvent.preventDefault();
4341
- }
4342
- }
4343
- }, true);
4344
- }
4345
- /**
4346
- * 设置样式
4347
- * @param format
4348
- */
4349
- setFormat(format) {
4350
- formatEle(this, format);
4351
- Object.keys(format).forEach(key => {
4352
- this.props[key] = format[key];
4353
- });
4354
- }
4355
- createRenderObject() {
4356
- return new ParagraphRenderObject(this);
4357
- }
4358
- createLineRect() {
4359
- return new ParagraphLineRectRenderObject(null);
4360
- }
4361
- serialize(viewOptions) {
4362
- return {
4363
- type: 'p',
4364
- props: {
4365
- ...this.props.getSerializeProps(viewOptions)
4366
- }
4367
- };
4368
- }
4369
- clone(data) {
4370
- const clone = new ParagraphElement();
4371
- this.props.clone(clone.props);
4372
- if (data) {
4373
- for (let i = 0; i < this.length; i++) {
4374
- clone.addChild(this.getChild(i).clone(true));
4375
- }
4376
- }
4377
- return clone;
4378
- }
4379
- static createElement() {
4380
- return new ParagraphElement();
4381
- }
4382
- }
4383
- class ParagraphRenderObject extends MuiltBlockLineRenderObject {
4384
- render(e) {
4385
- e.nextRender();
4386
- this.drawProjectNumber(e.render, e.docCtx.viewOptions, e);
4387
- }
4388
- /**
4389
- * 绘制项目符号
4390
- */
4391
- drawProjectNumber(ctx, viewOptions, e) {
4392
- const paraElement = this.element;
4393
- if (paraElement.props.numberType !== exports.ParagraphNumberType.none) {
4394
- if (paraElement.paintRenders.indexOf(this) > 0) {
4395
- return;
4396
- }
4397
- const line = this.getChild(0);
4398
- // const firstInlinePaintPos = ElementUtil.getRenderAbsolutePaintPos(firstInline, {
4399
- // x: 0,
4400
- // y: -viewOptions.translateY
4401
- // });
4402
- const firstInlinePaintPos = {
4403
- x: e.position.x + line.rect.x,
4404
- y: e.position.y + line.rect.y
4405
- };
4406
- if (paraElement.props.numberType === exports.ParagraphNumberType.ul) {
4407
- const numberSymbolY = firstInlinePaintPos.y + line.baseTopLine + Math.floor((line.baseBottomLine - line.baseTopLine) / 2);
4408
- ctx.contentContext.fillCircular(firstInlinePaintPos.x + 4 + paraElement.props.indent, numberSymbolY, 4);
4409
- }
4410
- else if (paraElement.props.numberType === exports.ParagraphNumberType.ol) {
4411
- const parent = paraElement.parent;
4412
- let i = paraElement.getIndex() - 1;
4413
- for (; i >= 0; i--) {
4414
- if (parent.getChild(i) instanceof ParagraphElement) {
4415
- //紧挨上面的段落
4416
- const prevSiblingPara = parent.getChild(i);
4417
- if (prevSiblingPara.props.numberType !== paraElement.props.numberType || prevSiblingPara.props.indent !== paraElement.props.indent) {
4418
- break;
4419
- }
4420
- }
4421
- }
4422
- const olText = (paraElement.getIndex() - i) + '.';
4423
- const textProps = new TextProps();
4424
- textProps.color = '#000';
4425
- textProps.fontSize = line.baseBottomLine - line.baseTopLine;
4426
- textProps.fontName = '宋体';
4427
- ctx.contentContext.drawText(olText, textProps, firstInlinePaintPos.x, firstInlinePaintPos.y + line.baseTopLine, 40, textProps.fontSize);
4428
- }
4429
- }
4430
- }
4431
- clone() {
4432
- const cloneRender = new ParagraphRenderObject(this.element);
4433
- cloneRender.rect = ElementUtil.cloneRect(this.rect);
4434
- for (let i = 0; i < this.length; i++) {
4435
- cloneRender.addChild(this.getChild(i).clone());
4436
- }
4437
- return cloneRender;
4438
- }
4439
- }
4440
- class ParagraphFactory extends ElementFactory {
4441
- match(type) {
4442
- return type === 'p';
4443
- }
4444
- createElement(data) {
4445
- const paraElement = new ParagraphElement();
4446
- const props = data.props;
4447
- paraElement.props.indent = props?.indent ?? 0;
4448
- paraElement.props.hanging = props?.hanging ?? 0;
4449
- paraElement.props.textAlign = props?.textAlign ?? 'left';
4450
- paraElement.props.numberType = props?.numberType ?? -1;
4451
- paraElement.props.lineHeight = props?.lineHeight ?? this.options.defaultLineHeight;
4452
- paraElement.props.marginTop = props?.marginTop ?? 0;
4453
- paraElement.props.marginBottom = props?.marginBottom ?? 0;
4454
- paraElement.props.tabs = props?.tabs ?? [];
4455
- return paraElement;
4456
- }
4457
- }
4458
- /**
4459
- * 段落行框
4460
- */
4461
- class ParagraphLineRectRenderObject extends BlockLineRectRenderObject {
4462
- baseTopLine = 0;
4463
- baseBottomLine = 0;
4464
- startX = 0;
4465
- render(e) {
4466
- }
4467
- clone() {
4468
- const cloneRender = new ParagraphLineRectRenderObject(this.element);
4469
- cloneRender.rect = ElementUtil.cloneRect(this.rect);
4470
- cloneRender.baseTopLine = this.baseTopLine;
4471
- cloneRender.baseBottomLine = this.baseBottomLine;
4472
- for (let i = 0; i < this.length; i++) {
4473
- cloneRender.addChild(this.getChild(i).clone());
4474
- }
4475
- return cloneRender;
4476
- }
4477
- }
4478
-
4479
4581
  class PSymbolElement extends LeafElement {
4480
4582
  textProps;
4481
4583
  defaultHeight = 14;
@@ -4578,6 +4680,9 @@ class TableCellElement extends BlockContainerElement {
4578
4680
  throw new Error('row is null');
4579
4681
  }
4580
4682
  const table = row.parent;
4683
+ if (!table) {
4684
+ debugger;
4685
+ }
4581
4686
  const cellIndex = row.getChildIndex(this);
4582
4687
  let cellWidth = table.getCellWidth(cellIndex);
4583
4688
  const cellOffset = table.getCellOffsetX(cellIndex);
@@ -5638,8 +5743,8 @@ class TableFactory extends ElementFactory {
5638
5743
  /**
5639
5744
  * 行-表格渲染模式
5640
5745
  */
5641
- function textLineRenderMode(ele, data) {
5642
- const tb = ele.cacheRender;
5746
+ function textLineRenderMode(tbRender, data) {
5747
+ const tb = tbRender;
5643
5748
  const rows = [];
5644
5749
  for (let i = 0; i < tb.length; i++) {
5645
5750
  const row = tb.getChild(i);
@@ -7623,8 +7728,7 @@ class RenderContext {
7623
7728
  drawMode = 'view';
7624
7729
  contentOffCanvas;
7625
7730
  overlayOffCanvas;
7626
- //pageRect!: Omit<Rect, any>;
7627
- onRenderCompleted = new Subject$1();
7731
+ onRenderCompleted = new OnceSubject();
7628
7732
  constructor(mainContext) {
7629
7733
  this.mainContext = mainContext;
7630
7734
  }
@@ -7646,7 +7750,6 @@ class RenderContext {
7646
7750
  this.pageRect = { x: 0, y: 0, width: pageSetting.width, height: pageSetting.height };
7647
7751
  ElementUtil.setCanvasProps(this.contentOffCanvas, this.contentContext.ctx, pageSetting);
7648
7752
  ElementUtil.setCanvasProps(this.overlayOffCanvas, this.overlaysContext.ctx, pageSetting);
7649
- //ElementUtil.setCanvasProps(this.mainContext.ctx.canvas, this.mainContext.ctx, pageSetting)
7650
7753
  }
7651
7754
  clear() {
7652
7755
  this.contentContext.clear();
@@ -8685,7 +8788,7 @@ class DataElementDate extends DataElementInlineGroup {
8685
8788
  this.props.valueTextProps.clone(valueText.props);
8686
8789
  valueText.text = formatStr;
8687
8790
  this.addChild(valueText, this.length - 1);
8688
- //this.beginMeasure();
8791
+ this.onChangedValidate();
8689
8792
  }
8690
8793
  getValue() {
8691
8794
  return ElementSerialize.serializeString(this);
@@ -8775,62 +8878,11 @@ class DataElementGroupElement extends InlineGroupInputElement {
8775
8878
  }
8776
8879
  }
8777
8880
  class DataElementGroupRenderObject extends InlineGroupRenderObject {
8778
- paintPos;
8779
8881
  render(e) {
8780
8882
  this.paintPos = e.position;
8781
- }
8782
- getCurrentParaGroupRenders() {
8783
- const renders = [];
8784
- const currParaRender = ElementUtil.getParentRender(this, ParagraphRenderObject);
8785
- for (let i = 0; i < this.element.paintRenders.length; i++) {
8786
- const paraRender = ElementUtil.getParentRender(this.element.paintRenders[i], ParagraphRenderObject);
8787
- if (paraRender === currParaRender) {
8788
- renders.push(this.element.paintRenders[i]);
8789
- }
8790
- }
8791
- return renders;
8792
- }
8793
- pagePaintCompleted(e) {
8794
- const { render, docCtx: { viewOptions } } = e;
8795
- const canPaint = this.element.isMouseenter || this.element.isFocused;
8796
- if (canPaint && this.element.paintRenders.indexOf(this) === 0) {
8797
- const currParaRenders = this.getCurrentParaGroupRenders();
8798
- const verOffset = 3;
8799
- if (currParaRenders.length > 1) {
8800
- const secondGroupRenderPos = currParaRenders[1].paintPos;
8801
- if (secondGroupRenderPos.x + currParaRenders[1].rect.width > this.paintPos.x) {
8802
- const leftPoints = [];
8803
- const rightPoints = [];
8804
- for (let i = 0; i < currParaRenders.length; i++) {
8805
- const groupRender = currParaRenders[i];
8806
- const groupRenderPos = groupRender.paintPos;
8807
- leftPoints.push({ x: groupRenderPos.x, y: groupRenderPos.y - verOffset });
8808
- rightPoints.push({
8809
- x: groupRenderPos.x + groupRender.rect.width,
8810
- y: groupRenderPos.y - verOffset
8811
- });
8812
- leftPoints.push({
8813
- x: groupRenderPos.x,
8814
- y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
8815
- });
8816
- rightPoints.push({
8817
- x: groupRenderPos.x + groupRender.rect.width,
8818
- y: groupRenderPos.y + groupRender.rect.height + verOffset * 2
8819
- });
8820
- }
8821
- const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
8822
- const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
8823
- render.overlaysContext.strokeLines([...sharpPoints, ...sharpPoints1, sharpPoints[0]], 1, viewOptions.dataGroupColor);
8824
- return;
8825
- }
8826
- }
8827
- for (let i = 0; i < currParaRenders.length; i++) {
8828
- const currRen = currParaRenders[i];
8829
- render.overlaysContext.strokeRect(currRen.paintPos.x, currRen.paintPos.y - verOffset, currRen.rect.width, currRen.rect.height + verOffset * 2, viewOptions.dataGroupColor);
8830
- }
8831
- }
8832
- }
8833
- endRender(ctx, position) {
8883
+ e.render.onRenderCompleted.subscribe(() => {
8884
+ drawDecorator(e, this);
8885
+ });
8834
8886
  }
8835
8887
  clone() {
8836
8888
  const cloneRender = new DataElementGroupRenderObject(this.element);
@@ -9051,6 +9103,7 @@ class DataElementList extends DataElementInlineGroup {
9051
9103
  this.addChild(valueText, this.length - 1);
9052
9104
  }
9053
9105
  }
9106
+ this.onChangedValidate();
9054
9107
  }
9055
9108
  getValue() {
9056
9109
  const values = ElementSerialize.serializeString(this);
@@ -9144,6 +9197,7 @@ class DataElementText extends DataElementInlineGroup {
9144
9197
  valueText.text = val + '';
9145
9198
  this.addChild(valueText, this.length - 1);
9146
9199
  }
9200
+ this.onChangedValidate();
9147
9201
  }
9148
9202
  getValue() {
9149
9203
  return ElementSerialize.serializeString(this, { all: false });
@@ -10980,8 +11034,6 @@ class ElementPaint {
10980
11034
  }
10981
11035
  paintPagePos;
10982
11036
  drawPages(docContainer, selectedSets) {
10983
- // this.rePaint = rePaint;
10984
- //this.measureCommContainer = measureCommContainer;
10985
11037
  this.selectedSets = selectedSets;
10986
11038
  const pageCount = docContainer.length;
10987
11039
  const containerPos = { x: docContainer.rect.x - this.viewOptions.pageOffset.x, y: docContainer.rect.y - this.viewOptions.pageOffset.y };
@@ -11007,13 +11059,13 @@ class ElementPaint {
11007
11059
  });
11008
11060
  nextRenderFn();
11009
11061
  const { scale, viewSettings: { width, height } } = this.viewOptions;
11062
+ while (this.renderCtx.onRenderCompleted.subs.length > 0) {
11063
+ this.renderCtx.onRenderCompleted.next();
11064
+ }
11010
11065
  this.renderCtx.commit({ width, height, scale }, this.viewOptions.pageOffset);
11011
11066
  }
11012
11067
  drawRenderObject(renderObject, parent, parentInViewPort = false) {
11013
11068
  const element = renderObject.element;
11014
- // if (this.rePaint && element) {
11015
- // //element.paintRenders.push(renderObject);
11016
- // }
11017
11069
  const { x: rx, y: ry, width: rw, height: rh } = renderObject.rect;
11018
11070
  const currPosition = { x: rx + parent.x, y: ry + parent.y };
11019
11071
  //判断当前绘制元素是否在视窗内
@@ -11053,18 +11105,6 @@ class ElementPaint {
11053
11105
  };
11054
11106
  renderObject.render(renderData);
11055
11107
  }
11056
- // //审阅信息
11057
- // if (this.viewOptions.showReviewWindow && element && element.type === 'comm') {
11058
- // const commElement = element as CommentElement;
11059
- // if (commElement.props.markType === 'start') {
11060
- // //获取当前绘制元素相对于当前页的坐标
11061
- // this.paintCommMap.push({
11062
- // ele: commElement,
11063
- // render: renderObject,
11064
- // pos: { x: currPosition.x - this.paintPagePos.x, y: currPosition.y - this.paintPagePos.y }
11065
- // });
11066
- // }
11067
- // }
11068
11108
  }
11069
11109
  //处理选中拖蓝
11070
11110
  if (inViewPort && this.selectedSets.has(element)) {
@@ -11500,6 +11540,7 @@ class EditorContext {
11500
11540
  this.clearPrevDocCb?.();
11501
11541
  //this.ele_types_handlers.length = 0;
11502
11542
  this.imageLoader.clear();
11543
+ this._document = null;
11503
11544
  }
11504
11545
  /**
11505
11546
  * 切换行打印模式
@@ -11879,6 +11920,8 @@ class DynamicContextParser {
11879
11920
  TableData(tableId, startRow, startCol, endRow, endCol) {
11880
11921
  const tb = this.doc.treeFind(item => item instanceof TableElement && item.props.id === tableId);
11881
11922
  const res = [];
11923
+ startRow = startRow < 0 ? tb.length + startRow : startRow;
11924
+ startCol = startCol < 0 ? tb.length + startCol : startCol;
11882
11925
  endRow = endRow < 0 ? tb.length + endRow : endRow;
11883
11926
  endCol = endCol < 0 ? tb.length + endCol : endCol;
11884
11927
  for (let i = startRow; i <= endRow; i++) {
@@ -11892,33 +11935,6 @@ class DynamicContextParser {
11892
11935
  }
11893
11936
  }
11894
11937
 
11895
- /**
11896
- * 文字行渲染模式
11897
- 用于医嘱打印模式
11898
- */
11899
- function runTextLineRender(ele, data) {
11900
- if (!data.options.textRowLineMode) {
11901
- return;
11902
- }
11903
- if (ele instanceof TableElement) {
11904
- textLineRenderMode(ele, data);
11905
- remeasureParentRenders(ele.cacheRender);
11906
- return;
11907
- }
11908
- if (ele instanceof BranchElement) {
11909
- for (let i = 0; i < ele.length; i++) {
11910
- runTextLineRender(ele.getChild(i), data);
11911
- }
11912
- }
11913
- }
11914
- function remeasureParentRenders(render) {
11915
- if (!render) {
11916
- return;
11917
- }
11918
- ElementUtil.remeasure(render);
11919
- remeasureParentRenders(render.parent);
11920
- }
11921
-
11922
11938
  class TabElement extends LeafElement {
11923
11939
  constructor() {
11924
11940
  super('tab');
@@ -12256,8 +12272,15 @@ class ParagraphMeasure {
12256
12272
  }
12257
12273
  }
12258
12274
  }
12259
- if (ele.length > 2) ;
12260
- this.arrange(data, ele.getChild(i));
12275
+ this.arrangeInlineItems(data, ele.getChild(i));
12276
+ }
12277
+ }
12278
+ arrangeInlineItems(parentLine, ele) {
12279
+ if (ele instanceof InlineGroupElement) {
12280
+ this.arrangeInlineGroupElement(parentLine, ele);
12281
+ }
12282
+ else {
12283
+ this.arrange(parentLine, ele);
12261
12284
  }
12262
12285
  }
12263
12286
  arrangeLeafElement(parentLine, ele) {
@@ -12481,7 +12504,6 @@ class DocumentArrange {
12481
12504
  this.docCtx.viewOptions.showReviewWindow = this.docCtx.document.commentsContainerElement.markPairs.length > 0;
12482
12505
  const docRenders = this.arrangeDoc();
12483
12506
  this.setMeasureCompletedModifyFlag(doc);
12484
- runTextLineRender(doc, { options: this.options, renderCtx: this.renderCtx });
12485
12507
  this.cacheDocRenders(docRenders);
12486
12508
  return docRenders;
12487
12509
  });
@@ -12634,7 +12656,9 @@ class DocumentArrange {
12634
12656
  continue;
12635
12657
  }
12636
12658
  if (Array.isArray(childRender)) {
12637
- element.cacheRender = null;
12659
+ if (childRender.length > 1) {
12660
+ element.cacheRender = null;
12661
+ }
12638
12662
  for (let j = 0; j < childRender.length; j++) {
12639
12663
  if (j > 0) {
12640
12664
  render = this.createRenderObject(element);
@@ -12651,12 +12675,20 @@ class DocumentArrange {
12651
12675
  }
12652
12676
  }
12653
12677
  renders.forEach(item => ElementUtil.remeasure(item));
12678
+ this.processTableTextLineMode(element);
12654
12679
  return renders.length > 1 ? renders : renders[0];
12655
12680
  }
12656
12681
  else {
12657
12682
  throw new Error('未实现');
12658
12683
  }
12659
12684
  }
12685
+ processTableTextLineMode(ele) {
12686
+ if (this.options.textRowLineMode && ele instanceof TableElement && ele.cacheRender) {
12687
+ const cacheRender = ele.cacheRender;
12688
+ clearChildrenRenderCache(ele);
12689
+ textLineRenderMode(cacheRender, { options: this.options, renderCtx: this.renderCtx });
12690
+ }
12691
+ }
12660
12692
  createRenderObject(element) {
12661
12693
  return element.createRenderObject({
12662
12694
  options: this.options,
@@ -13061,6 +13093,26 @@ class DocumentArrange {
13061
13093
  }
13062
13094
  }
13063
13095
 
13096
+ /**
13097
+ * 文字行渲染模式
13098
+ 用于医嘱打印模式
13099
+ */
13100
+ function runTextLineRender(ele, data) {
13101
+ if (!data.options.textRowLineMode) {
13102
+ return;
13103
+ }
13104
+ if (ele instanceof TableElement) {
13105
+ // textLineRenderMode(ele, data);
13106
+ // remeasureParentRenders(ele.cacheRender)
13107
+ return;
13108
+ }
13109
+ if (ele instanceof BranchElement) {
13110
+ for (let i = 0; i < ele.length; i++) {
13111
+ runTextLineRender(ele.getChild(i), data);
13112
+ }
13113
+ }
13114
+ }
13115
+
13064
13116
  /**
13065
13117
  * 测量阶段,生成Render-UI
13066
13118
  */
@@ -14353,6 +14405,7 @@ class ElementReader {
14353
14405
  const type = data.type;
14354
14406
  for (const factory of this.factories) {
14355
14407
  if (factory.match(type)) {
14408
+ data.props = data.props ?? {};
14356
14409
  const element = factory.createElement(data);
14357
14410
  this.readExtendsProps(data, element);
14358
14411
  const childArr = [];
@@ -18306,7 +18359,6 @@ function getCurrentActiveAppContext() {
18306
18359
  function setCurrentActiveAppContext(ctx) {
18307
18360
  currentActiveAppContext = ctx;
18308
18361
  }
18309
- let taskId;
18310
18362
  function renderApp(root, renderCtx, nodeEvent) {
18311
18363
  window['root'] = root;
18312
18364
  // const nodeEvent = new NodeEvent(root, renderCtx.mainContext.ctx.canvas);
@@ -18316,15 +18368,13 @@ function renderApp(root, renderCtx, nodeEvent) {
18316
18368
  return;
18317
18369
  }
18318
18370
  delayTask = true;
18319
- taskId = setTimeout(() => {
18320
- console.log(taskId + "正在运行中");
18371
+ setTimeout(() => {
18321
18372
  currentActiveAppContext = { root, render: flushTask };
18322
18373
  delayTask = false;
18323
18374
  root.clearPopNodes();
18324
18375
  prepareRender(root, renderCtx, nodeEvent.appState);
18325
18376
  updateCursor(nodeEvent, renderCtx);
18326
18377
  currentActiveAppContext = null;
18327
- console.log(taskId + "运行完成");
18328
18378
  }, 16);
18329
18379
  };
18330
18380
  flushTask();
@@ -18812,7 +18862,6 @@ class NodeEvent {
18812
18862
  this.setActiveAppContext(() => this.onMousemoveHandler(evt));
18813
18863
  });
18814
18864
  canvas.addEventListener('mouseup', evt => {
18815
- console.log('##松开了');
18816
18865
  this.setActiveAppContext(() => this.onMouseupHandler(evt));
18817
18866
  });
18818
18867
  canvas.addEventListener('mouseleave', evt => {
@@ -18907,7 +18956,6 @@ class NodeEvent {
18907
18956
  }
18908
18957
  //按下鼠标并进行拖动时,mousemove在按下的元素上处理
18909
18958
  if (this.appState.mousedown) {
18910
- console.log("offsetY:", evt.offsetY);
18911
18959
  if (this.appState.sourceNode && this.appState.sourceNode.parent) {
18912
18960
  const currNodePos = getNodePosition(this.appState.sourceNode, { x: 0, y: 0 });
18913
18961
  this.appState.pos = { x: evt.offsetX, y: evt.offsetY };
@@ -19265,7 +19313,7 @@ function invokeNodeEvent(node, event, name, useCapture) {
19265
19313
 
19266
19314
  class ViewPaint {
19267
19315
  ctx;
19268
- onRenderCompleted = new Subject$1();
19316
+ onRenderCompleted = new OnceSubject();
19269
19317
  pageSetting;
19270
19318
  pageRect;
19271
19319
  constructor(ctx) {
@@ -20028,7 +20076,7 @@ class MenuContainer extends NodeItems {
20028
20076
  }
20029
20077
  preRender(e) {
20030
20078
  const { render, renderPos, next } = e;
20031
- e.render.onRenderCompleted.onceSubscribe((render) => {
20079
+ e.render.onRenderCompleted.subscribe((render) => {
20032
20080
  e.appState.surface.registerPopNode(this);
20033
20081
  const parentPos = { x: renderPos.x - this.finalRect.x, y: renderPos.y - this.finalRect.y };
20034
20082
  render.tran(() => {
@@ -20102,11 +20150,31 @@ class ScrollView extends NodeItems {
20102
20150
  });
20103
20151
  this.addEventListener('wheel', evt => {
20104
20152
  const { deltaY, deltaX } = evt;
20105
- console.log(`deltaX:${deltaX},deltaY:${deltaY}`);
20106
20153
  this.horBar.updateScrollByCurrent(deltaX / 10, deltaY / 10);
20107
20154
  this.verBar.updateScrollByCurrent(deltaX / 10, deltaY / 10);
20108
20155
  });
20109
20156
  }
20157
+ scrollTo(x, y) {
20158
+ if (!this.content.finalRect || !this.finalRect) {
20159
+ return;
20160
+ }
20161
+ if (y > this.content.finalRect.height) {
20162
+ y = this.content.finalRect.height;
20163
+ }
20164
+ if (x > this.content.finalRect.width) {
20165
+ x = this.content.finalRect.width;
20166
+ }
20167
+ let scrollX = x - this.finalRect.width;
20168
+ let scrollY = y - this.finalRect.height;
20169
+ scrollX = scrollX < 0 ? 0 : scrollX;
20170
+ scrollY = scrollY < 0 ? 0 : scrollY;
20171
+ this.scrollX = scrollX;
20172
+ this.scrollY = scrollY;
20173
+ this.onScrollEvent.next({
20174
+ x: this.scrollX,
20175
+ y: this.scrollY
20176
+ });
20177
+ }
20110
20178
  measureOverride(e, availableSize) {
20111
20179
  const measureSize = availableSize;
20112
20180
  this.content.measure(e, measureSize);
@@ -20329,10 +20397,6 @@ class ScrollBar extends NodeItems {
20329
20397
  const x = this.orientation === 'horizontal' ? (scrollView.scrollX / scrollView.content.finalRect.width) * finalSize.width : (ScrollBarSize - this.thumbSize) / 2;
20330
20398
  const y = this.orientation === 'horizontal' ? (ScrollBarSize - this.thumbSize) / 2 : (scrollView.scrollY / scrollView.content.finalRect.height) * finalSize.height;
20331
20399
  this.thumb.arrange(e, { x, y, width, height });
20332
- if (this.orientation === 'vertical') {
20333
- console.log(y, height, finalSize.width, finalSize.height, scrollView.scrollY);
20334
- if (scrollView.scrollY === 4.723577235772358) ;
20335
- }
20336
20400
  return super.arrangeOverride(e, finalSize);
20337
20401
  }
20338
20402
  render(e) {
@@ -20436,6 +20500,9 @@ class RuleControl extends NodeItems {
20436
20500
  super();
20437
20501
  this.docCtx = docCtx;
20438
20502
  this.ss = docCtx.selectionState;
20503
+ this.bgColor = '#fff';
20504
+ this.shadowBlur = 5;
20505
+ this.shadowColor = '#000';
20439
20506
  this.options = {
20440
20507
  width: 0,
20441
20508
  pagePL: 0,
@@ -21135,7 +21202,7 @@ class CanvasTextEditor extends NodeItems {
21135
21202
  */
21136
21203
  docClickHandle(evt) {
21137
21204
  this.setCursor();
21138
- this.selectionOverlays.getSelectionTreeData();
21205
+ this.updateSelection();
21139
21206
  this.onClickEvent.next(evt);
21140
21207
  }
21141
21208
  /**
@@ -21147,6 +21214,7 @@ class CanvasTextEditor extends NodeItems {
21147
21214
  if (res) {
21148
21215
  this.flushToSchedule();
21149
21216
  }
21217
+ this.updateSelection();
21150
21218
  this.onDblClickEvent.next(evt);
21151
21219
  }
21152
21220
  /**
@@ -21553,6 +21621,7 @@ class CanvasTextEditor extends NodeItems {
21553
21621
  return;
21554
21622
  }
21555
21623
  //this.docScroll.scrollTo(cursorPos.rect.x, cursorPos.rect.y - this.viewOptions.translateY);
21624
+ this.scrollView.scrollTo(cursorPos.rect.x, cursorPos.rect.y + 100);
21556
21625
  }
21557
21626
  }
21558
21627
  /**
@@ -21709,6 +21778,13 @@ class CanvasTextEditor extends NodeItems {
21709
21778
  scrollView.y = 30;
21710
21779
  this.scrollView = scrollView;
21711
21780
  scrollView.content.addChild(this);
21781
+ const label = new LabelNode();
21782
+ label.text = '请注意了';
21783
+ label.bgColor = '#fff';
21784
+ label.padding = 2;
21785
+ label.x = 100;
21786
+ label.y = 100;
21787
+ //this.addChild(label);
21712
21788
  scrollView.onScrollEvent.subscribe(data => {
21713
21789
  //console.log(data);
21714
21790
  this.viewOptions.pageOffset.x = data.x;
@@ -21812,6 +21888,24 @@ class CanvasTextEditor extends NodeItems {
21812
21888
  appCtx.root.setInputPosition(caretPos);
21813
21889
  }
21814
21890
  }
21891
+ measureOverride(e, availableSize) {
21892
+ this.controls.forEach(item => {
21893
+ item.measure(e, availableSize);
21894
+ });
21895
+ return super.measureOverride(e, availableSize);
21896
+ }
21897
+ arrangeOverride(e, finalSize) {
21898
+ this.controls.forEach(item => {
21899
+ const itemRect = {
21900
+ x: item.x,
21901
+ y: item.y,
21902
+ width: item.desiredSize.width,
21903
+ height: item.desiredSize.height
21904
+ };
21905
+ item.arrange(e, itemRect);
21906
+ });
21907
+ return super.arrangeOverride(e, finalSize);
21908
+ }
21815
21909
  }
21816
21910
 
21817
21911
  /**
@@ -22240,6 +22334,7 @@ exports.MarginProps = MarginProps;
22240
22334
  exports.MouseElementEvent = MouseElementEvent;
22241
22335
  exports.MousedownElementEvent = MousedownElementEvent;
22242
22336
  exports.MuiltBlockLineRenderObject = MuiltBlockLineRenderObject;
22337
+ exports.OnceSubject = OnceSubject;
22243
22338
  exports.PSymbolElement = PSymbolElement;
22244
22339
  exports.PSymbolRenderObject = PSymbolRenderObject;
22245
22340
  exports.PaddingProps = PaddingProps;
@@ -22296,19 +22391,23 @@ exports.ValidateElement = ValidateElement;
22296
22391
  exports.ValidateProps = ValidateProps;
22297
22392
  exports.ValidateRenderObject = ValidateRenderObject;
22298
22393
  exports.ViewOptions = ViewOptions;
22394
+ exports.clearChildrenRenderCache = clearChildrenRenderCache;
22299
22395
  exports.createPrintTemplate = createPrintTemplate;
22300
22396
  exports.defaultParaHanging = defaultParaHanging;
22301
22397
  exports.deleteCurrentParagraph = deleteCurrentParagraph;
22302
22398
  exports.documentPrint = documentPrint;
22399
+ exports.drawDecorator = drawDecorator;
22303
22400
  exports.elementTypeEventHandler = elementTypeEventHandler;
22304
22401
  exports.fontMapFunc = fontMapFunc;
22305
22402
  exports.fromEvent = fromEvent;
22403
+ exports.getCalleeName = getCalleeName;
22306
22404
  exports.getFocusTextSegment = getFocusTextSegment;
22307
22405
  exports.invokeTypeHandler = invokeTypeHandler;
22308
22406
  exports.isDate = isDate;
22309
22407
  exports.objectToString = objectToString;
22310
22408
  exports.onTableContextmenu = onTableContextmenu;
22311
22409
  exports.onceTask = onceTask$1;
22410
+ exports.parser = parser;
22312
22411
  exports.printDocOnContextmenu = printDocOnContextmenu;
22313
22412
  exports.printNodes = printNodes;
22314
22413
  exports.reactiveMap = reactiveMap;