@hailin-zheng/editor-core 1.0.58 → 1.0.61

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
@@ -1416,6 +1416,7 @@ class ViewOptions {
1416
1416
  viewBackcolor = 'rgb(230,230,230)';
1417
1417
  paraSymbolColor = 'rgb(128,128,128)';
1418
1418
  dataGroupColor = 'rgb(0,80,179)';
1419
+ defaultLineHeight = 1.3;
1419
1420
  //新增-留痕块文本颜色
1420
1421
  trackInsColor = '#ff4d4f';
1421
1422
  //删除-留痕块文本颜色
@@ -1753,7 +1754,7 @@ class ParagraphProps extends INotifyPropertyChanged {
1753
1754
  if (this.hanging) {
1754
1755
  props["hanging"] = this.hanging;
1755
1756
  }
1756
- if (this.lineHeight && this.lineHeight !== 1.3) {
1757
+ if (this.lineHeight && this.lineHeight !== viewOptions.defaultLineHeight) {
1757
1758
  props["lineHeight"] = this.lineHeight;
1758
1759
  }
1759
1760
  if (this.textAlign && this.textAlign !== "left") {
@@ -3384,7 +3385,7 @@ class ParagraphFactory extends ElementFactory {
3384
3385
  paraElement.props.hanging = props?.hanging ?? 0;
3385
3386
  paraElement.props.textAlign = props?.textAlign ?? 'left';
3386
3387
  paraElement.props.numberType = props?.numberType ?? -1;
3387
- paraElement.props.lineHeight = props?.lineHeight ?? 1.3;
3388
+ paraElement.props.lineHeight = props?.lineHeight ?? this.options.defaultLineHeight;
3388
3389
  paraElement.props.pageBreak = props?.pageBreak ?? false;
3389
3390
  return paraElement;
3390
3391
  }
@@ -3475,7 +3476,7 @@ class TableCellElement extends BlockContainerElement {
3475
3476
  const cellRender = new TableCellRenderObject(this);
3476
3477
  cellRender.rect.width = cellWidth;
3477
3478
  cellRender.rect.maxWidth = cellWidth;
3478
- cellRender.padding = new PaddingProps(0, 0, 5, 5);
3479
+ cellRender.padding = new PaddingProps(2, 2, 5, 5);
3479
3480
  cellRender.rect.x = cellOffset;
3480
3481
  return cellRender;
3481
3482
  }
@@ -6657,9 +6658,9 @@ class DocumentSelection {
6657
6658
  if (!this.selectionState.rangeDirty) {
6658
6659
  return false;
6659
6660
  }
6660
- const range = this.selectionState.range;
6661
6661
  //转换选区
6662
6662
  this.transformRange();
6663
+ const range = this.selectionState.range;
6663
6664
  this.selectionState.clear();
6664
6665
  if (!range) {
6665
6666
  return false;
@@ -10065,7 +10066,7 @@ class ElementMeasure {
10065
10066
  const innerLineRect = innerLineRects[i];
10066
10067
  innerLineRect.rect.x = this.getParaLineRectStartX(innerLineRects.length, i, paragraph, render, innerLineRect);
10067
10068
  //限制最大行高
10068
- const maxLineHeight = Math.floor(14 * 1.3);
10069
+ const maxLineHeight = paragraph.props.lineHeight !== this.options.defaultLineHeight ? 100 : Math.floor(14 * 2);
10069
10070
  //fillLineHeight填充行高
10070
10071
  let fillLineHeight = Math.ceil(innerLineRect.rect.height * (paragraph.props.lineHeight - 1));
10071
10072
  fillLineHeight = fillLineHeight > maxLineHeight ? maxLineHeight : fillLineHeight;
@@ -15250,13 +15251,15 @@ class DocumentContext {
15250
15251
  */
15251
15252
  searchText(text) {
15252
15253
  const docTextData = this.getElementTextData(this.ctx);
15253
- const matchData = [];
15254
15254
  for (let i = 0; i < docTextData.length; i++) {
15255
- if (docTextData[i].text.indexOf(text) >= 0) {
15256
- matchData.push(docTextData[i]);
15255
+ // if (docTextData[i].text.indexOf(text) >= 0) {
15256
+ // matchData.push(docTextData[i]);
15257
+ // }
15258
+ const matchAll = docTextData[i].text.matchAll(new RegExp(`${text}`, 'g'));
15259
+ for (let regExpMatchArray of matchAll) {
15260
+ console.log(regExpMatchArray);
15257
15261
  }
15258
15262
  }
15259
- console.log(matchData);
15260
15263
  }
15261
15264
  getElementTextData(ele) {
15262
15265
  const arr = [];
@@ -15877,7 +15880,7 @@ class CanvasTextEditor {
15877
15880
  this.viewOptions = new ViewOptions();
15878
15881
  this.documentSelection = new DocumentSelection();
15879
15882
  this.docCtx = new EditorContext(this.documentSelection.selectionState, this.viewOptions);
15880
- this.viewOptions.copyRightInfo = '万达信息电子病历编辑器,www.wondersgroup.com';
15883
+ this.viewOptions.copyRightInfo = '电子病历编辑器(XXX版权所有)';
15881
15884
  this.viewOptions.drawCharRectColor = 'green';
15882
15885
  this.viewOptions.showLineRect = true;
15883
15886
  this.viewOptions.docSpace = 20;
@@ -16396,6 +16399,9 @@ class CanvasTextEditor {
16396
16399
  return null;
16397
16400
  }
16398
16401
  const para = ElementUtil.getParentByType(selectionState.startControl, ParagraphElement);
16402
+ if (!para) {
16403
+ return null;
16404
+ }
16399
16405
  return para.props;
16400
16406
  }
16401
16407
  setTextFormat(newProps) {
@@ -16622,6 +16628,14 @@ class CanvasTextEditor {
16622
16628
  }
16623
16629
  return this.documentChange.insertElement(targetElement, targetOffset, destEleArray);
16624
16630
  }
16631
+ /**
16632
+ * 插入新元素
16633
+ * @param ele
16634
+ */
16635
+ insertNewElement(ele) {
16636
+ const { startControl, startOffset } = this.selectionState;
16637
+ this.insertElement(startControl, startOffset, [ele]);
16638
+ }
16625
16639
  showHistory() {
16626
16640
  //console.log(History.ops);
16627
16641
  const newPara = new ParagraphElement();