@hailin-zheng/editor-core 2.1.5 → 2.1.6

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
@@ -2492,6 +2492,7 @@ class DataEleDateProps extends DataEleBaseTextProps {
2492
2492
  minValue;
2493
2493
  maxValue;
2494
2494
  format;
2495
+ value;
2495
2496
  clone(dest) {
2496
2497
  const clone = dest ?? new DataEleDateProps();
2497
2498
  super.clone(clone);
@@ -2504,7 +2505,8 @@ class DataEleDateProps extends DataEleBaseTextProps {
2504
2505
  const props = {
2505
2506
  minValue: this.minValue,
2506
2507
  maxValue: this.maxValue,
2507
- format: this.format
2508
+ format: this.format,
2509
+ value: this.value
2508
2510
  };
2509
2511
  this.getBaseProps(props, options);
2510
2512
  return props;
@@ -8640,6 +8642,7 @@ class DataElementDate extends DataElementInlineGroup {
8640
8642
  setValue(val) {
8641
8643
  if (val === null) {
8642
8644
  this.clearInnerItems();
8645
+ this.props.value = '';
8643
8646
  return;
8644
8647
  }
8645
8648
  const format = this.props.format ?? 'YYYY-MM-DD';
@@ -8653,18 +8656,24 @@ class DataElementDate extends DataElementInlineGroup {
8653
8656
  }
8654
8657
  this.pubOnChange('self');
8655
8658
  this.clearInnerItems();
8659
+ this.props.value = date.format('YYYY-MM-DD HH:mm:ss');
8656
8660
  const valueText = new TextGroupElement();
8657
8661
  this.props.valueTextProps.clone(valueText.props);
8658
8662
  valueText.text = formatStr;
8659
8663
  this.addChild(valueText, this.length - 1);
8660
8664
  this.onChangedValidate();
8661
8665
  }
8662
- isValid(val) {
8663
- const format = this.props.format ?? 'YYYY-MM-DD';
8666
+ isValid(val, format) {
8667
+ if (!format) {
8668
+ format = this.props.format ?? 'YYYY-MM-DD';
8669
+ }
8664
8670
  const date = moment__default["default"](val, format);
8665
8671
  return date.isValid();
8666
8672
  }
8667
8673
  getValue() {
8674
+ if (this.props.value) {
8675
+ return this.props.value;
8676
+ }
8668
8677
  return ElementSerialize.serializeString(this);
8669
8678
  }
8670
8679
  validate() {
@@ -8711,6 +8720,7 @@ class DataElementDateFactory extends DataElementBaseFactory {
8711
8720
  dataEleProps.minValue = props.minValue;
8712
8721
  dataEleProps.maxValue = props.maxValue;
8713
8722
  dataEleProps.format = props.format;
8723
+ dataEleProps.value = props.value ?? '';
8714
8724
  //dataEleProps.caption = props.caption;
8715
8725
  //dataEleProps.type = props.type;
8716
8726
  dataEleProps.nullText = props.nullText;
@@ -28112,6 +28122,10 @@ class DocEditor {
28112
28122
  }
28113
28123
  }
28114
28124
  scrollToPosition(pos) {
28125
+ const scale = this.viewOptions.scale;
28126
+ //处理缩放
28127
+ pos.x = pos.x * scale;
28128
+ pos.y = pos.y * scale;
28115
28129
  if (pos.y - this.viewOptions.pageOffset.y > 0 && pos.y - this.viewOptions.pageOffset.y < this.viewOptions.viewSettings.height) {
28116
28130
  return;
28117
28131
  }
@@ -28588,10 +28602,10 @@ class DocEditor {
28588
28602
  if (dataEle && dataEle instanceof DataElementDate && dataEle.props.editable) {
28589
28603
  const position = editor.getDataElementPosition(dataEle.startDecorate);
28590
28604
  let currVal = dataEle.getValue();
28591
- if (!dataEle.isValid(currVal)) {
28605
+ if (!dataEle.isValid(currVal, 'YYYY-MM-DD HH:mm:ss')) {
28592
28606
  currVal = '';
28593
28607
  }
28594
- return calendar.render(position, currVal, dataEle.props.format);
28608
+ return calendar.render(position, currVal);
28595
28609
  }
28596
28610
  calendar.reset();
28597
28611
  return null;
@@ -28655,7 +28669,7 @@ class DocEditor {
28655
28669
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
28656
28670
  }
28657
28671
  version() {
28658
- return "2.1.5";
28672
+ return "2.1.6";
28659
28673
  }
28660
28674
  }
28661
28675