@hailin-zheng/editor-core 2.0.29 → 2.0.30

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
@@ -2373,7 +2373,7 @@ class DataEleCheckProps extends DataEleBaseProps {
2373
2373
  if (this.falseChar !== falseChar) {
2374
2374
  props.falseChar = this.falseChar;
2375
2375
  }
2376
- if (this.border) {
2376
+ if (!this.border) {
2377
2377
  props.border = this.border;
2378
2378
  }
2379
2379
  if (this.trueStateColor !== '#f00000') {
@@ -12383,14 +12383,14 @@ class ElementUtil {
12383
12383
  }
12384
12384
  };
12385
12385
  }
12386
- static getMousePos(e) {
12386
+ static getMousePos(e, scale = 1) {
12387
12387
  const svgContainer = e.currentTarget;
12388
12388
  const parentRect = svgContainer.getBoundingClientRect();
12389
12389
  const localX = e.clientX - parentRect.x; //+ this.viewOptions.pageOffset.x;
12390
12390
  const localY = e.clientY - parentRect.y; //+ this.viewOptions.pageOffset.y;
12391
12391
  return {
12392
- x: localX,
12393
- y: localY
12392
+ x: localX / scale,
12393
+ y: localY / scale
12394
12394
  };
12395
12395
  }
12396
12396
  static createClipPath(id, width, height, x = 0, y = 0) {
@@ -16129,8 +16129,8 @@ class DocumentPaint {
16129
16129
  getDocumentContainerHeight() {
16130
16130
  if (this.docPages.length > 0) {
16131
16131
  return {
16132
- width: this.docContainer.rect.width * this.viewOptions.scale,
16133
- height: this.docContainer.rect.height * this.viewOptions.scale
16132
+ width: this.docContainer.rect.width,
16133
+ height: this.docContainer.rect.height
16134
16134
  };
16135
16135
  }
16136
16136
  else {
@@ -16886,21 +16886,22 @@ class DocumentEvent {
16886
16886
  this.bindEvent();
16887
16887
  }
16888
16888
  getEventListener() {
16889
+ const scale = this.viewOptions.scale;
16889
16890
  return {
16890
16891
  mousedown: (evt) => {
16891
- this.mousedown(evt, ElementUtil.getMousePos(evt));
16892
+ this.mousedown(evt, ElementUtil.getMousePos(evt, scale));
16892
16893
  },
16893
16894
  mouseup: (evt) => {
16894
- this.mouseup(evt, ElementUtil.getMousePos(evt));
16895
+ this.mouseup(evt, ElementUtil.getMousePos(evt, scale));
16895
16896
  },
16896
16897
  click: (evt) => {
16897
16898
  this.mouseClickHandle(evt);
16898
16899
  },
16899
16900
  mousemove: (evt) => {
16900
- this.mousemove(evt, ElementUtil.getMousePos(evt));
16901
+ this.mousemove(evt, ElementUtil.getMousePos(evt, scale));
16901
16902
  },
16902
16903
  dblclick: (evt) => {
16903
- this.mouseDblClickHandle(evt, ElementUtil.getMousePos(evt));
16904
+ this.mouseDblClickHandle(evt, ElementUtil.getMousePos(evt, scale));
16904
16905
  },
16905
16906
  contextmenu: (evt) => {
16906
16907
  this.contextMenu.next(evt);
@@ -27056,7 +27057,15 @@ class DocEditor {
27056
27057
  }
27057
27058
  },
27058
27059
  children: [
27059
- docContentVNode, inputVNode, dropContainer
27060
+ {
27061
+ sel: 'div.scale-container', data: {
27062
+ style: {
27063
+ transform: 'scale(' + this.viewOptions.scale + ')',
27064
+ transformOrigin: 'left top'
27065
+ }
27066
+ },
27067
+ children: [docContentVNode, inputVNode, dropContainer]
27068
+ }
27060
27069
  ]
27061
27070
  }, ruleFunc.refreshRuleSvg().render()
27062
27071
  ]
@@ -27421,6 +27430,11 @@ class DocEditor {
27421
27430
  this.updateRenderCtx();
27422
27431
  this.flushToSchedule();
27423
27432
  this.documentPaint.layoutPages();
27433
+ const sub = this.afterNodePatch.subscribe(() => {
27434
+ sub.unsubscribe();
27435
+ const scrollDOM = this.svgContainer.querySelector('.scroll-container');
27436
+ scrollDOM.scrollLeft = (scrollDOM.scrollWidth - scrollDOM.getBoundingClientRect().width) / 2;
27437
+ });
27424
27438
  return scale;
27425
27439
  }
27426
27440
  updateRenderCtx() {