@hailin-zheng/editor-core 2.2.8 → 2.2.9

Sign up to get free protection for your applications and to get access to all the features.
package/editor.css CHANGED
@@ -9,6 +9,9 @@
9
9
  .svg-container * {
10
10
  white-space: pre;
11
11
  }
12
+ .svg-container svg{
13
+ pointer-events: none;
14
+ }
12
15
 
13
16
  .drop-container {
14
17
  position: absolute;
package/index-cjs.js CHANGED
@@ -1537,12 +1537,19 @@ class BranchElement extends Element {
1537
1537
  }
1538
1538
  return len;
1539
1539
  }
1540
- treeFilter(predicate) {
1540
+ treeFilter(predicate, options) {
1541
+ if (!options) {
1542
+ options = { includeChildren: true };
1543
+ }
1541
1544
  const items = [];
1542
1545
  for (let i = 0; i < this.length; i++) {
1543
1546
  const item = this.getChild(i);
1544
1547
  if (predicate(item)) {
1545
1548
  items.push(item);
1549
+ //已经匹配节点,不需要匹配当前元素的子节点
1550
+ if (!options.includeChildren) {
1551
+ continue;
1552
+ }
1546
1553
  }
1547
1554
  if (item instanceof BranchElement) {
1548
1555
  items.push(...item.treeFilter(predicate));
@@ -2870,15 +2877,7 @@ class ValidateProps {
2870
2877
  return clone;
2871
2878
  }
2872
2879
  }
2873
- class DataElementGroupProps extends DataEleBaseProps {
2874
- clone(dest) {
2875
- const clone = dest ?? new DataElementGroupProps();
2876
- super.cloneBaseProps(clone);
2877
- }
2878
- getSerializeProps(options) {
2879
- const props = {};
2880
- return this.getBaseProps(props, options);
2881
- }
2880
+ class DataElementGroupProps extends DataEleBaseTextProps {
2882
2881
  }
2883
2882
  class DataElementBarcodeProps {
2884
2883
  type = 'code128';
@@ -8647,7 +8646,62 @@ class DataElementDateFactory extends DataElementBaseFactory {
8647
8646
  }
8648
8647
  }
8649
8648
 
8650
- class DataElementGroupElement extends InlineGroupInputElement {
8649
+ class BreakElement extends LeafElement {
8650
+ textProps;
8651
+ constructor() {
8652
+ super('br');
8653
+ this.textProps = new TextProps();
8654
+ this.textProps.fontSize = 14;
8655
+ this.textProps.fontName = '宋体';
8656
+ this.textProps.color = '#595959';
8657
+ }
8658
+ createRenderObject() {
8659
+ const symbol = new BreakRenderObject(this);
8660
+ symbol.rect.height = 14;
8661
+ symbol.rect.width = 7;
8662
+ return symbol;
8663
+ }
8664
+ serialize() {
8665
+ return {
8666
+ type: 'br',
8667
+ props: {}
8668
+ };
8669
+ }
8670
+ clone() {
8671
+ const clone = new BreakElement();
8672
+ cloneElementBase(this, clone);
8673
+ return clone;
8674
+ }
8675
+ }
8676
+ class BreakRenderObject extends LeafRenderObject {
8677
+ exportSVG(event) {
8678
+ if (!event.options.showEnterSymbol || event.mode === 'print') {
8679
+ return null;
8680
+ }
8681
+ return ElementUtil.createSvgText('↓', { 'dominant-baseline': 'hanging',
8682
+ 'font-family': 'Courier',
8683
+ 'font-size': this.rect.height,
8684
+ x: this.rect.x + 4,
8685
+ y: this.rect.y,
8686
+ fill: 'green' });
8687
+ }
8688
+ clone() {
8689
+ const render = new BreakRenderObject(this.element);
8690
+ render.rect = ElementUtil.cloneRect(this.rect);
8691
+ return render;
8692
+ }
8693
+ }
8694
+ class BreakFactory extends ElementFactory {
8695
+ match(type) {
8696
+ return type === 'br';
8697
+ }
8698
+ createElement(data) {
8699
+ const ele = new BreakElement();
8700
+ return ele;
8701
+ }
8702
+ }
8703
+
8704
+ class DataElementGroupElement extends DataElementInlineGroup {
8651
8705
  constructor() {
8652
8706
  super('data-group');
8653
8707
  this.props = new DataElementGroupProps();
@@ -8660,6 +8714,38 @@ class DataElementGroupElement extends InlineGroupInputElement {
8660
8714
  this.refreshView();
8661
8715
  });
8662
8716
  }
8717
+ setValue(val) {
8718
+ if (val === null || val === undefined) {
8719
+ val = '';
8720
+ }
8721
+ if (this.getValue() === val) {
8722
+ return;
8723
+ }
8724
+ this.pubOnChange('self');
8725
+ this.clearInnerItems();
8726
+ if (typeof val !== 'string') {
8727
+ val += '';
8728
+ }
8729
+ if (val) {
8730
+ const items = val.split('<br/>');
8731
+ if (items.length) {
8732
+ items.forEach((item, index) => {
8733
+ const valueText = new TextGroupElement();
8734
+ this.props.valueTextProps.clone(valueText.props);
8735
+ valueText.text = item + '';
8736
+ this.addChild(valueText, this.length - 1);
8737
+ if (index < items.length - 1) {
8738
+ const brElement = new BreakElement();
8739
+ this.addChild(brElement, this.length - 1);
8740
+ }
8741
+ });
8742
+ }
8743
+ }
8744
+ this.onChangedValidate();
8745
+ }
8746
+ getValue() {
8747
+ return ElementSerialize.serializeString(this, { all: false });
8748
+ }
8663
8749
  clone(data) {
8664
8750
  return super.cloneSelf(data, DataElementGroupElement);
8665
8751
  }
@@ -8695,9 +8781,18 @@ class DataElementGroupFactory extends DataElementBaseFactory {
8695
8781
  createElement(data) {
8696
8782
  const props = data.props;
8697
8783
  const ele = new DataElementGroupElement();
8698
- ElementUtil.readEleBaseProps(ele.props, props);
8784
+ this.createDataEleProps(ele.props, props);
8699
8785
  return ele;
8700
8786
  }
8787
+ createDataEleProps(dest, props) {
8788
+ const dataEleProps = dest;
8789
+ ElementUtil.readEleBaseProps(dataEleProps, props);
8790
+ dataEleProps.nullText = props.nullText;
8791
+ dataEleProps.nullTextProps = ElementUtil.readTextProps(null, props.nullTextProps, this.options);
8792
+ dataEleProps.valueTextProps = ElementUtil.readTextProps(null, props.valueTextProps, this.options);
8793
+ dataEleProps.dataType = props.dataType;
8794
+ return dataEleProps;
8795
+ }
8701
8796
  }
8702
8797
 
8703
8798
  class DataElementImage extends DataElementLeaf {
@@ -8939,61 +9034,6 @@ class DataElementListFactory extends DataElementBaseFactory {
8939
9034
  }
8940
9035
  }
8941
9036
 
8942
- class BreakElement extends LeafElement {
8943
- textProps;
8944
- constructor() {
8945
- super('br');
8946
- this.textProps = new TextProps();
8947
- this.textProps.fontSize = 14;
8948
- this.textProps.fontName = '宋体';
8949
- this.textProps.color = '#595959';
8950
- }
8951
- createRenderObject() {
8952
- const symbol = new BreakRenderObject(this);
8953
- symbol.rect.height = 14;
8954
- symbol.rect.width = 7;
8955
- return symbol;
8956
- }
8957
- serialize() {
8958
- return {
8959
- type: 'br',
8960
- props: {}
8961
- };
8962
- }
8963
- clone() {
8964
- const clone = new BreakElement();
8965
- cloneElementBase(this, clone);
8966
- return clone;
8967
- }
8968
- }
8969
- class BreakRenderObject extends LeafRenderObject {
8970
- exportSVG(event) {
8971
- if (!event.options.showEnterSymbol || event.mode === 'print') {
8972
- return null;
8973
- }
8974
- return ElementUtil.createSvgText('↓', { 'dominant-baseline': 'hanging',
8975
- 'font-family': 'Courier',
8976
- 'font-size': this.rect.height,
8977
- x: this.rect.x + 4,
8978
- y: this.rect.y,
8979
- fill: 'green' });
8980
- }
8981
- clone() {
8982
- const render = new BreakRenderObject(this.element);
8983
- render.rect = ElementUtil.cloneRect(this.rect);
8984
- return render;
8985
- }
8986
- }
8987
- class BreakFactory extends ElementFactory {
8988
- match(type) {
8989
- return type === 'br';
8990
- }
8991
- createElement(data) {
8992
- const ele = new BreakElement();
8993
- return ele;
8994
- }
8995
- }
8996
-
8997
9037
  class DataElementText extends DataElementInlineGroup {
8998
9038
  //props: DataEleBaseTextProps;
8999
9039
  constructor() {
@@ -13332,8 +13372,8 @@ class DocumentContext {
13332
13372
  const dataEleList = this.ctx.treeFilter(item => validateDataEle(item));
13333
13373
  return dataEleList.map(item => item.props.id);
13334
13374
  }
13335
- getControlInstanceList() {
13336
- return this.ctx.treeFilter(item => validateDataEle(item));
13375
+ getControlInstanceList(options) {
13376
+ return this.ctx.treeFilter(item => validateDataEle(item), options);
13337
13377
  }
13338
13378
  getControlById(id) {
13339
13379
  return this.ctx.treeFind(item => validateDataEle(item) && item['props']['id'] === id);
@@ -13356,8 +13396,9 @@ class DocumentContext {
13356
13396
  * 获取数据元结构以及get\set闭包调用函数
13357
13397
  * @returns
13358
13398
  */
13359
- getDataElementModelList() {
13360
- const dataEleList = this.ctx.treeFilter(item => validateDataEle(item) || item instanceof DataElementInlineGroup);
13399
+ getDataElementModelList(options) {
13400
+ const dataEleList = this.ctx.treeFilter(item => validateDataEle(item), options);
13401
+ //数据元、数据组
13361
13402
  const dataInlineGroups = dataEleList.filter(item => item instanceof DataElementInlineGroup);
13362
13403
  const dataLeafs = dataEleList.filter(item => item instanceof DataElementLeaf);
13363
13404
  //复选框数据元
@@ -13366,7 +13407,7 @@ class DocumentContext {
13366
13407
  const dataOtherLeafValues = CommonUtil.removeUnionSet(dataLeafs, dataCheckList).map(item => ({
13367
13408
  id: item.props.id,
13368
13409
  name: item.props.name,
13369
- fieldName: item.props.field,
13410
+ fieldName: item.props.fieldName,
13370
13411
  item,
13371
13412
  getValue: () => {
13372
13413
  return item.getValue();
@@ -21943,7 +21984,7 @@ class DocEditor {
21943
21984
  rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
21944
21985
  }
21945
21986
  version() {
21946
- return "2.2.8";
21987
+ return "2.2.9";
21947
21988
  }
21948
21989
  switchPageHeaderEditor() {
21949
21990
  this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);