@hailin-zheng/editor-core 2.0.28 → 2.0.29

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
@@ -643,6 +643,15 @@ class CommonUtil {
643
643
  ele.removeChild(ele.firstChild);
644
644
  }
645
645
  }
646
+ static findParent(curr, predicate) {
647
+ if (!curr) {
648
+ return null;
649
+ }
650
+ if (predicate(curr)) {
651
+ return curr;
652
+ }
653
+ return this.findParent(curr.parentElement, predicate);
654
+ }
646
655
  }
647
656
 
648
657
  const docOpsMap = new Map();
@@ -8447,17 +8456,17 @@ class DataElementCheckRenderObject extends LeafRenderObject {
8447
8456
  const style = props.style;
8448
8457
  if (props.multiSelect) {
8449
8458
  style === 'RadioButton' ? this.drawCircleCheckbox(t, width, height, props.checked)
8450
- : this.drawRectCheckbox(t, width, height, props.size, props.checked);
8459
+ : this.drawRectCheckbox(t, width, height, props.size, props.checked, props.border);
8451
8460
  }
8452
8461
  else {
8453
- style === 'CheckBox' ? this.drawRectCheckbox(t, width, height, props.size, props.checked)
8462
+ style === 'CheckBox' ? this.drawRectCheckbox(t, width, height, props.size, props.checked, props.border)
8454
8463
  : this.drawCircleCheckbox(t, width, height, props.checked);
8455
8464
  }
8456
8465
  }
8457
8466
  return t;
8458
8467
  }
8459
- drawRectCheckbox(t, width, height, size, checked) {
8460
- t.children.push({
8468
+ drawRectCheckbox(t, width, height, size, checked, border) {
8469
+ border && t.children.push({
8461
8470
  sel: 'rect',
8462
8471
  data: {
8463
8472
  ns: "http://www.w3.org/2000/svg",
@@ -19971,11 +19980,10 @@ function createPrintTemplate({ width, height, orient }) {
19971
19980
  @page {
19972
19981
  size: ${orient};
19973
19982
  margin: 0;
19974
- padding: 0;
19975
19983
  }
19976
19984
  div {
19977
19985
  width: ${width}mm;
19978
- height: ${height}mm;
19986
+ min-height: ${height}mm;
19979
19987
  font-size: 0;
19980
19988
  }
19981
19989
  @media print {
@@ -19983,7 +19991,6 @@ function createPrintTemplate({ width, height, orient }) {
19983
19991
  body {
19984
19992
  width: ${width}mm;
19985
19993
  height: ${height}mm;
19986
- margin: 0;
19987
19994
  }
19988
19995
  div {
19989
19996
  width: initial;
@@ -26134,14 +26141,36 @@ class EditorCalendarVNode {
26134
26141
  style: {
26135
26142
  position: 'absolute',
26136
26143
  left: (position.x - 10) + 'px',
26137
- top: position.y + 'px',
26144
+ top: position.y + 5 + position.height + 'px',
26138
26145
  'min-width': '100px',
26139
26146
  'background-color': 'white',
26140
26147
  'z-index': '1000',
26141
26148
  'border-radius': '5px',
26142
26149
  'box-shadow': '0 0 5px 0 rgba(0,0,0,0.2)',
26143
26150
  'user-select': 'none',
26144
- }
26151
+ },
26152
+ hook: {
26153
+ insert: (vnode) => {
26154
+ const elm = vnode.elm;
26155
+ const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
26156
+ if (parent) {
26157
+ const parentRect = parent.getBoundingClientRect();
26158
+ const elmRect = elm.getBoundingClientRect();
26159
+ if (elmRect.top < parentRect.top) {
26160
+ elm.style.top = (position.y - elmRect.height) + 'px';
26161
+ }
26162
+ if (elmRect.left < parentRect.left) {
26163
+ elm.style.left = (position.x - 10) + 'px';
26164
+ }
26165
+ if (elmRect.right > parentRect.right) {
26166
+ elm.style.left = (position.x - elmRect.width + 10) + 'px';
26167
+ }
26168
+ if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
26169
+ elm.style.top = (position.y - position.height - elmRect.height) + 'px';
26170
+ }
26171
+ }
26172
+ }
26173
+ },
26145
26174
  },
26146
26175
  children: []
26147
26176
  };
@@ -27314,14 +27343,14 @@ class DocEditor {
27314
27343
  const startDecorateRender = element.paintRenders[0];
27315
27344
  if (!startDecorateRender) {
27316
27345
  console.error('未找到数据元开始渲染元素');
27317
- return;
27346
+ return null;
27318
27347
  }
27319
27348
  const { x, height, y, width } = startDecorateRender.rect;
27320
27349
  const pos = ElementUtil.getRenderAbsolutePaintPos(startDecorateRender);
27321
27350
  return {
27322
27351
  x: pos.x + width,
27323
- y: pos.y + height + 5,
27324
- translateY: this.viewOptions.pageOffset.y
27352
+ y: pos.y,
27353
+ height
27325
27354
  };
27326
27355
  }
27327
27356
  /**
@@ -28083,14 +28112,36 @@ class DocEditor {
28083
28112
  style: {
28084
28113
  position: 'absolute',
28085
28114
  left: (position.x - 10) + 'px',
28086
- top: position.y + 'px',
28115
+ top: position.y + 5 + position.height + 'px',
28087
28116
  'min-width': '100px',
28088
28117
  'background-color': 'white',
28089
28118
  'z-index': '1000',
28090
28119
  'border-radius': '5px',
28091
28120
  'box-shadow': '0 0 5px 0 rgba(0,0,0,0.2)',
28092
28121
  'user-select': 'none',
28093
- }
28122
+ },
28123
+ hook: {
28124
+ insert: (vnode) => {
28125
+ const elm = vnode.elm;
28126
+ const parent = CommonUtil.findParent(elm, (item) => item.className === 'scroll-container');
28127
+ if (parent) {
28128
+ const parentRect = parent.getBoundingClientRect();
28129
+ const elmRect = elm.getBoundingClientRect();
28130
+ if (elmRect.top < parentRect.top) {
28131
+ elm.style.top = (position.y - elmRect.height) + 'px';
28132
+ }
28133
+ if (elmRect.left < parentRect.left) {
28134
+ elm.style.left = (position.x - 10) + 'px';
28135
+ }
28136
+ if (elmRect.right > parentRect.right) {
28137
+ elm.style.left = (position.x - elmRect.width + 10) + 'px';
28138
+ }
28139
+ if (elmRect.top + elmRect.height > parentRect.top + parentRect.height) {
28140
+ elm.style.top = (position.y - position.height - elmRect.height) + 'px';
28141
+ }
28142
+ }
28143
+ }
28144
+ },
28094
28145
  },
28095
28146
  children: [
28096
28147
  {