@hailin-zheng/editor-core 2.1.4 → 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.js CHANGED
@@ -2463,6 +2463,7 @@ class DataEleDateProps extends DataEleBaseTextProps {
2463
2463
  minValue;
2464
2464
  maxValue;
2465
2465
  format;
2466
+ value;
2466
2467
  clone(dest) {
2467
2468
  const clone = dest ?? new DataEleDateProps();
2468
2469
  super.clone(clone);
@@ -2475,7 +2476,8 @@ class DataEleDateProps extends DataEleBaseTextProps {
2475
2476
  const props = {
2476
2477
  minValue: this.minValue,
2477
2478
  maxValue: this.maxValue,
2478
- format: this.format
2479
+ format: this.format,
2480
+ value: this.value
2479
2481
  };
2480
2482
  this.getBaseProps(props, options);
2481
2483
  return props;
@@ -8611,6 +8613,7 @@ class DataElementDate extends DataElementInlineGroup {
8611
8613
  setValue(val) {
8612
8614
  if (val === null) {
8613
8615
  this.clearInnerItems();
8616
+ this.props.value = '';
8614
8617
  return;
8615
8618
  }
8616
8619
  const format = this.props.format ?? 'YYYY-MM-DD';
@@ -8624,18 +8627,24 @@ class DataElementDate extends DataElementInlineGroup {
8624
8627
  }
8625
8628
  this.pubOnChange('self');
8626
8629
  this.clearInnerItems();
8630
+ this.props.value = date.format('YYYY-MM-DD HH:mm:ss');
8627
8631
  const valueText = new TextGroupElement();
8628
8632
  this.props.valueTextProps.clone(valueText.props);
8629
8633
  valueText.text = formatStr;
8630
8634
  this.addChild(valueText, this.length - 1);
8631
8635
  this.onChangedValidate();
8632
8636
  }
8633
- isValid(val) {
8634
- const format = this.props.format ?? 'YYYY-MM-DD';
8637
+ isValid(val, format) {
8638
+ if (!format) {
8639
+ format = this.props.format ?? 'YYYY-MM-DD';
8640
+ }
8635
8641
  const date = moment(val, format);
8636
8642
  return date.isValid();
8637
8643
  }
8638
8644
  getValue() {
8645
+ if (this.props.value) {
8646
+ return this.props.value;
8647
+ }
8639
8648
  return ElementSerialize.serializeString(this);
8640
8649
  }
8641
8650
  validate() {
@@ -8682,6 +8691,7 @@ class DataElementDateFactory extends DataElementBaseFactory {
8682
8691
  dataEleProps.minValue = props.minValue;
8683
8692
  dataEleProps.maxValue = props.maxValue;
8684
8693
  dataEleProps.format = props.format;
8694
+ dataEleProps.value = props.value ?? '';
8685
8695
  //dataEleProps.caption = props.caption;
8686
8696
  //dataEleProps.type = props.type;
8687
8697
  dataEleProps.nullText = props.nullText;
@@ -28078,10 +28088,15 @@ class DocEditor {
28078
28088
  const index = docRender.getIndex();
28079
28089
  const cursorPos = DocumentCursor.getElementCursorPos(ele, 0, region, index);
28080
28090
  //this.selectionState.resetRange(element, 0);
28091
+ this.documentEvent.mousedownPos = cursorPos.rect;
28081
28092
  this.scrollToPosition(cursorPos.rect);
28082
28093
  }
28083
28094
  }
28084
28095
  scrollToPosition(pos) {
28096
+ const scale = this.viewOptions.scale;
28097
+ //处理缩放
28098
+ pos.x = pos.x * scale;
28099
+ pos.y = pos.y * scale;
28085
28100
  if (pos.y - this.viewOptions.pageOffset.y > 0 && pos.y - this.viewOptions.pageOffset.y < this.viewOptions.viewSettings.height) {
28086
28101
  return;
28087
28102
  }
@@ -28558,10 +28573,10 @@ class DocEditor {
28558
28573
  if (dataEle && dataEle instanceof DataElementDate && dataEle.props.editable) {
28559
28574
  const position = editor.getDataElementPosition(dataEle.startDecorate);
28560
28575
  let currVal = dataEle.getValue();
28561
- if (!dataEle.isValid(currVal)) {
28576
+ if (!dataEle.isValid(currVal, 'YYYY-MM-DD HH:mm:ss')) {
28562
28577
  currVal = '';
28563
28578
  }
28564
- return calendar.render(position, currVal, dataEle.props.format);
28579
+ return calendar.render(position, currVal);
28565
28580
  }
28566
28581
  calendar.reset();
28567
28582
  return null;
@@ -28625,7 +28640,7 @@ class DocEditor {
28625
28640
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
28626
28641
  }
28627
28642
  version() {
28628
- return "2.1.4";
28643
+ return "2.1.6";
28629
28644
  }
28630
28645
  }
28631
28646