@hailin-zheng/editor-core 1.1.17 → 1.1.18

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
@@ -49,6 +49,9 @@ class ContentMenuItem {
49
49
  */
50
50
  class MouseElementEvent extends ElementEvent {
51
51
  }
52
+ class InputElementEvent extends ElementEvent {
53
+ data;
54
+ }
52
55
  class MousedownElementEvent extends ElementEvent {
53
56
  }
54
57
  class KeyboradElementEvent extends ElementEvent {
@@ -1437,7 +1440,7 @@ class ViewOptions {
1437
1440
  viewBackcolor = 'rgb(230,230,230)';
1438
1441
  paraSymbolColor = 'rgb(128,128,128)';
1439
1442
  dataGroupColor = 'rgb(0,80,179)';
1440
- defaultLineHeight = 1.5;
1443
+ defaultLineHeight = 1;
1441
1444
  //新增-留痕块文本颜色
1442
1445
  trackInsColor = '#ff4d4f';
1443
1446
  //删除-留痕块文本颜色
@@ -1772,7 +1775,7 @@ class ParagraphProps extends INotifyPropertyChanged {
1772
1775
  //textProps!: TextProps;
1773
1776
  indent = 0;
1774
1777
  hanging = 0;
1775
- lineHeight = 1.5;
1778
+ lineHeight = 1;
1776
1779
  textAlign = 'left';
1777
1780
  numberType = ParagraphNumberType.none;
1778
1781
  //段前距
@@ -1872,6 +1875,8 @@ class CheckBoxProps extends INotifyPropertyChanged {
1872
1875
  isChecked;
1873
1876
  //用于复选框分组
1874
1877
  groupName;
1878
+ trueChar = '√';
1879
+ falseChar = '×';
1875
1880
  clone(dest) {
1876
1881
  const clone = dest ?? new CheckBoxProps();
1877
1882
  super.cloneAttachedProperty(clone);
@@ -2047,7 +2052,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2047
2052
  editable;
2048
2053
  deleteable;
2049
2054
  minLength;
2050
- type;
2051
2055
  underline;
2052
2056
  expression;
2053
2057
  hidden;
@@ -2066,7 +2070,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2066
2070
  target.secretBrowse = source.secretBrowse;
2067
2071
  target.printable = source.printable;
2068
2072
  target.minLength = source.minLength;
2069
- target.type = source.type;
2070
2073
  target.underline = source.underline;
2071
2074
  target.expression = source.expression;
2072
2075
  target.hidden = source.hidden;
@@ -2078,7 +2081,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2078
2081
  props["id"] = this.id;
2079
2082
  props["name"] = this.name;
2080
2083
  props["fieldName"] = this.fieldName;
2081
- props["type"] = this.type;
2082
2084
  if (this.caption) {
2083
2085
  props["caption"] = this.caption;
2084
2086
  }
@@ -2118,7 +2120,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
2118
2120
  class DataEleBaseTextProps extends DataEleBaseProps {
2119
2121
  constructor() {
2120
2122
  super();
2121
- super.type = 'text';
2122
2123
  }
2123
2124
  valueTextProps;
2124
2125
  nullText;
@@ -2134,7 +2135,6 @@ class DataEleBaseTextProps extends DataEleBaseProps {
2134
2135
  }
2135
2136
  getSerializeProps(options) {
2136
2137
  const props = {
2137
- type: this.type,
2138
2138
  valueTextProps: this.valueTextProps.getSerializeProps(options),
2139
2139
  nullText: this.nullText,
2140
2140
  nullTextProps: this.nullTextProps.getSerializeProps(options)
@@ -2164,7 +2164,6 @@ class DataEleBaseTextProps extends DataEleBaseProps {
2164
2164
  class DataEleListProps extends DataEleBaseTextProps {
2165
2165
  constructor() {
2166
2166
  super();
2167
- super.type = 'droplist';
2168
2167
  }
2169
2168
  options = [];
2170
2169
  dropDownStyle;
@@ -2230,16 +2229,23 @@ class CommProps extends INotifyPropertyChanged {
2230
2229
  };
2231
2230
  }
2232
2231
  }
2232
+ const trueChar = '✓';
2233
+ const falseChar = '×';
2233
2234
  class DataEleCheckProps extends DataEleBaseProps {
2234
2235
  constructor() {
2235
2236
  super();
2236
- super.type = 'check';
2237
2237
  }
2238
+ border = true;
2238
2239
  size;
2239
2240
  checked;
2240
2241
  checkedValue = '';
2241
2242
  groupName;
2242
2243
  multiSelect = false;
2244
+ drawStateChar = false;
2245
+ trueChar = trueChar;
2246
+ falseChar = falseChar;
2247
+ trueStateColor = '#f00000';
2248
+ falseStateColor = '#000000';
2243
2249
  clone(dest) {
2244
2250
  const clone = dest ?? new DataEleCheckProps();
2245
2251
  super.cloneBaseProps(clone);
@@ -2248,6 +2254,12 @@ class DataEleCheckProps extends DataEleBaseProps {
2248
2254
  clone.groupName = this.groupName;
2249
2255
  clone.multiSelect = this.multiSelect;
2250
2256
  clone.checkedValue = this.checkedValue;
2257
+ clone.drawStateChar = this.drawStateChar;
2258
+ clone.trueChar = this.trueChar;
2259
+ clone.falseChar = this.falseChar;
2260
+ clone.border = this.border;
2261
+ clone.trueStateColor = this.trueStateColor;
2262
+ clone.falseStateColor = this.falseStateColor;
2251
2263
  return clone;
2252
2264
  }
2253
2265
  getSerializeProps(options) {
@@ -2256,8 +2268,26 @@ class DataEleCheckProps extends DataEleBaseProps {
2256
2268
  size: this.size,
2257
2269
  groupName: this.groupName,
2258
2270
  multiSelect: this.multiSelect,
2259
- checkedValue: this.checkedValue
2271
+ checkedValue: this.checkedValue,
2260
2272
  };
2273
+ if (this.drawStateChar) {
2274
+ props.drawStateChar = this.drawStateChar;
2275
+ }
2276
+ if (this.trueChar !== trueChar) {
2277
+ props.trueChar = this.trueChar;
2278
+ }
2279
+ if (this.falseChar !== falseChar) {
2280
+ props.falseChar = this.falseChar;
2281
+ }
2282
+ if (this.border) {
2283
+ props.border = this.border;
2284
+ }
2285
+ if (this.trueStateColor !== '#f00000') {
2286
+ props.trueStateColor = this.trueStateColor;
2287
+ }
2288
+ if (this.falseStateColor !== '#000000') {
2289
+ props.falseStateColor = this.falseStateColor;
2290
+ }
2261
2291
  this.getBaseProps(props, options);
2262
2292
  return props;
2263
2293
  }
@@ -2268,12 +2298,17 @@ class DataEleCheckProps extends DataEleBaseProps {
2268
2298
  this.groupName = props.groupName;
2269
2299
  this.multiSelect = props.multiSelect;
2270
2300
  this.checkedValue = props.checkedValue;
2301
+ this.drawStateChar = props.drawStateChar;
2302
+ this.trueChar = props.trueChar;
2303
+ this.falseChar = props.falseChar;
2304
+ this.trueStateColor = props.trueStateColor;
2305
+ this.falseStateColor = props.falseStateColor;
2306
+ this.border = props.border;
2271
2307
  }
2272
2308
  }
2273
2309
  class DataEleImageProps extends DataEleBaseProps {
2274
2310
  constructor() {
2275
2311
  super();
2276
- super.type = 'img';
2277
2312
  }
2278
2313
  width;
2279
2314
  height;
@@ -2307,10 +2342,6 @@ class DataEleImageProps extends DataEleBaseProps {
2307
2342
  }
2308
2343
  }
2309
2344
  class DataEleDateProps extends DataEleBaseTextProps {
2310
- constructor() {
2311
- super();
2312
- super.type = 'date';
2313
- }
2314
2345
  minValue;
2315
2346
  maxValue;
2316
2347
  format;
@@ -3137,7 +3168,7 @@ class DataElementRenderObject extends InlineGroupRenderObject {
3137
3168
  bgColor = viewOptions.dataEleErrorBgColor;
3138
3169
  }
3139
3170
  if (bgColor) {
3140
- render.overlaysContext.fillRect(position.x, position.y - 2, this.rect.width, this.rect.height + 4, bgColor);
3171
+ render.overlaysContext.fillRect(position.x, position.y, this.rect.width, this.rect.height, bgColor);
3141
3172
  }
3142
3173
  if (this.element.props.secretBrowse && viewOptions.secretBrowse) {
3143
3174
  render.contentContext.ctx.filter = "blur(10px)";
@@ -3174,7 +3205,7 @@ class DataElementRenderObject extends InlineGroupRenderObject {
3174
3205
  textProps.fontSize = 16;
3175
3206
  textProps.fontName = viewOptions.defaultFontName;
3176
3207
  textProps.color = '#fff';
3177
- const titleWidth = render.contentContext.measureText2(caption, textProps);
3208
+ const titleWidth = render.contentContext.measureTextWidth(caption, textProps);
3178
3209
  const x = position.x;
3179
3210
  const y = position.y - 20;
3180
3211
  render.contentContext.fillRect(x, y, titleWidth + 10, 20, 'blue');
@@ -4057,8 +4088,8 @@ class DocumentContainerRender extends BlockContainerRenderObject {
4057
4088
  }
4058
4089
 
4059
4090
  class TextGroupElement extends LeafElement {
4060
- //props: TextProps;
4061
4091
  textMeasures = [];
4092
+ fontBoundingBox;
4062
4093
  isMeasure = false;
4063
4094
  constructor() {
4064
4095
  super('text');
@@ -4098,6 +4129,7 @@ class TextGroupElement extends LeafElement {
4098
4129
  createRenderObject(data) {
4099
4130
  if (!this.isMeasure || this.modifyFlag !== ModifyFlag$1.None || !this.cacheRender) {
4100
4131
  data.renderCtx.contentContext.measureTextUnits(this.textMeasures, this.props);
4132
+ this.fontBoundingBox = data.renderCtx.contentContext.measureTextMetrics(this.props.getFont());
4101
4133
  this.isMeasure = true;
4102
4134
  }
4103
4135
  const render = new TextGroupRenderObject(this);
@@ -4171,10 +4203,7 @@ class TextGroupRenderObject extends LeafRenderObject {
4171
4203
  if (this.element.props.border) {
4172
4204
  render.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height);
4173
4205
  }
4174
- render.contentContext.drawTextUnits(this, position.x, position.y);
4175
- // if (this.element.isMouseenter) {
4176
- // ctx.overlaysContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, CommonUtil.randomColor());
4177
- // }
4206
+ render.contentContext.drawTextUnits(this, position.x, position.y, this.element.fontBoundingBox.fontBoundingBoxAscent);
4178
4207
  }
4179
4208
  constructor(element) {
4180
4209
  super(element);
@@ -4193,7 +4222,7 @@ class TextGroupRenderObject extends LeafRenderObject {
4193
4222
  }
4194
4223
  measure() {
4195
4224
  this.rect.width = this.textMeasures.reduce((prev, curr) => prev + curr.actualSize, 0);
4196
- this.rect.height = this.element.props.fontSize;
4225
+ this.rect.height = this.element.fontBoundingBox.fontBoundingBoxAscent + this.element.fontBoundingBox.fontBoundingBoxDescent;
4197
4226
  }
4198
4227
  }
4199
4228
  class TextGroupFactory extends ElementFactory {
@@ -5590,10 +5619,15 @@ class TableUtil {
5590
5619
  }
5591
5620
  const remainWidth = tbWidth - sum;
5592
5621
  const ratio = remainWidth / percentSum;
5622
+ let count = 0;
5593
5623
  for (let i = 0; i < percentCols.length; i++) {
5594
5624
  const width = percentCols[i];
5595
5625
  if (typeof width === 'string') {
5596
5626
  percentCols[i] = Math.floor(Number.parseFloat(width) * ratio);
5627
+ if (i === percentCols.length - 1) {
5628
+ percentCols[i] = remainWidth - count;
5629
+ }
5630
+ count += percentCols[i];
5597
5631
  }
5598
5632
  }
5599
5633
  return percentCols;
@@ -6237,7 +6271,6 @@ class ElementUtil {
6237
6271
  dest.secretBrowse = props.secretBrowse;
6238
6272
  dest.deleteable = props.deleteable;
6239
6273
  dest.underline = props.underline;
6240
- dest.type = props.type;
6241
6274
  dest.expression = props.expression;
6242
6275
  dest.hidden = props.hidden;
6243
6276
  return dest;
@@ -6308,9 +6341,9 @@ class ElementUtil {
6308
6341
  }
6309
6342
  static remeasureTableRow(rowRender, foreceColIndex = -1) {
6310
6343
  const rowEle = rowRender.element;
6311
- let maxCellHeight = rowEle.props.minHeight > 19 ? rowEle.props.minHeight : 19;
6344
+ let maxCellHeight = rowEle.props.minHeight > 20 ? rowEle.props.minHeight : 20;
6312
6345
  //限制行最小高度
6313
- maxCellHeight = maxCellHeight < 19 ? 19 : maxCellHeight;
6346
+ maxCellHeight = maxCellHeight < 20 ? 20 : maxCellHeight;
6314
6347
  //获取行内非纵向合并单元格的最高单元格高度
6315
6348
  for (let i = 0; i < rowRender.length; i++) {
6316
6349
  const cellRender = rowRender.getChild(i);
@@ -7770,7 +7803,7 @@ class PaintContent {
7770
7803
  this.ctx.fill();
7771
7804
  this.ctx.restore();
7772
7805
  }
7773
- drawTextUnits(textGroupRender, x, y) {
7806
+ drawTextUnits(textGroupRender, x, y, baseLine) {
7774
7807
  const textEle = textGroupRender.element;
7775
7808
  const textProps = textEle.props;
7776
7809
  const { width, height } = textGroupRender.rect;
@@ -7793,12 +7826,10 @@ class PaintContent {
7793
7826
  this.drawHoriLine(x, y, width, textProps.color, 1);
7794
7827
  }
7795
7828
  let horX = 0;
7796
- let vertHeight = height - (height / 7);
7829
+ let vertHeight = baseLine;
7797
7830
  if (textProps.vertAlign === 'superscript') {
7798
7831
  //到top
7799
7832
  vertHeight -= textProps.fontSize * 2 / 5;
7800
- //top在向上收缩 -top行间距
7801
- //vertHeight -= textProps.fontSize * this.getParaLineHeight(textEle) / 20
7802
7833
  }
7803
7834
  for (let i = 0; i < textGroupRender.textMeasures.length; i++) {
7804
7835
  const unit = textGroupRender.textMeasures[i];
@@ -7807,6 +7838,15 @@ class PaintContent {
7807
7838
  }
7808
7839
  this.ctx.restore();
7809
7840
  }
7841
+ drawText2(str, font, color, x, y, width, height) {
7842
+ const textMetrics = this.measureTextMetrics(font, str);
7843
+ this.ctx.save();
7844
+ this.ctx.fillStyle = color;
7845
+ this.ctx.font = font;
7846
+ let vertHeight = textMetrics.actualBoundingBoxAscent;
7847
+ this.ctx.fillText(str, x + (width - (textMetrics.actualBoundingBoxLeft + textMetrics.actualBoundingBoxRight)) / 2 - textMetrics.actualBoundingBoxLeft, y + vertHeight + (height - (textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent)) / 2);
7848
+ this.ctx.restore();
7849
+ }
7810
7850
  getParaLineHeight(textEle) {
7811
7851
  const para = ElementUtil.getParentByType(textEle, ParagraphElement);
7812
7852
  if (!para) {
@@ -7817,10 +7857,23 @@ class PaintContent {
7817
7857
  measureText(text, textProps) {
7818
7858
  this.ctx.fillStyle = textProps.color;
7819
7859
  this.ctx.font = textProps.getFont();
7820
- const textMeasure = this.ctx.measureText(text);
7821
- return { width: textMeasure.width, height: textProps.fontSize };
7860
+ const { width, fontBoundingBoxDescent, fontBoundingBoxAscent } = this.ctx.measureText(text);
7861
+ return { width: width, height: fontBoundingBoxAscent + fontBoundingBoxDescent };
7822
7862
  }
7823
- measureText2(text, font) {
7863
+ measureTextMetrics(font, str = 'M') {
7864
+ this.ctx.font = font;
7865
+ const textMetrics = this.ctx.measureText(str);
7866
+ return {
7867
+ fontBoundingBoxAscent: textMetrics.fontBoundingBoxAscent,
7868
+ fontBoundingBoxDescent: textMetrics.fontBoundingBoxDescent,
7869
+ actualBoundingBoxAscent: textMetrics.actualBoundingBoxAscent,
7870
+ actualBoundingBoxDescent: textMetrics.actualBoundingBoxDescent,
7871
+ actualBoundingBoxLeft: textMetrics.actualBoundingBoxLeft,
7872
+ actualBoundingBoxRight: textMetrics.actualBoundingBoxRight,
7873
+ width: textMetrics.width
7874
+ };
7875
+ }
7876
+ measureTextWidth(text, font) {
7824
7877
  this.ctx.font = font.fontSize + 'px ' + font.fontName;
7825
7878
  return this.ctx.measureText(text).width;
7826
7879
  }
@@ -8655,11 +8708,22 @@ class DataElementCheckRenderObject extends LeafRenderObject {
8655
8708
  render(e) {
8656
8709
  const { render, position } = e;
8657
8710
  const element = this.element;
8658
- if (this.element.props.multiSelect) {
8659
- render.contentContext.drawCheckBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
8711
+ if (element.props.drawStateChar) {
8712
+ const font = `${element.props.size - 2}px 微软雅黑`;
8713
+ const str = element.props.checked ? element.props.trueChar : element.props.falseChar;
8714
+ const color = element.props.checked ? element.props.trueStateColor : element.props.falseStateColor;
8715
+ e.render.contentContext.drawText2(str, font, color, position.x, position.y, element.props.size, element.props.size);
8716
+ if (element.props.border) {
8717
+ e.render.contentContext.strokeRect(position.x + 2, position.y, element.props.size, element.props.size);
8718
+ }
8660
8719
  }
8661
8720
  else {
8662
- render.contentContext.drawRadioBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
8721
+ if (element.props.multiSelect) {
8722
+ render.contentContext.drawCheckBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
8723
+ }
8724
+ else {
8725
+ render.contentContext.drawRadioBox(position.x + 2, position.y, element.props.size, element.props.size, element.props.checked);
8726
+ }
8663
8727
  }
8664
8728
  }
8665
8729
  }
@@ -8676,15 +8740,15 @@ class DataElementCheckFactory extends ElementFactory {
8676
8740
  createDataEleProps(dest, props) {
8677
8741
  const dataEleProps = dest;
8678
8742
  ElementUtil.readEleBaseProps(dataEleProps, props);
8679
- //dataEleProps.id = props.id ?? nanoid(5);
8680
- //dataEleProps.name = props.name;
8681
- //dataEleProps.caption = props.caption;
8682
- //dataEleProps.type = props.type;
8683
8743
  dataEleProps.checked = props.checked;
8684
8744
  dataEleProps.size = props.size;
8685
8745
  dataEleProps.groupName = props.groupName;
8686
8746
  dataEleProps.multiSelect = props.multiSelect ?? false;
8687
8747
  dataEleProps.checkedValue = props.checkedValue;
8748
+ dataEleProps.drawStateChar = props.drawStateChar ?? false;
8749
+ dataEleProps.trueChar = props.trueChar ?? trueChar;
8750
+ dataEleProps.falseChar = props.falseChar ?? falseChar;
8751
+ dataEleProps.border = props.border ?? true;
8688
8752
  return dataEleProps;
8689
8753
  }
8690
8754
  }
@@ -11316,6 +11380,7 @@ class ParagraphMeasure {
11316
11380
  }
11317
11381
  },
11318
11382
  parent: null,
11383
+ isCloseToBody,
11319
11384
  applyNewLine() {
11320
11385
  createInnerLineFunc();
11321
11386
  },
@@ -11501,6 +11566,7 @@ class ParagraphMeasure {
11501
11566
  parentLine.updateHeight(child);
11502
11567
  },
11503
11568
  parent: parentLine,
11569
+ isCloseToBody: parentLine.isCloseToBody,
11504
11570
  applyNewLine() {
11505
11571
  parentLine.applyNewLine();
11506
11572
  render = ele.createRenderObject({ options, renderCtx });
@@ -11562,7 +11628,7 @@ class ParagraphMeasure {
11562
11628
  arrangeLeafRender(parentLine, render) {
11563
11629
  if (parentLine.lineWidth() + render.rect.width > parentLine.limitWidth) {
11564
11630
  if (render instanceof TextGroupRenderObject) {
11565
- const { firstItem, lastItem } = this.cutTextRender(render, parentLine.limitWidth - parentLine.lineWidth(), parentLine.lineWidth() === 0);
11631
+ const { firstItem, lastItem } = this.cutTextRender(render, parentLine.limitWidth - parentLine.lineWidth(), parentLine.lineWidth() === 0, parentLine.isCloseToBody);
11566
11632
  if (firstItem) {
11567
11633
  parentLine.add(firstItem);
11568
11634
  }
@@ -11570,6 +11636,10 @@ class ParagraphMeasure {
11570
11636
  parentLine.applyNewLine();
11571
11637
  this.arrangeLeafRender(parentLine, lastItem);
11572
11638
  }
11639
+ if (!firstItem && !lastItem) {
11640
+ parentLine.applyNewLine();
11641
+ this.arrangeLeafRender(parentLine, render);
11642
+ }
11573
11643
  }
11574
11644
  else if (render instanceof FillNullSpaceRenderObject) {
11575
11645
  const { firstItem, lastItem } = this.cutFillNullRender(render, parentLine.limitWidth - parentLine.lineWidth());
@@ -11609,7 +11679,7 @@ class ParagraphMeasure {
11609
11679
  }
11610
11680
  }
11611
11681
  }
11612
- cutTextRender(render, limitWidth, lineEmpty) {
11682
+ cutTextRender(render, limitWidth, lineEmpty, isCloseToBody) {
11613
11683
  let sumWidth = 0;
11614
11684
  const cutRender = render.clone();
11615
11685
  cutRender.textMeasures.length = 0;
@@ -11623,13 +11693,13 @@ class ParagraphMeasure {
11623
11693
  break;
11624
11694
  }
11625
11695
  }
11626
- // //后置标点处理
11627
- // i = this.patchHandlePostPunctuation(render, nextRender, i, inCloseBody, lineEmpty);
11628
- // //前置标点处理
11629
- // i = this.patchHandleLeadingPunctuation(render, i, lineEmpty);
11630
- // if (i <= 0) {
11631
- // return {firstItem: null, lastItem: null};
11632
- // }
11696
+ //后置标点处理
11697
+ i = this.patchHandlePostPunctuation(render, i, isCloseToBody, lineEmpty);
11698
+ //前置标点处理
11699
+ i = this.patchHandleLeadingPunctuation(render, i, lineEmpty);
11700
+ if (i <= 0) {
11701
+ return { firstItem: null, lastItem: null };
11702
+ }
11633
11703
  cutRender.textMeasures = render.textMeasures.splice(0, i);
11634
11704
  render.measure();
11635
11705
  cutRender.measure();
@@ -11639,6 +11709,7 @@ class ParagraphMeasure {
11639
11709
  * 处理前置标点,前置标点不能出现在末尾
11640
11710
  * @param render
11641
11711
  * @param i
11712
+ * @param lineEmpty
11642
11713
  */
11643
11714
  patchHandleLeadingPunctuation(render, i, lineEmpty) {
11644
11715
  if (i === 1 && lineEmpty) {
@@ -11653,15 +11724,10 @@ class ParagraphMeasure {
11653
11724
  * 处理后置标点,后置标点不能出现在行首
11654
11725
  * @param render
11655
11726
  * @param i
11727
+ * @param inCloseBody
11656
11728
  * @param lineEmpty
11657
11729
  */
11658
- patchHandlePostPunctuation(render, nextRender, i, inCloseBody, lineEmpty) {
11659
- if (i === render.textMeasures.length - 1) {
11660
- //紧跟着的字符包含后置标点
11661
- if (this.containerStartSymbolInTextStart(nextRender)) {
11662
- i--;
11663
- }
11664
- }
11730
+ patchHandlePostPunctuation(render, i, inCloseBody, lineEmpty) {
11665
11731
  if (inCloseBody && this.containPostPunctuation(render.textMeasures[i]?.char)) {
11666
11732
  if (this.containPostPunctuation(render.textMeasures[i + 1]?.char)) {
11667
11733
  i--;
@@ -13875,7 +13941,7 @@ class DocumentEvent {
13875
13941
  }
13876
13942
  const event = new GetTrackTipsEvent(this.docCtx);
13877
13943
  event.source = element;
13878
- DocumentEvent.invokeEvent('GetTrackTips', element, event, 'Bubbling', this.docCtx);
13944
+ DocumentEvent.invokeEvent('GetTrackTips', element, event, 'Bubbling');
13879
13945
  if (event.trackTips) {
13880
13946
  this.trackTipsChanged.next({ pos: { ...this.currentPos }, tips: event.trackTips });
13881
13947
  this.prevTrackInfo = true;
@@ -13927,7 +13993,7 @@ class DocumentEvent {
13927
13993
  this.endHitInfo = this.startHitInfo;
13928
13994
  const mousedownEvent = new MousedownElementEvent(this.docCtx);
13929
13995
  mousedownEvent.source = startElement;
13930
- DocumentEvent.invokeEvent('ElementMousedown', startElement, mousedownEvent, 'All', this.docCtx);
13996
+ DocumentEvent.invokeEvent('ElementMousedown', startElement, mousedownEvent, 'All');
13931
13997
  }
13932
13998
  else {
13933
13999
  this.clearHitInfo();
@@ -14060,7 +14126,7 @@ class DocumentEvent {
14060
14126
  //const { render: { renderPosition: { x: rx, y: ry } } } = this.currentMouseoverRender;
14061
14127
  //const rp = this.currentMouseoverRender?.absoluteRenderRect as Rect;
14062
14128
  const rp = ElementUtil.getRenderAbsolutePaintRect(cellRender);
14063
- rp.y -= this.viewOptions.pageOffset.y;
14129
+ //rp.y -= this.viewOptions.pageOffset.y;
14064
14130
  const relativePos = { x: mousePos.x - rp.x, y: mousePos.y - rp.y };
14065
14131
  const isInCellBorder = CommonUtil.isInRectBorder(cellRender.rect, 2, relativePos);
14066
14132
  cursorType = ElementUtil.getBorderCursor(isInCellBorder.borderType);
@@ -14177,7 +14243,7 @@ class DocumentEvent {
14177
14243
  const startElement = this.startHitInfo.render.element;
14178
14244
  const mousedownEvent = new MousedownElementEvent(this.docCtx);
14179
14245
  mousedownEvent.source = startElement;
14180
- DocumentEvent.invokeEvent('ElementClick', startElement, mousedownEvent, "All", this.docCtx);
14246
+ DocumentEvent.invokeEvent('ElementClick', startElement, mousedownEvent, "All");
14181
14247
  //this.refreshDocument();
14182
14248
  }
14183
14249
  const { startControl, startOffset, collapsed } = this.selectionState;
@@ -14189,7 +14255,7 @@ class DocumentEvent {
14189
14255
  dropEvent.source = startControl;
14190
14256
  dropEvent.sourceOffset = startOffset;
14191
14257
  dropEvent.dragElement = this.focusedElement;
14192
- if (DocumentEvent.invokeEvent('ElementDrop', startControl, dropEvent, 'All', this.docCtx)) {
14258
+ if (DocumentEvent.invokeEvent('ElementDrop', startControl, dropEvent, 'All')) {
14193
14259
  return;
14194
14260
  }
14195
14261
  this.docCtx.docChange.moveElement(startControl, startOffset, this.focusedElement, this.startHitInfo.offset, this.selectionState);
@@ -14225,7 +14291,7 @@ class DocumentEvent {
14225
14291
  if (hitInfo) {
14226
14292
  docEvent.source = hitInfo.element;
14227
14293
  docEvent.sourceRender = hitInfo.render;
14228
- const res = DocumentEvent.invokeEvent('ElementDblClick', hitInfo.element, docEvent, 'All', this.docCtx);
14294
+ const res = DocumentEvent.invokeEvent('ElementDblClick', hitInfo.element, docEvent, 'All');
14229
14295
  if (res) {
14230
14296
  return;
14231
14297
  }
@@ -14406,7 +14472,7 @@ class DocumentEvent {
14406
14472
  * @param eventStage
14407
14473
  * @param docCtx
14408
14474
  */
14409
- static invokeEvent(type, sourceElement, event, eventStage, docCtx) {
14475
+ static invokeEvent(type, sourceElement, event, eventStage) {
14410
14476
  const parents = ElementUtil.getParentElements(sourceElement);
14411
14477
  //先执行捕获阶段,在执行冒泡
14412
14478
  for (let i = parents.length - 1; i > -parents.length; i--) {
@@ -14940,7 +15006,7 @@ class DocumentInput {
14940
15006
  const evt = nodeEvt.sourceEvt;
14941
15007
  const keyEvent = new KeyboradElementEvent(this.docCtx);
14942
15008
  keyEvent.sourceEvent = evt;
14943
- if (DocumentEvent.invokeEvent('ElementKeyDown', this.docCtx.selectionState.startControl, keyEvent, 'Capture', this.docCtx)) {
15009
+ if (DocumentEvent.invokeEvent('ElementKeyDown', this.docCtx.selectionState.startControl, keyEvent, 'Capture')) {
14944
15010
  return;
14945
15011
  }
14946
15012
  if (evt.keyCode === 8) {
@@ -15067,7 +15133,13 @@ class DocumentChange {
15067
15133
  this.onInputBySelectRange(data);
15068
15134
  return;
15069
15135
  }
15070
- //判断是否需要创建新的留痕区域
15136
+ const inputEvent = new InputElementEvent(this.docCtx);
15137
+ inputEvent.data = data.data;
15138
+ DocumentEvent.invokeEvent('ElementInput', startControl, inputEvent, 'All');
15139
+ if (inputEvent.isCancel) {
15140
+ return;
15141
+ }
15142
+ //判断是否需要创建新留痕区域
15071
15143
  if (enableTrackChanges && !this.isInCorrectTrackRegion(startControl, TrackRunTypeEnum.Inserted)) {
15072
15144
  this.newInputTrackChanges(data, startControl, startOffset);
15073
15145
  return;
@@ -15174,7 +15246,7 @@ class DocumentChange {
15174
15246
  }
15175
15247
  }
15176
15248
  /**
15177
- * 创建新的留痕块,并返回留痕块输入定位文本
15249
+ * 创建新留痕块,并返回留痕块输入定位文本
15178
15250
  * @param startControl
15179
15251
  * @param startOffset
15180
15252
  * @param trackType
@@ -15330,7 +15402,7 @@ class DocumentChange {
15330
15402
  eventElement.source = startControl;
15331
15403
  eventElement.sourceEvent = evt;
15332
15404
  eventElement.sourceOffset = startOffset;
15333
- const res = DocumentEvent.invokeEvent('BackspaceKey', startControl, eventElement, 'Capture', this.docCtx);
15405
+ const res = DocumentEvent.invokeEvent('BackspaceKey', startControl, eventElement, 'Capture');
15334
15406
  if (res && res.isCancel) {
15335
15407
  return;
15336
15408
  }
@@ -15353,7 +15425,7 @@ class DocumentChange {
15353
15425
  eventElement.source = startControl;
15354
15426
  eventElement.sourceEvent = evt;
15355
15427
  eventElement.sourceOffset = startOffset;
15356
- const res = DocumentEvent.invokeEvent('DeleteKey', startControl, eventElement, 'Capture', this.docCtx);
15428
+ const res = DocumentEvent.invokeEvent('DeleteKey', startControl, eventElement, 'Capture');
15357
15429
  if (res && res.isCancel) {
15358
15430
  return;
15359
15431
  }
@@ -16112,6 +16184,25 @@ class DocumentChange {
16112
16184
  });
16113
16185
  }
16114
16186
  }
16187
+ static setParaStyle(ss, setterFunc) {
16188
+ if (ss.collapsed && ss.startControl) {
16189
+ const para = ElementUtil.getParentByType(ss.startControl, ParagraphElement);
16190
+ if (para) {
16191
+ setterFunc(para.props);
16192
+ }
16193
+ }
16194
+ else {
16195
+ const range = ss.selectedRange;
16196
+ if (!range) {
16197
+ return;
16198
+ }
16199
+ RangeUtil.recursionTraversalRangeHandler(range, (itemRange) => {
16200
+ if (itemRange.target instanceof ParagraphElement) {
16201
+ setterFunc(itemRange.target.props);
16202
+ }
16203
+ });
16204
+ }
16205
+ }
16115
16206
  /**
16116
16207
  * 复制
16117
16208
  * @param evt
@@ -20697,7 +20788,7 @@ class CanvasTextEditor extends AbsolutePanel {
20697
20788
  }
20698
20789
  const elementEvent = new ContextMenuElementEvent(this.docCtx);
20699
20790
  elementEvent.source = startControl;
20700
- DocumentEvent.invokeEvent('ElementContextMenu', startControl, elementEvent, 'All', this.docCtx);
20791
+ DocumentEvent.invokeEvent('ElementContextMenu', startControl, elementEvent, 'All');
20701
20792
  const position = { x: evt.offsetX + 10, y: evt.offsetY, translateY: this.viewOptions.pageOffset.y };
20702
20793
  this.onContextMenuItemChanged.next({ pos: position, menus: elementEvent.menus });
20703
20794
  }
@@ -20863,14 +20954,16 @@ class CanvasTextEditor extends AbsolutePanel {
20863
20954
  return null;
20864
20955
  }
20865
20956
  /**
20866
- * 设置段落对齐
20867
- * @param align
20957
+ * 设置段落样式
20958
+ * @param newProps
20868
20959
  */
20869
- switchParaAlign(align) {
20960
+ setParaStyle(newProps) {
20870
20961
  const setterFunc = (paraProps) => {
20871
- paraProps.textAlign = align;
20962
+ Object.keys(newProps).forEach(key => {
20963
+ paraProps[key] = newProps[key];
20964
+ });
20872
20965
  };
20873
- DocumentChange.setParaAlign(this.selectionState, setterFunc);
20966
+ DocumentChange.setParaStyle(this.selectionState, setterFunc);
20874
20967
  }
20875
20968
  combineCell() {
20876
20969
  TableUtil.mergeCells(this.selectionState);
@@ -21430,26 +21523,6 @@ class CanvasTextEditor extends AbsolutePanel {
21430
21523
  insertNewRow(tb, insertRowIndex) {
21431
21524
  return TableUtil.insertNewRow(tb, insertRowIndex);
21432
21525
  }
21433
- generatorDoc(data) {
21434
- //根据传入的参数,动态生成病情信息的结构化报告
21435
- const para = new ParagraphElement();
21436
- //创建患者姓名文本标签
21437
- const patNameLabel = new TextGroupElement();
21438
- patNameLabel.text = "患者姓名:";
21439
- //添加到段落中
21440
- para.addChild(patNameLabel);
21441
- //创建患者姓名数据元
21442
- const patNameDataEle = new DataElementText();
21443
- patNameDataEle.props.valueTextProps = new TextProps();
21444
- patNameDataEle.props.valueTextProps.fontName = '宋体';
21445
- patNameDataEle.props.valueTextProps.fontSize = 16;
21446
- //数据元赋值
21447
- patNameDataEle.setValue(data.patName);
21448
- //添加到段落中
21449
- para.addChild(patNameDataEle);
21450
- //添加到正文中
21451
- this.docCtx.document.bodyElement.addChild(para);
21452
- }
21453
21526
  }
21454
21527
 
21455
21528
  /**
@@ -21737,5 +21810,5 @@ function removeDuplicatesEvent(events) {
21737
21810
  return arr;
21738
21811
  }
21739
21812
 
21740
- export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CanvasTextEditor, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommentsUtil, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, DOMEventSource, DOMSubscription, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentImagesBaseLoader, DocumentImagesLoader, DocumentInput, DocumentPaint, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementPaint, ElementReader, ElementSerialize, ElementUtil, EventMap, EventSourceCore$1 as EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag$1 as ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RunElementFactory, SelectionOverlays, SelectionRange, SelectionState, Subject$1 as Subject, SubjectSubscription$1 as SubjectSubscription, Subscription$1 as Subscription, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, clearChildrenRenderCache, createPrintTemplate, defaultParaHanging, deleteCurrentParagraph, documentPrint, drawDecorator, elementTypeEventHandler, fontMapFunc, fromEvent, getCalleeName, getFocusTextSegment, invokeTypeHandler, isDate, objectToString, onTableContextmenu, onceTask$1 as onceTask, parser, printDocOnContextmenu, printNodes, reactiveMap, runTextLineRender, setDataElementProps, setNotifyChangedCallback, targetMaps, textLineRenderMode, toRawType, toTypeString, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
21813
+ export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CanvasTextEditor, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommentsUtil, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, DOMEventSource, DOMSubscription, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentImagesBaseLoader, DocumentImagesLoader, DocumentInput, DocumentPaint, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementPaint, ElementReader, ElementSerialize, ElementUtil, EventMap, EventSourceCore$1 as EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag$1 as ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RunElementFactory, SelectionOverlays, SelectionRange, SelectionState, Subject$1 as Subject, SubjectSubscription$1 as SubjectSubscription, Subscription$1 as Subscription, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, clearChildrenRenderCache, createPrintTemplate, defaultParaHanging, deleteCurrentParagraph, documentPrint, drawDecorator, elementTypeEventHandler, falseChar, fontMapFunc, fromEvent, getCalleeName, getFocusTextSegment, invokeTypeHandler, isDate, objectToString, onTableContextmenu, onceTask$1 as onceTask, parser, printDocOnContextmenu, printNodes, reactiveMap, runTextLineRender, setDataElementProps, setNotifyChangedCallback, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
21741
21814
  //# sourceMappingURL=index.js.map