@hailin-zheng/editor-core 2.0.10 → 2.0.11

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
@@ -4403,6 +4403,27 @@ class TableCellRenderObject extends InlineMuiltBlockLineRenderObject {
4403
4403
  }]);
4404
4404
  }
4405
4405
  }
4406
+ /**
4407
+ * 绘制对角线
4408
+ * @private
4409
+ */
4410
+ renderDiagonalHTML(event, diagonal, children) {
4411
+ if (!diagonal) {
4412
+ return;
4413
+ }
4414
+ if (diagonal === 'all') {
4415
+ this.renderDiagonalHTML(event, 'main', children);
4416
+ this.renderDiagonalHTML(event, 'sub', children);
4417
+ return;
4418
+ }
4419
+ if (diagonal && this.rect.width && this.rect.height) {
4420
+ let diagonalStartX = diagonal === 'main' ? 0 : this.rect.width;
4421
+ let diagonalStartY = 0;
4422
+ let diagonalEndX = diagonal === 'main' ? this.rect.width : 0;
4423
+ let diagonalEndY = this.rect.height;
4424
+ children.push(ElementUtil.createLine(diagonalStartX, diagonalStartY, diagonalEndX, diagonalEndY, '#000', 1));
4425
+ }
4426
+ }
4406
4427
  clone() {
4407
4428
  const cloneRender = new TableCellRenderObject(this.element);
4408
4429
  cloneRender.rect = ElementUtil.cloneRect(this.rect);
@@ -4419,27 +4440,16 @@ class TableCellRenderObject extends InlineMuiltBlockLineRenderObject {
4419
4440
  const clipId = `CP_${counter}`;
4420
4441
  t.children = [...CommonUtil.toArray(event.getChildNodes(this)), ElementUtil.createClipPath(clipId, this.rect.width, this.rect.height)];
4421
4442
  if (this.element.props.backgroundColor) {
4422
- //t.data.attrs.fill = this.element.props.backgroundColor;
4423
4443
  t.children.splice(0, 0, this.createBgRect());
4424
4444
  }
4425
4445
  t.data.attrs['clip-path'] = `url(#${clipId})`;
4446
+ this.renderDiagonalHTML(event, this.element.props.diagonal, t.children);
4426
4447
  t.isCompleted = true;
4427
4448
  return t;
4428
4449
  }
4429
4450
  createBgRect() {
4430
4451
  if (this.element.props.backgroundColor) {
4431
- return {
4432
- sel: 'rect',
4433
- data: {
4434
- ns: 'http://www.w3.org/2000/svg',
4435
- attrs: {
4436
- fill: this.element.props.backgroundColor,
4437
- stroke: 'none',
4438
- width: this.rect.width,
4439
- height: this.rect.height,
4440
- }
4441
- }
4442
- };
4452
+ return ElementUtil.getFillSvgRect(0, 0, this.rect.width, this.rect.height, this.element.props.backgroundColor);
4443
4453
  }
4444
4454
  return null;
4445
4455
  }
@@ -8578,6 +8588,26 @@ class ElementUtil {
8578
8588
  }
8579
8589
  };
8580
8590
  }
