@hailin-zheng/editor-core 1.1.6 → 1.1.7

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
@@ -4172,15 +4172,10 @@ class TableUtil {
4172
4172
  const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
4173
4173
  if (vMergeEndIndex > rowIndex) {
4174
4174
  const nextRow = tb.getChild(rowIndex + 1);
4175
- nextRow.getChild(i).props.vMerge = vMergeEndIndex - rowIndex > 2 ? 'restart' : null;
4175
+ nextRow.getChild(i).props.vMerge = vMergeEndIndex - rowIndex > 1 ? 'restart' : null;
4176
4176
  }
4177
4177
  }
4178
4178
  else if (cell.props.vMerge === 'continue') {
4179
- // const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
4180
- // if (vMergeEndIndex > rowIndex) {
4181
- // const nextRow = tb.getChild<TableRowElement>(rowIndex + 1);
4182
- // nextRow.getChild<TableCellElement>(i).cellProps.vMerge = 'continue';
4183
- // }
4184
4179
  const vMergeStartIndex = this.getVMergeStartIndex(tb, rowIndex, i);
4185
4180
  const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
4186
4181
  //当前单元格处于合并行的最后一行,并且合并的行数为2行
@@ -5167,6 +5162,11 @@ class TextGroupFactory extends ElementFactory {
5167
5162
  }
5168
5163
 
5169
5164
  class ElementSerialize {
5165
+ /**
5166
+ * 将当前文档对象构建并输出到标准的JSON对象
5167
+ * @param element
5168
+ * @param viewOptions
5169
+ */
5170
5170
  static serialize(element, viewOptions) {
5171
5171
  if (element instanceof BranchElement) {
5172
5172
  const result = element.serialize(viewOptions);
@@ -7967,7 +7967,7 @@ class DataElementDate extends DataElementInlineGroup {
7967
7967
  return res;
7968
7968
  }
7969
7969
  const format = this.props.format ?? 'YYYY-MM-DD';
7970
- const date = moment(this.getValue(), format);
7970
+ const date = moment(this.getValue(), format, true);
7971
7971
  if (!date.isValid()) {
7972
7972
  return '日期格式不正确';
7973
7973
  }
@@ -13682,24 +13682,6 @@ class DocumentEvent {
13682
13682
  this.editor.addEventListener('contextmenu', evt => {
13683
13683
  this.contextMenu.next(evt.sourceEvt);
13684
13684
  });
13685
- // this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'mousedown').subscribe((evt) => {
13686
- // this.mousedown(evt);
13687
- // }));
13688
- // this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'mouseup').subscribe((evt) => {
13689
- // this.mouseup(evt);
13690
- // }));
13691
- // this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'click').subscribe((evt) => {
13692
- // this.mouseClickHandle(evt);
13693
- // }));
13694
- // this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'contextmenu').subscribe((evt) => {
13695
- // this.contextMenu.next(evt);
13696
- // }));
13697
- // this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'mousemove').subscribe((evt) => {
13698
- // this.mousemove(evt);
13699
- // }));
13700
- // this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'dblclick').subscribe((evt) => {
13701
- // this.mouseDblClickHandle(evt);
13702
- // }));
13703
13685
  this.documentInput.onLeftEvent.subscribe(() => {
13704
13686
  this.moveCursorToLeft();
13705
13687
  });
@@ -14443,17 +14425,27 @@ class DocumentEvent {
14443
14425
  const moveDistanceX = this.currentPos.x - mousedownPos.x;
14444
14426
  const moveDistanceY = this.currentPos.y - mousedownPos.y;
14445
14427
  const row = cellElement.parent;
14428
+ const minColWidth = 20;
14446
14429
  const table = row?.parent;
14447
14430
  if (!row || !table) {
14448
14431
  throw new Error('row | table is null');
14449
14432
  }
14450
14433
  const cellIndex = row.getChildIndex(cellElement);
14451
14434
  let cellWidth = table.getCellWidth(cellIndex);
14452
- table.getColsCount();
14453
14435
  if (['left', 'right'].includes(border)) {
14454
14436
  if (cellIndex === 0 && border === 'left') {
14455
14437
  return;
14456
14438
  }
14439
+ //当前操作的是表格的最后一列
14440
+ if (cellIndex === table.getColsCount() - 1 && border === 'right') {
14441
+ cellWidth += moveDistanceX;
14442
+ if (cellWidth < minColWidth) {
14443
+ return;
14444
+ }
14445
+ table.setCellWidth(cellIndex, cellWidth);
14446
+ this.edgeRenderInfo.mousedownPos = this.currentPos;
14447
+ return;
14448
+ }
14457
14449
  let resizeColWidth = 0;
14458
14450
  let resizeColIndex = 0;
14459
14451
  if (border === 'left') {
@@ -14471,14 +14463,13 @@ class DocumentEvent {
14471
14463
  }
14472
14464
  cellWidth += moveDistanceX;
14473
14465
  }
14474
- if (resizeColWidth < 20 || cellWidth < 20) {
14466
+ if (resizeColWidth < minColWidth || cellWidth < minColWidth) {
14475
14467
  return;
14476
14468
  }
14477
14469
  console.log(resizeColWidth, cellWidth);
14478
14470
  table.setCellWidth(resizeColIndex, resizeColWidth);
14479
14471
  table.setCellWidth(cellIndex, cellWidth);
14480
14472
  this.edgeRenderInfo.mousedownPos = this.currentPos;
14481
- table.pubOnChange('self');
14482
14473
  }
14483
14474
  else if (['bottom', 'top'].includes(border)) {
14484
14475
  let rowIndex = row.getIndex();
@@ -21142,6 +21133,36 @@ class CanvasTextEditor extends AbsolutePanel {
21142
21133
  appCtx.root.setInputPosition(caretPos);
21143
21134
  }
21144
21135
  }
21136
+ generatorDoc(data) {
21137
+ //根据传入的参数,动态生成病情信息的结构化报告
21138
+ const para = new ParagraphElement();
21139
+ //创建患者姓名文本标签
21140
+ const patNameLabel = new TextGroupElement();
21141
+ patNameLabel.text = "患者姓名:";
21142
+ //添加到段落中
21143
+ para.addChild(patNameLabel);
21144
+ //创建患者姓名数据元
21145
+ const patNameDataEle = new DataElementText();
21146
+ patNameDataEle.props.valueTextProps = new TextProps();
21147
+ patNameDataEle.props.valueTextProps.fontName = '宋体';
21148
+ patNameDataEle.props.valueTextProps.fontSize = 16;
21149
+ //数据元赋值
21150
+ patNameDataEle.setValue(data.patName);
21151
+ //添加到段落中
21152
+ para.addChild(patNameDataEle);
21153
+ //添加到正文中
21154
+ this.docCtx.document.bodyElement.addChild(para);
21155
+ }
21156
+ /**
21157
+ * 设置关键字
21158
+ * 匹配用户输入的关键字,回调到应用业务中处理
21159
+ */
21160
+ setKeywords(keys, cb) {
21161
+ }
21162
+ /**
21163
+ * 注册编辑器格式读取器
21164
+ */
21165
+ registerReaderFactory(handler) { }
21145
21166
  }
21146
21167
 
21147
21168
  /**