@hailin-zheng/editor-core 1.1.1 → 1.1.3

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.js CHANGED
@@ -366,6 +366,7 @@ class BlockContentRenderObject extends BranchRenderObject {
366
366
  }
367
367
  }
368
368
  class InlineGroupRenderObject extends BranchRenderObject {
369
+ paintPos;
369
370
  }
370
371
  /**
371
372
  * 包含块级渲染元素的容器元素,例如body、table-cell等
@@ -907,8 +908,10 @@ class Subject$1 extends EventSourceCore$1 {
907
908
  this.addSub(sub);
908
909
  return sub;
909
910
  }
910
- onceSubscribe(listener) {
911
- const sub = this.subscribe(listener);
911
+ }
912
+ class OnceSubject extends Subject$1 {
913
+ subscribe(listener) {
914
+ const sub = super.subscribe(listener);
912
915
  sub.once = true;
913
916
  return sub;
914
917
  }
@@ -1295,13 +1298,23 @@ class BranchElement extends Element {
1295
1298
  }
1296
1299
  else {
1297
1300
  this.modifyFlag = ModifyFlag$1.Modify;
1298
- for (let i = 0; i < this.length; i++) {
1299
- this.getChild(i).pubOnChange('to-child');
1300
- }
1301
+ clearChildrenRenderCache(this);
1302
+ // for (let i = 0; i < this.length; i++) {
1303
+ // this.getChild(i).pubOnChange('to-child')
1304
+ // }
1301
1305
  }
1302
1306
  this._onChangeEvent.next();
1303
1307
  }
1304
1308
  }
1309
+ function clearChildrenRenderCache(ele) {
1310
+ for (let i = 0; i < ele.length; i++) {
1311
+ const curr = ele.getChild(i);
1312
+ curr.cacheRender = null;
1313
+ if (curr instanceof BranchElement) {
1314
+ clearChildrenRenderCache(curr);
1315
+ }
1316
+ }
1317
+ }
1305
1318
  /**
1306
1319
  * 行内编组元素
1307
1320
  */