8591
+ static createLine(x1, y1, x2, y2, stroke, width) {
8592
+ return {
8593
+ sel: 'line',
8594
+ data: {
8595
+ ns: "http://www.w3.org/2000/svg",
8596
+ attrs: {
8597
+ x1,
8598
+ y1,
8599
+ x2,
8600
+ y2,
8601
+ stroke,
8602
+ 'stroke-width': width,
8603
+ fill: 'none'
8604
+ }
8605
+ }
8606
+ };
8607
+ }
8608
+ static getRectPath(x, y, width, height) {
8609
+ return `M${x} ${y} L${x + width} ${y} L${x + width} ${y + height} L${x} ${y + height} Z`;
8610
+ }
8581
8611
  static getFillSvgPath(pathPoints, fill, width) {
8582
8612
  const d = typeof pathPoints === 'string' ? pathPoints : pathPoints.map((p, i) => (i === 0 ? 'M' : 'L') + `${p.x} ${p.y}`).join(' ');
8583
8613
  return {
@@ -11571,7 +11601,17 @@ class DocumentBodyPartRenderObject extends MuiltBlockLineRenderObject {
11571
11601
  exportHTML(event) {
11572
11602
  const t = super.exportHTML(event);
11573
11603
  if (this.element.isFocused) {
11574
- t.children = [ElementUtil.getFillSvgRect(0, 0, this.rect.width, this.rect.height, event.options.selectPrintAreaBgColor)];
11604
+ // const bgRect=ElementUtil.getStrokeSvgPath(ElementUtil.getRectPath(0,0,this.rect.width,this.rect.height),'black',1);
11605
+ // bgRect.data.attrs.rx=5;
11606
+ // bgRect.data.attrs.ry=5;
11607
+ // bgRect.data.attrs['stroke-dasharray']='5,5';
11608
+ const bgRect = ElementUtil.getFillSvgRect(event.relativePagePos.x, event.relativePagePos.y, this.rect.width, this.rect.height, '#f0f0f0');
11609
+ bgRect.data.attrs['stroke'] = 'black';
11610
+ bgRect.data.attrs['stroke-width'] = 0.5;
11611
+ bgRect.data.attrs.rx = 5;
11612
+ bgRect.data.attrs.ry = 5;
11613
+ //t.children = [bgRect];
11614
+ event.highlights.push(bgRect);
11575
11615
  }
11576
11616
  return t;
11577
11617
  }
@@ -18091,9 +18131,6 @@ class DocumentChange {
18091
18131
  }
18092
18132
  newInput(data) {
18093
18133
  const { startControl, startOffset, collapsed, enableTrackChanges } = this.selectionState;
18094
- if (!startControl) {
18095
- debugger;
18096
- }
18097
18134
  if (!collapsed) {
18098
18135
  this.onInputBySelectRange(data);
18099
18136
  return;
@@ -18982,9 +19019,13 @@ class DocumentChange {
18982
19019
  }
18983
19020
  }
18984
19021
  else {
19022
+ let insertTarget = targetElement;
19023
+ let insertTargetOffset = targetOffset;
18985
19024
  for (let i = 0; i < destEleArray.length; i++) {
18986
19025
  lastEle = destEleArray[i];
18987
- targetElement.parent.addChild(lastEle, targetElement.getIndex() + targetOffset);
19026
+ insertTarget.parent.addChild(lastEle, insertTarget.getIndex() + insertTargetOffset);
19027
+ insertTarget = lastEle;
19028
+ insertTargetOffset = 1;
18988
19029
  }
18989
19030
  }
18990
19031
  return lastEle;
@@ -25674,6 +25715,7 @@ class EditorCalendarVNode {
25674
25715
  this.currMonth.value = moment(dataValue).month();
25675
25716
  this.selectedDate.value = moment(dataValue).format('YYYY-MM-DD');
25676
25717
  this.currentDate = dataValue;
25718
+ this.currTime.value = moment(dataValue).format('HH:mm:ss');
25677
25719
  }
25678
25720
  if (!this.currentDate) {
25679
25721
  this.currentDate = moment().format('YYYY-MM-DD');
@@ -26887,7 +26929,7 @@ class DocEditor {
26887
26929
  */
26888
26930
  getCurrentDataElement() {
26889
26931
  const selectionState = this.documentSelection.selectionState;
26890
- const { startControl, startOffset, collapsed } = selectionState;
26932
+ const { startControl, startOffset, collapsed, ancestorCommonControl } = selectionState;
26891
26933
  if (startControl && collapsed) {
26892
26934
  if (!ElementUtil.verifyHitable(startControl)) {
26893
26935
  return null;
@@ -26900,6 +26942,10 @@ class DocEditor {
26900
26942
  return null;
26901
26943
  }
26902
26944
  }
26945
+ else if (!collapsed && ancestorCommonControl) {
26946
+ const dataEle = ElementUtil.getParent(startControl, validateDataEle);
26947
+ return dataEle;
26948
+ }
26903
26949
  return null;
26904
26950
  }
26905
26951
  /**
@@ -27611,6 +27657,9 @@ class DocEditor {
27611
27657
  const editor = this;
27612
27658
  return {
27613
27659
  render() {
27660
+ if (editor.viewOptions.docMode === DocMode.View) {
27661
+ return null;
27662
+ }
27614
27663
  const dataEle = editor.getCurrentDataElement();
27615
27664
  if (dataEle && dataEle instanceof DataElementList && dataEle.props.editable) {
27616
27665
  const position = editor.getDataElementPosition(dataEle.startDecorate);
@@ -27721,6 +27770,9 @@ class DocEditor {
27721
27770
  });
27722
27771
  return {
27723
27772
  render() {
27773
+ if (editor.viewOptions.docMode === DocMode.View) {
27774
+ return null;
27775
+ }
27724
27776
  const dataEle = editor.getCurrentDataElement();
27725
27777
  if (dataEle && dataEle instanceof DataElementDate && dataEle.props.editable) {
27726
27778
  const position = editor.getDataElementPosition(dataEle.startDecorate);