@hailin-zheng/editor-core 1.0.57 → 1.0.60

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
@@ -3484,7 +3484,7 @@ class TableCellElement extends BlockContainerElement {
3484
3484
  const cellRender = new TableCellRenderObject(this);
3485
3485
  cellRender.rect.width = cellWidth;
3486
3486
  cellRender.rect.maxWidth = cellWidth;
3487
- cellRender.padding = new PaddingProps(0, 0, 5, 5);
3487
+ cellRender.padding = new PaddingProps(2, 2, 5, 5);
3488
3488
  cellRender.rect.x = cellOffset;
3489
3489
  return cellRender;
3490
3490
  }
@@ -6666,9 +6666,9 @@ class DocumentSelection {
6666
6666
  if (!this.selectionState.rangeDirty) {
6667
6667
  return false;
6668
6668
  }
6669
- const range = this.selectionState.range;
6670
6669
  //转换选区
6671
6670
  this.transformRange();
6671
+ const range = this.selectionState.range;
6672
6672
  this.selectionState.clear();
6673
6673
  if (!range) {
6674
6674
  return false;
@@ -12101,7 +12101,7 @@ class DocumentEvent {
12101
12101
  //设置文档页中的相对位置
12102
12102
  evt.pageX = hitPagePos.x;
12103
12103
  evt.pageY = hitPagePos.y;
12104
- const hitInfo = this.getHitLeafRender(docRender, { x: 0, y: -docRender.rect.y }, {
12104
+ const hitInfo = this.getHitLeafRender(docRender, { x: -docRender.rect.x, y: -docRender.rect.y }, {
12105
12105
  x: evt.pageX,
12106
12106
  y: evt.pageY
12107
12107
  });
@@ -15253,6 +15253,50 @@ class DocumentContext {
15253
15253
  }
15254
15254
  });
15255
15255
  }
15256
+ /**
15257
+ * 查询字符
15258
+ * @param text
15259
+ */
15260
+ searchText(text) {
15261
+ const docTextData = this.getElementTextData(this.ctx);
15262
+ for (let i = 0; i < docTextData.length; i++) {
15263
+ // if (docTextData[i].text.indexOf(text) >= 0) {
15264
+ // matchData.push(docTextData[i]);
15265
+ // }
15266
+ const matchAll = docTextData[i].text.matchAll(new RegExp(`${text}`, 'g'));
15267
+ for (let regExpMatchArray of matchAll) {
15268
+ console.log(regExpMatchArray);
15269
+ }
15270
+ }
15271
+ }
15272
+ getElementTextData(ele) {
15273
+ const arr = [];
15274
+ if (ele instanceof BranchElement) {
15275
+ let prevText = null;
15276
+ for (let i = 0; i < ele.length; i++) {
15277
+ const child = ele.getChild(i);
15278
+ if (child instanceof TextGroupElement) {
15279
+ if (prevText) {
15280
+ const prevData = arr[arr.length - 1];
15281
+ prevData.eles.push(child);
15282
+ prevData.text += child.text;
15283
+ }
15284
+ else {
15285
+ arr.push({
15286
+ text: child.text,
15287
+ eles: [child]
15288
+ });
15289
+ }
15290
+ prevText = child;
15291
+ }
15292
+ else {
15293
+ arr.push(...this.getElementTextData(child));
15294
+ prevText = null;
15295
+ }
15296
+ }
15297
+ }
15298
+ return arr;
15299
+ }
15256
15300
  }
15257
15301
 
15258
15302
  /**
@@ -15844,7 +15888,7 @@ class CanvasTextEditor {
15844
15888
  this.viewOptions = new ViewOptions();
15845
15889
  this.documentSelection = new DocumentSelection();
15846
15890
  this.docCtx = new EditorContext(this.documentSelection.selectionState, this.viewOptions);
15847
- this.viewOptions.copyRightInfo = '万达信息电子病历编辑器,www.wondersgroup.com';
15891
+ this.viewOptions.copyRightInfo = '电子病历编辑器(XXX版权所有)';
15848
15892
  this.viewOptions.drawCharRectColor = 'green';
15849
15893
  this.viewOptions.showLineRect = true;
15850
15894
  this.viewOptions.docSpace = 20;
@@ -16363,6 +16407,9 @@ class CanvasTextEditor {
16363
16407
  return null;
16364
16408
  }
16365
16409
  const para = ElementUtil.getParentByType(selectionState.startControl, ParagraphElement);
16410
+ if (!para) {
16411
+ return null;
16412
+ }
16366
16413
  return para.props;
16367
16414
  }
16368
16415
  setTextFormat(newProps) {
@@ -16589,6 +16636,14 @@ class CanvasTextEditor {
16589
16636
  }
16590
16637
  return this.documentChange.insertElement(targetElement, targetOffset, destEleArray);
16591
16638
  }
16639
+ /**
16640
+ * 插入新元素
16641
+ * @param ele
16642
+ */
16643
+ insertNewElement(ele) {
16644
+ const { startControl, startOffset } = this.selectionState;
16645
+ this.insertElement(startControl, startOffset, [ele]);
16646
+ }
16592
16647
  showHistory() {
16593
16648
  //console.log(History.ops);
16594
16649
  const newPara = new ParagraphElement();