@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.js CHANGED
@@ -3475,7 +3475,7 @@ class TableCellElement extends BlockContainerElement {
3475
3475
  const cellRender = new TableCellRenderObject(this);
3476
3476
  cellRender.rect.width = cellWidth;
3477
3477
  cellRender.rect.maxWidth = cellWidth;
3478
- cellRender.padding = new PaddingProps(0, 0, 5, 5);
3478
+ cellRender.padding = new PaddingProps(2, 2, 5, 5);
3479
3479
  cellRender.rect.x = cellOffset;
3480
3480
  return cellRender;
3481
3481
  }
@@ -6657,9 +6657,9 @@ class DocumentSelection {
6657
6657
  if (!this.selectionState.rangeDirty) {
6658
6658
  return false;
6659
6659
  }
6660
- const range = this.selectionState.range;
6661
6660
  //转换选区
6662
6661
  this.transformRange();
6662
+ const range = this.selectionState.range;
6663
6663
  this.selectionState.clear();
6664
6664
  if (!range) {
6665
6665
  return false;
@@ -12092,7 +12092,7 @@ class DocumentEvent {
12092
12092
  //设置文档页中的相对位置
12093
12093
  evt.pageX = hitPagePos.x;
12094
12094
  evt.pageY = hitPagePos.y;
12095
- const hitInfo = this.getHitLeafRender(docRender, { x: 0, y: -docRender.rect.y }, {
12095
+ const hitInfo = this.getHitLeafRender(docRender, { x: -docRender.rect.x, y: -docRender.rect.y }, {
12096
12096
  x: evt.pageX,
12097
12097
  y: evt.pageY
12098
12098
  });
@@ -15244,6 +15244,50 @@ class DocumentContext {
15244
15244
  }
15245
15245
  });
15246
15246
  }
15247
+ /**
15248
+ * 查询字符
15249
+ * @param text
15250
+ */
15251
+ searchText(text) {
15252
+ const docTextData = this.getElementTextData(this.ctx);
15253
+ for (let i = 0; i < docTextData.length; i++) {
15254
+ // if (docTextData[i].text.indexOf(text) >= 0) {
15255
+ // matchData.push(docTextData[i]);
15256
+ // }
15257
+ const matchAll = docTextData[i].text.matchAll(new RegExp(`${text}`, 'g'));
15258
+ for (let regExpMatchArray of matchAll) {
15259
+ console.log(regExpMatchArray);
15260
+ }
15261
+ }
15262
+ }
15263
+ getElementTextData(ele) {
15264
+ const arr = [];
15265
+ if (ele instanceof BranchElement) {
15266
+ let prevText = null;
15267
+ for (let i = 0; i < ele.length; i++) {
15268
+ const child = ele.getChild(i);
15269
+ if (child instanceof TextGroupElement) {
15270
+ if (prevText) {
15271
+ const prevData = arr[arr.length - 1];
15272
+ prevData.eles.push(child);
15273
+ prevData.text += child.text;
15274
+ }
15275
+ else {
15276
+ arr.push({
15277
+ text: child.text,
15278
+ eles: [child]
15279
+ });
15280
+ }
15281
+ prevText = child;
15282
+ }
15283
+ else {
15284
+ arr.push(...this.getElementTextData(child));
15285
+ prevText = null;
15286
+ }
15287
+ }
15288
+ }
15289
+ return arr;
15290
+ }
15247
15291
  }
15248
15292
 
15249
15293
  /**
@@ -15835,7 +15879,7 @@ class CanvasTextEditor {
15835
15879
  this.viewOptions = new ViewOptions();
15836
15880
  this.documentSelection = new DocumentSelection();
15837
15881
  this.docCtx = new EditorContext(this.documentSelection.selectionState, this.viewOptions);
15838
- this.viewOptions.copyRightInfo = '万达信息电子病历编辑器,www.wondersgroup.com';
15882
+ this.viewOptions.copyRightInfo = '电子病历编辑器(XXX版权所有)';
15839
15883
  this.viewOptions.drawCharRectColor = 'green';
15840
15884
  this.viewOptions.showLineRect = true;
15841
15885
  this.viewOptions.docSpace = 20;
@@ -16354,6 +16398,9 @@ class CanvasTextEditor {
16354
16398
  return null;
16355
16399
  }
16356
16400
  const para = ElementUtil.getParentByType(selectionState.startControl, ParagraphElement);
16401
+ if (!para) {
16402
+ return null;
16403
+ }
16357
16404
  return para.props;
16358
16405
  }
16359
16406
  setTextFormat(newProps) {
@@ -16580,6 +16627,14 @@ class CanvasTextEditor {
16580
16627
  }
16581
16628
  return this.documentChange.insertElement(targetElement, targetOffset, destEleArray);
16582
16629
  }
16630
+ /**
16631
+ * 插入新元素
16632
+ * @param ele
16633
+ */
16634
+ insertNewElement(ele) {
16635
+ const { startControl, startOffset } = this.selectionState;
16636
+ this.insertElement(startControl, startOffset, [ele]);
16637
+ }
16583
16638
  showHistory() {
16584
16639
  //console.log(History.ops);
16585
16640
  const newPara = new ParagraphElement();