@@ -1415,6 +1428,8 @@ class ViewOptions {
1415
1428
  defaultColor = "rgb(0,0,0)";
1416
1429
  selectionOverlaysColor = 'rgb(131,175,155,0.5)';
1417
1430
  dataEleOverlaysColor = 'rgb(131,175,155,0.5)';
1431
+ dataEleFocusedBgColor = 'rgb(131,175,155,0.8)';
1432
+ dataEleErrorBgColor = '#ff4d4f';
1418
1433
  dataEleReadOnlyOverlayColor = '#d9d9d9';
1419
1434
  dataEleOutlineColor = 'rgb(131,175,155,0.7)';
1420
1435
  viewBackcolor = 'rgb(230,230,230)';
@@ -1446,6 +1461,8 @@ class ViewOptions {
1446
1461
  enableDyExpression = false;
1447
1462
  //是否显示标尺
1448
1463
  showRule = true;
1464
+ //是否开启数据元输入验证功能
1465
+ enableDataEleInputValidate = false;
1449
1466
  //整页模式,不分页
1450
1467
  _fullPageView = false;
1451
1468
  get fullPageView() {
@@ -3650,8 +3667,12 @@ class InlineGroupInputElement extends InlineGroupElement {
3650
3667
  }
3651
3668
  }
3652
3669
  class DataElementInlineGroup extends InlineGroupInputElement {
3670
+ errorTip;
3653
3671
  constructor(type) {
3654
3672
  super(type);
3673
+ this.onChangeSubject.subscribe(() => {
3674
+ this.onChangedValidate();
3675
+ });
3655
3676
  this.addEvent('ElementMousemove', (evt) => {
3656
3677
  this.isMouseenter = true;
3657
3678
  this.refreshView();
@@ -3715,6 +3736,21 @@ class DataElementInlineGroup extends InlineGroupInputElement {
3715
3736
  this.expressFn = new Function();
3716
3737
  }
3717
3738
  }
3739
+ /**
3740
+ * 数据元发生更改后,进行数据验证
3741
+ */
3742
+ onChangedValidate() {
3743
+ this.errorTip = '';
3744
+ const options = getCurrOptions(this);
3745
+ if (!options || !options.enableDataEleInputValidate) {
3746
+ return;
3747
+ }
3748
+ this.errorTip = this.validate();
3749
+ }
3750
+ }
3751
+ function getCurrOptions(ele) {
3752
+ const doc = ElementUtil.getParent(ele, item => item.type === 'doc');
3753
+ return doc?.viewOptions;
3718
3754
  }
3719
3755
  class DataElementRenderObject extends InlineGroupRenderObject {
3720
3756
  render(e) {
@@ -3725,9 +3761,18 @@ class DataElementRenderObject extends InlineGroupRenderObject {
3725
3761
  }
3726
3762
  render.contentContext.tran(() => {
3727
3763
  //绘制数据元区域底色
3764
+ let bgColor = '';
3728
3765
  if (this.element.isMouseenter) {
3729
- const overlayColor = this.element.props.editable ? viewOptions.dataEleOverlaysColor : viewOptions.dataEleReadOnlyOverlayColor;
3730
- render.overlaysContext.fillRect(position.x, position.y - 2, this.rect.width, this.rect.height + 4, overlayColor);
3766
+ bgColor = this.element.props.editable ? viewOptions.dataEleOverlaysColor : viewOptions.dataEleReadOnlyOverlayColor;
3767
+ }
3768
+ if (this.element.isFocused) {
3769
+ bgColor = e.docCtx.viewOptions.dataEleFocusedBgColor;
3770
+ }
3771
+ if (this.element.errorTip) {
3772
+ bgColor = viewOptions.dataEleErrorBgColor;
3773
+ }
3774
+ if (bgColor) {
3775
+ render.overlaysContext.fillRect(position.x, position.y - 2, this.rect.width, this.rect.height + 4, bgColor);
3731
3776
  }
3732
3777
  if (this.element.props.secretBrowse && viewOptions.secretBrowse) {
3733
3778
  render.contentContext.ctx.filter = "blur(10px)";
@@ -3749,23 +3794,25 @@ class DataElementRenderObject extends InlineGroupRenderObject {
3749
3794
  * @private
3750
3795
  */
3751
3796
  drawCaption(e) {
3752
- const { render, position, docCtx: { viewOptions } } = e;
3753
- //获取到焦点时,绘制数据元标题
3754
- if (render.drawMode === 'view' && this.element.isFocused && this.element.paintRenders.indexOf(this) === 0) {
3755
- const { caption } = this.element.props;
3756
- if (!caption) {
3757
- return;
3797
+ e.render.onRenderCompleted.subscribe(() => {
3798
+ const { render, position, docCtx: { viewOptions } } = e;
3799
+ //获取到焦点时,绘制数据元标题
3800
+ if (render.drawMode === 'view' && this.element.isFocused && this.element.paintRenders.indexOf(this) === 0) {
3801
+ const { caption } = this.element.props;
3802
+ if (!caption) {
3803
+ return;
3804
+ }
3805
+ const textProps = new TextProps();
3806
+ textProps.fontSize = 16;
3807
+ textProps.fontName = viewOptions.defaultFontName;
3808
+ textProps.color = '#fff';
3809
+ const titleWidth = render.contentContext.measureText(caption, textProps).width;
3810
+ const x = position.x;
3811
+ const y = position.y - 20;
3812
+ render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
3813
+ render.contentContext.drawText(caption, textProps, x + 5, y, titleWidth, 20);
3758
3814
  }
3759
- const textProps = new TextProps();
3760
- textProps.fontSize = 16;
3761
- textProps.fontName = viewOptions.defaultFontName;
3762
- textProps.color = '#fff';
3763
- const titleWidth = render.contentContext.measureText(caption, textProps).width;
3764
- const x = position.x;
3765
- const y = position.y - 20;
3766
- render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
3767
- render.contentContext.drawText(caption, textProps, x + 5, y, titleWidth, 20);
3768
- }
3815
+ });
3769
3816
  }
3770
3817
  }
3771
3818
  const validateDataEle = (ele) => {
@@ -4455,7 +4502,7 @@ class PSymbolElement extends LeafElement {
4455
4502
  super('psym');
4456
4503
  this.textProps = new TextProps();
4457
4504
  this.textProps.fontSize = this.defaultHeight;
4458
- this.textProps.fontName = '楷体';
4505
+ this.textProps.fontName = 'sans-serif';
4459
4506
  this.textProps.color = '#8c8c8c';
4460
4507
  }
4461
4508
  createRenderObject() {
@@ -4482,7 +4529,7 @@ class PSymbolRenderObject extends LeafRenderObject {
4482
4529
  if (render.drawMode === 'print') {
4483
4530
  return;
4484
4531
  }
4485
- render.contentContext.drawText('', this.element.textProps, position.x, position.y, 20, this.rect.height);
4532
+ render.contentContext.drawText('', this.element.textProps, position.x, position.y, 20, this.rect.height);
4486
4533
  }
4487
4534
  //绘制段落符号
4488
4535
  clone() {
@@ -4550,6 +4597,9 @@ class TableCellElement extends BlockContainerElement {
4550
4597
  throw new Error('row is null');
4551
4598
  }
4552
4599
  const table = row.parent;
4600
+ if (!table) {
4601
+ debugger;
4602
+ }
4553
4603
  const cellIndex = row.getChildIndex(this);
4554
4604
  let cellWidth = table.getCellWidth(cellIndex);
4555
4605
  const cellOffset = table.getCellOffsetX(cellIndex);
@@ -7595,8 +7645,7 @@ class RenderContext {
7595
7645
  drawMode = 'view';
7596
7646
  contentOffCanvas;
7597
7647
  overlayOffCanvas;
7598
- //pageRect!: Omit<Rect, any>;
7599
- onRenderCompleted = new Subject$1();
7648
+ onRenderCompleted = new OnceSubject();
7600
7649
  constructor(mainContext) {
7601
7650
  this.mainContext = mainContext;
7602
7651
  }
@@ -7618,7 +7667,6 @@ class RenderContext {
7618
7667
  this.pageRect = { x: 0, y: 0, width: pageSetting.width, height: pageSetting.height };
7619
7668
  ElementUtil.setCanvasProps(this.contentOffCanvas, this.contentContext.ctx, pageSetting);
7620
7669
  ElementUtil.setCanvasProps(this.overlayOffCanvas, this.overlaysContext.ctx, pageSetting);
7621
- //ElementUtil.setCanvasProps(this.mainContext.ctx.canvas, this.mainContext.ctx, pageSetting)
7622
7670
  }
7623
7671
  clear() {
7624
7672
  this.contentContext.clear();
@@ -8657,7 +8705,7 @@ class DataElementDate extends DataElementInlineGroup {
8657
8705
  this.props.valueTextProps.clone(valueText.props);
8658
8706
  valueText.text = formatStr;
8659
8707
  this.addChild(valueText, this.length - 1);
8660
- //this.beginMeasure();
8708
+ this.onChangedValidate();
8661
8709
  }
8662
8710
  getValue() {
8663
8711
  return ElementSerialize.serializeString(this);
@@ -8747,9 +8795,9 @@ class DataElementGroupElement extends InlineGroupInputElement {
8747
8795
  }
8748
8796
  }
8749
8797
  class DataElementGroupRenderObject extends InlineGroupRenderObject {
8750
- paintPos;
8751
8798
  render(e) {
8752
8799
  this.paintPos = e.position;
8800
+ e.render.onRenderCompleted.subscribe(() => { this.paintDecorate(e); });
8753
8801
  }
8754
8802
  getCurrentParaGroupRenders() {
8755
8803
  const renders = [];
@@ -8762,7 +8810,7 @@ class DataElementGroupRenderObject extends InlineGroupRenderObject {
8762
8810
  }
8763
8811
  return renders;
8764
8812
  }
8765
- pagePaintCompleted(e) {
8813
+ paintDecorate(e) {
8766
8814
  const { render, docCtx: { viewOptions } } = e;
8767
8815
  const canPaint = this.element.isMouseenter || this.element.isFocused;
8768
8816
  if (canPaint && this.element.paintRenders.indexOf(this) === 0) {
@@ -9023,6 +9071,7 @@ class DataElementList extends DataElementInlineGroup {
9023
9071
  this.addChild(valueText, this.length - 1);
9024
9072
  }
9025
9073
  }
9074
+ this.onChangedValidate();
9026
9075
  }
9027
9076
  getValue() {
9028
9077
  const values = ElementSerialize.serializeString(this);
@@ -9116,6 +9165,7 @@ class DataElementText extends DataElementInlineGroup {
9116
9165
  valueText.text = val + '';
9117
9166
  this.addChild(valueText, this.length - 1);
9118
9167
  }
9168
+ this.onChangedValidate();
9119
9169
  }
9120
9170
  getValue() {
9121
9171
  return ElementSerialize.serializeString(this, { all: false });
@@ -10952,8 +11002,6 @@ class ElementPaint {
10952
11002
  }
10953
11003
  paintPagePos;
10954
11004
  drawPages(docContainer, selectedSets) {
10955
- // this.rePaint = rePaint;
10956
- //this.measureCommContainer = measureCommContainer;
10957
11005
  this.selectedSets = selectedSets;
10958
11006
  const pageCount = docContainer.length;
10959
11007
  const containerPos = { x: docContainer.rect.x - this.viewOptions.pageOffset.x, y: docContainer.rect.y - this.viewOptions.pageOffset.y };
@@ -10979,13 +11027,13 @@ class ElementPaint {
10979
11027
  });
10980
11028
  nextRenderFn();
10981
11029
  const { scale, viewSettings: { width, height } } = this.viewOptions;
11030
+ while (this.renderCtx.onRenderCompleted.subs.length > 0) {
11031
+ this.renderCtx.onRenderCompleted.next();
11032
+ }
10982
11033
  this.renderCtx.commit({ width, height, scale }, this.viewOptions.pageOffset);
10983
11034
  }
10984
11035
  drawRenderObject(renderObject, parent, parentInViewPort = false) {
10985
11036
  const element = renderObject.element;
10986
- // if (this.rePaint && element) {
10987
- // //element.paintRenders.push(renderObject);
10988
- // }
10989
11037
  const { x: rx, y: ry, width: rw, height: rh } = renderObject.rect;
10990
11038
  const currPosition = { x: rx + parent.x, y: ry + parent.y };
10991
11039
  //判断当前绘制元素是否在视窗内
@@ -11025,18 +11073,6 @@ class ElementPaint {
11025
11073
  };
11026
11074
  renderObject.render(renderData);
11027
11075
  }
11028
- // //审阅信息
11029
- // if (this.viewOptions.showReviewWindow && element && element.type === 'comm') {
11030
- // const commElement = element as CommentElement;
11031
- // if (commElement.props.markType === 'start') {
11032
- // //获取当前绘制元素相对于当前页的坐标
11033
- // this.paintCommMap.push({
11034
- // ele: commElement,
11035
- // render: renderObject,
11036
- // pos: { x: currPosition.x - this.paintPagePos.x, y: currPosition.y - this.paintPagePos.y }
11037
- // });
11038
- // }
11039
- // }
11040
11076
  }
11041
11077
  //处理选中拖蓝
11042
11078
  if (inViewPort && this.selectedSets.has(element)) {
@@ -11472,6 +11508,7 @@ class EditorContext {
11472
11508
  this.clearPrevDocCb?.();
11473
11509
  //this.ele_types_handlers.length = 0;
11474
11510
  this.imageLoader.clear();
11511
+ this._document = null;
11475
11512
  }
11476
11513
  /**
11477
11514
  * 切换行打印模式
@@ -11851,6 +11888,8 @@ class DynamicContextParser {
11851
11888
  TableData(tableId, startRow, startCol, endRow, endCol) {
11852
11889
  const tb = this.doc.treeFind(item => item instanceof TableElement && item.props.id === tableId);
11853
11890
  const res = [];
11891
+ startRow = startRow < 0 ? tb.length + startRow : startRow;
11892
+ startCol = startCol < 0 ? tb.length + startCol : startCol;
11854
11893
  endRow = endRow < 0 ? tb.length + endRow : endRow;
11855
11894
  endCol = endCol < 0 ? tb.length + endCol : endCol;
11856
11895
  for (let i = startRow; i <= endRow; i++) {
@@ -12077,7 +12116,6 @@ class ParagraphMeasure {
12077
12116
  */
12078
12117
  setParaTextAlign(counter, paraLineIndex, paraElement, limitWidth, paraLineRender) {
12079
12118
  let indent = paraLineRender.startX;
12080
- paraLineRender.line.rect.width = limitWidth;
12081
12119
  if (paraElement.props.textAlign === 'center') {
12082
12120
  const remainSpace = limitWidth - paraLineRender.line.rect.width;
12083
12121
  const startX = Math.ceil(remainSpace / 2) + indent;
@@ -12101,6 +12139,7 @@ class ParagraphMeasure {
12101
12139
  //return indent;
12102
12140
  }
12103
12141
  else ;
12142
+ paraLineRender.line.rect.width = limitWidth;
12104
12143
  }
12105
12144
  /**
12106
12145
  * 设置两端对齐
@@ -12228,8 +12267,15 @@ class ParagraphMeasure {
12228
12267
  }
12229
12268
  }
12230
12269
  }
12231
- if (ele.length > 2) ;
12232
- this.arrange(data, ele.getChild(i));
12270
+ this.arrangeInlineItems(data, ele.getChild(i));
12271
+ }
12272
+ }
12273
+ arrangeInlineItems(parentLine, ele) {
12274
+ if (ele instanceof InlineGroupElement) {
12275
+ this.arrangeInlineGroupElement(parentLine, ele);
12276
+ }
12277
+ else {
12278
+ this.arrange(parentLine, ele);
12233
12279
  }
12234
12280
  }
12235
12281
  arrangeLeafElement(parentLine, ele) {
@@ -12606,7 +12652,9 @@ class DocumentArrange {
12606
12652
  continue;
12607
12653
  }
12608
12654
  if (Array.isArray(childRender)) {
12609
- element.cacheRender = null;
12655
+ if (childRender.length > 1) {
12656
+ element.cacheRender = null;
12657
+ }
12610
12658
  for (let j = 0; j < childRender.length; j++) {
12611
12659
  if (j > 0) {
12612
12660
  render = this.createRenderObject(element);
@@ -14219,7 +14267,7 @@ class PageBreakRenderObject extends LeafRenderObject {
14219
14267
  if (render.drawMode === 'print') {
14220
14268
  return;
14221
14269
  }
14222
- render.contentContext.drawText('', this.element.textProps, position.x, position.y, 20, this.rect.height);
14270
+ render.contentContext.drawText('', this.element.textProps, position.x, position.y, 20, this.rect.height);
14223
14271
  }
14224
14272
  clone() {
14225
14273
  const render = new PageBreakRenderObject(this.element);
@@ -14742,7 +14790,8 @@ class DocumentEvent {
14742
14790
  };
14743
14791
  }
14744
14792
  }
14745
- if (!this.ismousedown) {
14793
+ //只有设计模式时,才需要进行边界判断,方可调整表格列宽等
14794
+ if (!this.ismousedown && this.viewOptions.docMode === DocMode.Design) {
14746
14795
  this.edgeRenderInfo = edgeRenderInfo;
14747
14796
  }
14748
14797
  //存在边界元素,并且当前边界处于鼠标按下状态
@@ -18277,7 +18326,6 @@ function getCurrentActiveAppContext() {
18277
18326
  function setCurrentActiveAppContext(ctx) {
18278
18327
  currentActiveAppContext = ctx;
18279
18328
  }
18280
- let taskId;
18281
18329
  function renderApp(root, renderCtx, nodeEvent) {
18282
18330
  window['root'] = root;
18283
18331
  // const nodeEvent = new NodeEvent(root, renderCtx.mainContext.ctx.canvas);
@@ -18287,15 +18335,13 @@ function renderApp(root, renderCtx, nodeEvent) {
18287
18335
  return;
18288
18336
  }
18289
18337
  delayTask = true;
18290
- taskId = setTimeout(() => {
18291
- console.log(taskId + "正在运行中");
18338
+ setTimeout(() => {
18292
18339
  currentActiveAppContext = { root, render: flushTask };
18293
18340
  delayTask = false;
18294
18341
  root.clearPopNodes();
18295
18342
  prepareRender(root, renderCtx, nodeEvent.appState);
18296
18343
  updateCursor(nodeEvent, renderCtx);
18297
18344
  currentActiveAppContext = null;
18298
- console.log(taskId + "运行完成");
18299
18345
  }, 16);
18300
18346
  };
18301
18347
  flushTask();
@@ -18602,6 +18648,7 @@ class ButtonBase extends TextBase {
18602
18648
 
18603
18649
  const ViewConfig = {
18604
18650
  surfaceBgColor: '#f0f0f0',
18651
+ showMousePositionLine: false,
18605
18652
  primaryColor: '#6750A4',
18606
18653
  onPrimaryColor: '#FFFFFF',
18607
18654
  themeSecondaryColor: '#2b88d8',
@@ -19235,7 +19282,7 @@ function invokeNodeEvent(node, event, name, useCapture) {
19235
19282
 
19236
19283
  class ViewPaint {
19237
19284
  ctx;
19238
- onRenderCompleted = new Subject$1();
19285
+ onRenderCompleted = new OnceSubject();
19239
19286
  pageSetting;
19240
19287
  pageRect;
19241
19288
  constructor(ctx) {
@@ -19423,8 +19470,8 @@ class ViewPaint {
19423
19470
  let { x, y } = lines[i];
19424
19471
  x = Math.ceil(x);
19425
19472
  y = Math.ceil(y);
19426
- x += 0.5;
19427
- y += 0.5;
19473
+ // x += 0.5;
19474
+ // y += 0.5;
19428
19475
  if (i === 0) {
19429
19476
  this.ctx.moveTo(x, y);
19430
19477
  }
@@ -19447,8 +19494,8 @@ class ViewPaint {
19447
19494
  }
19448
19495
  }
19449
19496
  drawRadioBox(x, y, width, height, isChecked) {
19450
- x = x + Math.floor(width / 2);
19451
- y = y + Math.floor(height / 2);
19497
+ // x = x + Math.floor(width / 2);
19498
+ // y = y + Math.floor(height / 2);
19452
19499
  width = Math.floor(width / 2);
19453
19500
  this.ctx.save();
19454
19501
  this.ctx.strokeStyle = 'black';
@@ -19592,6 +19639,13 @@ class SurfaceView extends NodeItems {
19592
19639
  this.reLayout = false;
19593
19640
  }
19594
19641
  e.render.fillRect(0, 0, this.finalRect.width, this.finalRect.height, ViewConfig.surfaceBgColor);
19642
+ e.next(e.render);
19643
+ this.drawMouseLinePosition(e);
19644
+ }
19645
+ drawMouseLinePosition(e) {
19646
+ {
19647
+ return;
19648
+ }
19595
19649
  }
19596
19650
  start() {
19597
19651
  this.renderSchedule = renderApp(this, this.renderCtx, this.nodeEvent);
@@ -19991,7 +20045,7 @@ class MenuContainer extends NodeItems {
19991
20045
  }
19992
20046
  preRender(e) {
19993
20047
  const { render, renderPos, next } = e;
19994
- e.render.onRenderCompleted.onceSubscribe((render) => {
20048
+ e.render.onRenderCompleted.subscribe((render) => {
19995
20049
  e.appState.surface.registerPopNode(this);
19996
20050
  const parentPos = { x: renderPos.x - this.finalRect.x, y: renderPos.y - this.finalRect.y };
19997
20051
  render.tran(() => {
@@ -20065,11 +20119,31 @@ class ScrollView extends NodeItems {
20065
20119
  });
20066
20120
  this.addEventListener('wheel', evt => {
20067
20121
  const { deltaY, deltaX } = evt;
20068
- console.log(`deltaX:${deltaX},deltaY:${deltaY}`);
20069
20122
  this.horBar.updateScrollByCurrent(deltaX / 10, deltaY / 10);
20070
20123
  this.verBar.updateScrollByCurrent(deltaX / 10, deltaY / 10);
20071
20124
  });
20072
20125
  }
20126
+ scrollTo(x, y) {
20127
+ if (!this.content.finalRect || !this.finalRect) {
20128
+ return;
20129
+ }
20130
+ if (y > this.content.finalRect.height) {
20131
+ y = this.content.finalRect.height;
20132
+ }
20133
+ if (x > this.content.finalRect.width) {
20134
+ x = this.content.finalRect.width;
20135
+ }
20136
+ let scrollX = x - this.finalRect.width;
20137
+ let scrollY = y - this.finalRect.height;
20138
+ scrollX = scrollX < 0 ? 0 : scrollX;
20139
+ scrollY = scrollY < 0 ? 0 : scrollY;
20140
+ this.scrollX = scrollX;
20141
+ this.scrollY = scrollY;
20142
+ this.onScrollEvent.next({
20143
+ x: this.scrollX,
20144
+ y: this.scrollY
20145
+ });
20146
+ }
20073
20147
  measureOverride(e, availableSize) {
20074
20148
  const measureSize = availableSize;
20075
20149
  this.content.measure(e, measureSize);
@@ -20292,10 +20366,6 @@ class ScrollBar extends NodeItems {
20292
20366
  const x = this.orientation === 'horizontal' ? (scrollView.scrollX / scrollView.content.finalRect.width) * finalSize.width : (ScrollBarSize - this.thumbSize) / 2;
20293
20367
  const y = this.orientation === 'horizontal' ? (ScrollBarSize - this.thumbSize) / 2 : (scrollView.scrollY / scrollView.content.finalRect.height) * finalSize.height;
20294
20368
  this.thumb.arrange(e, { x, y, width, height });
20295
- if (this.orientation === 'vertical') {
20296
- console.log(y, height, finalSize.width, finalSize.height, scrollView.scrollY);
20297
- if (scrollView.scrollY === 4.723577235772358) ;
20298
- }
20299
20369
  return super.arrangeOverride(e, finalSize);
20300
20370
  }
20301
20371
  render(e) {
@@ -20399,6 +20469,9 @@ class RuleControl extends NodeItems {
20399
20469
  super();
20400
20470
  this.docCtx = docCtx;
20401
20471
  this.ss = docCtx.selectionState;
20472
+ this.bgColor = '#fff';
20473
+ this.shadowBlur = 5;
20474
+ this.shadowColor = '#000';
20402
20475
  this.options = {
20403
20476
  width: 0,
20404
20477
  pagePL: 0,
@@ -20876,8 +20949,6 @@ class CanvasTextEditor extends NodeItems {
20876
20949
  pagePL = left;
20877
20950
  pagePR = right;
20878
20951
  }
20879
- // this.docRule.setRuleOptions({width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft});
20880
- // this.docRule.refreshRule();
20881
20952
  this.rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
20882
20953
  }
20883
20954
  createDocViewer() {
@@ -20976,12 +21047,17 @@ class CanvasTextEditor extends NodeItems {
20976
21047
  this.documentPaint.rePages();
20977
21048
  });
20978
21049
  this.updateDocSize();
20979
- //页面高度
20980
- // this.documentSelection.updateSelectionState();
20981
- // this.selectionOverlays.getSelectionTreeData();
20982
- // this.beforeRenderSubject.next();
20983
21050
  }
20984
- //生成选区内容对象
21051
+ this.updateSelection();
21052
+ this.refreshDocRule();
21053
+ this.onChanged();
21054
+ //this.refreshView();
21055
+ }
21056
+ /**
21057
+ * 计算选区内容对象
21058
+ * @private
21059
+ */
21060
+ updateSelection() {
20985
21061
  let ssChanged = false;
20986
21062
  try {
20987
21063
  //防止由于选区不正确导致的错误,导致后续的当前任务无法释放
@@ -20992,18 +21068,12 @@ class CanvasTextEditor extends NodeItems {
20992
21068
  }
20993
21069
  this.selectionOverlays.getSelectionTreeData();
20994
21070
  ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
20995
- this.refreshDocRule();
20996
- this.onChanged();
20997
- //this.refreshView();
20998
21071
  }
20999
21072
  /**
21000
21073
  * 刷新绘制文档
21001
21074
  * @param rePaint
21002
21075
  */
21003
21076
  refreshView() {
21004
- // const ssChanged = this.documentSelection.updateSelectionState();
21005
- // this.selectionOverlays.getSelectionTreeData();
21006
- // ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
21007
21077
  this.documentPaint.refreshView();
21008
21078
  this.setCursor();
21009
21079
  }
@@ -21101,7 +21171,7 @@ class CanvasTextEditor extends NodeItems {
21101
21171
  */
21102
21172
  docClickHandle(evt) {
21103
21173
  this.setCursor();
21104
- this.selectionOverlays.getSelectionTreeData();
21174
+ this.updateSelection();
21105
21175
  this.onClickEvent.next(evt);
21106
21176
  }
21107
21177
  /**
@@ -21113,6 +21183,7 @@ class CanvasTextEditor extends NodeItems {
21113
21183
  if (res) {
21114
21184
  this.flushToSchedule();
21115
21185
  }
21186
+ this.updateSelection();
21116
21187
  this.onDblClickEvent.next(evt);
21117
21188
  }
21118
21189
  /**
@@ -21195,8 +21266,6 @@ class CanvasTextEditor extends NodeItems {
21195
21266
  let minDocViewWidth = pageWidth + this.viewOptions.docSpace * 2;
21196
21267
  let maxDocViewWidth = this.surfaceView.width;
21197
21268
  this.width = Math.max(minDocViewWidth, maxDocViewWidth) - ScrollBarSize;
21198
- // this.viewOptions.viewSettings.width = this.width;
21199
- // this.viewOptions.viewSettings.height = this.scrollView.height as number;
21200
21269
  const docSize = this.documentPaint.getDocumentContainerHeight();
21201
21270
  this.height = docSize.height;
21202
21271
  this.updateRenderCtx();
@@ -21209,6 +21278,7 @@ class CanvasTextEditor extends NodeItems {
21209
21278
  this.updateRenderCtx();
21210
21279
  this.documentPaint.layoutPages();
21211
21280
  this.refreshDocument();
21281
+ this.updateLayout();
21212
21282
  }
21213
21283
  /**
21214
21284
  * 缩放视图
@@ -21520,6 +21590,7 @@ class CanvasTextEditor extends NodeItems {
21520
21590
  return;
21521
21591
  }
21522
21592
  //this.docScroll.scrollTo(cursorPos.rect.x, cursorPos.rect.y - this.viewOptions.translateY);
21593
+ this.scrollView.scrollTo(cursorPos.rect.x, cursorPos.rect.y + 100);
21523
21594
  }
21524
21595
  }
21525
21596
  /**
@@ -21676,6 +21747,13 @@ class CanvasTextEditor extends NodeItems {
21676
21747
  scrollView.y = 30;
21677
21748
  this.scrollView = scrollView;
21678
21749
  scrollView.content.addChild(this);
21750
+ const label = new LabelNode();
21751
+ label.text = '请注意了';
21752
+ label.bgColor = '#fff';
21753
+ label.padding = 2;
21754
+ label.x = 100;
21755
+ label.y = 100;
21756
+ //this.addChild(label);
21679
21757
  scrollView.onScrollEvent.subscribe(data => {
21680
21758
  //console.log(data);
21681
21759
  this.viewOptions.pageOffset.x = data.x;
@@ -21697,7 +21775,6 @@ class CanvasTextEditor extends NodeItems {
21697
21775
  this.viewOptions.viewSettings.height = data.height;
21698
21776
  this.updateDocSize();
21699
21777
  this.resetViewer();
21700
- this.updateLayout();
21701
21778
  });
21702
21779
  surface.addChild(scrollView);
21703
21780
  const rule2 = new RuleControl(this.docCtx);
@@ -21707,6 +21784,7 @@ class CanvasTextEditor extends NodeItems {
21707
21784
  rule2.x = 20;
21708
21785
  rule2.y = 500;
21709
21786
  surface.addChild(rule2);
21787
+ //surface.addChild(win);
21710
21788
  surface.start();
21711
21789
  }
21712
21790
  /**
@@ -21779,6 +21857,24 @@ class CanvasTextEditor extends NodeItems {
21779
21857
  appCtx.root.setInputPosition(caretPos);
21780
21858
  }
21781
21859
  }
21860
+ measureOverride(e, availableSize) {
21861
+ this.controls.forEach(item => {
21862
+ item.measure(e, availableSize);
21863
+ });
21864
+ return super.measureOverride(e, availableSize);
21865
+ }
21866
+ arrangeOverride(e, finalSize) {
21867
+ this.controls.forEach(item => {
21868
+ const itemRect = {
21869
+ x: item.x,
21870
+ y: item.y,
21871
+ width: item.desiredSize.width,
21872
+ height: item.desiredSize.height
21873
+ };
21874
+ item.arrange(e, itemRect);
21875
+ });
21876
+ return super.arrangeOverride(e, finalSize);
21877
+ }
21782
21878
  }
21783
21879
 
21784
21880
  /**
@@ -22066,5 +22162,5 @@ function removeDuplicatesEvent(events) {
22066
22162
  return arr;
22067
22163
  }
22068
22164
 
22069
- export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CanvasTextEditor, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommentsUtil, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, DOMEventSource, DOMSubscription, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentImagesBaseLoader, DocumentImagesLoader, DocumentInput, DocumentPaint, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementPaint, ElementReader, ElementSerialize, ElementUtil, EventMap, EventSourceCore$1 as EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag$1 as ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RunElementFactory, SelectionOverlays, SelectionRange, SelectionState, Subject$1 as Subject, SubjectSubscription$1 as SubjectSubscription, Subscription$1 as Subscription, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, createPrintTemplate, defaultParaHanging, deleteCurrentParagraph, documentPrint, elementTypeEventHandler, fontMapFunc, fromEvent, getFocusTextSegment, invokeTypeHandler, isDate, objectToString, onTableContextmenu, onceTask$1 as onceTask, printDocOnContextmenu, printNodes, reactiveMap, runTextLineRender, setDataElementProps, setNotifyChangedCallback, targetMaps, textLineRenderMode, toRawType, toTypeString, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
22165
+ export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CanvasTextEditor, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommentsUtil, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, DOMEventSource, DOMSubscription, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentImagesBaseLoader, DocumentImagesLoader, DocumentInput, DocumentPaint, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementPaint, ElementReader, ElementSerialize, ElementUtil, EventMap, EventSourceCore$1 as EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag$1 as ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RunElementFactory, SelectionOverlays, SelectionRange, SelectionState, Subject$1 as Subject, SubjectSubscription$1 as SubjectSubscription, Subscription$1 as Subscription, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, createPrintTemplate, defaultParaHanging, deleteCurrentParagraph, documentPrint, elementTypeEventHandler, fontMapFunc, fromEvent, getFocusTextSegment, invokeTypeHandler, isDate, objectToString, onTableContextmenu, onceTask$1 as onceTask, printDocOnContextmenu, printNodes, reactiveMap, runTextLineRender, setDataElementProps, setNotifyChangedCallback, targetMaps, textLineRenderMode, toRawType, toTypeString, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
22070
22166
  //# sourceMappingURL=index.js.map