@hailin-zheng/editor-core 1.1.6 → 1.1.8
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 +67 -36
- package/index-cjs.js.map +1 -1
- package/index.js +67 -36
- package/index.js.map +1 -1
- package/med_editor/framework/element-serialize.d.ts +5 -0
- package/med_editor/framework/impl/table/table-util.d.ts +7 -0
- package/med_editor/texteditor.d.ts +12 -0
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -4201,15 +4201,10 @@ class TableUtil {
|
|
4201
4201
|
const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
|
4202
4202
|
if (vMergeEndIndex > rowIndex) {
|
4203
4203
|
const nextRow = tb.getChild(rowIndex + 1);
|
4204
|
-
nextRow.getChild(i).props.vMerge = vMergeEndIndex - rowIndex >
|
4204
|
+
nextRow.getChild(i).props.vMerge = vMergeEndIndex - rowIndex > 1 ? 'restart' : null;
|
4205
4205
|
}
|
4206
4206
|
}
|
4207
4207
|
else if (cell.props.vMerge === 'continue') {
|
4208
|
-
// const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
|
4209
|
-
// if (vMergeEndIndex > rowIndex) {
|
4210
|
-
// const nextRow = tb.getChild<TableRowElement>(rowIndex + 1);
|
4211
|
-
// nextRow.getChild<TableCellElement>(i).cellProps.vMerge = 'continue';
|
4212
|
-
// }
|
4213
4208
|
const vMergeStartIndex = this.getVMergeStartIndex(tb, rowIndex, i);
|
4214
4209
|
const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
|
4215
4210
|
//当前单元格处于合并行的最后一行,并且合并的行数为2行
|
@@ -4322,6 +4317,13 @@ class TableUtil {
|
|
4322
4317
|
currCell.props.vMerge = i === tbRegion.startRow ? 'restart' : 'continue';
|
4323
4318
|
currCell.props.hMerge = 'restart';
|
4324
4319
|
}
|
4320
|
+
//选择的行数一行,此时纵向合并不需要设置
|
4321
|
+
if (tbRegion.endRow === tbRegion.startRow) {
|
4322
|
+
currCell.props.vMerge = null;
|
4323
|
+
}
|
4324
|
+
if (tbRegion.startCol === tbRegion.endCol) {
|
4325
|
+
currCell.props.hMerge = null;
|
4326
|
+
}
|
4325
4327
|
if (currCell !== startCell) {
|
4326
4328
|
cellContents.push(...ElementUtil.getChildrenElements(currCell));
|
4327
4329
|
currCell.clearItems();
|
@@ -4461,6 +4463,13 @@ class TableUtil {
|
|
4461
4463
|
tb.pubOnChange('self');
|
4462
4464
|
tb.refreshView();
|
4463
4465
|
}
|
4466
|
+
/**
|
4467
|
+
* 在指定位置插入行
|
4468
|
+
* 动作:在指定行上方或者下方插入行
|
4469
|
+
* 原则:插入的行单元格尽量不纵向合并
|
4470
|
+
* @param ss
|
4471
|
+
* @param insertRowIndex
|
4472
|
+
*/
|
4464
4473
|
static insertRow(ss, insertRowIndex) {
|
4465
4474
|
const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
4466
4475
|
if (!startCell?.parent) {
|
@@ -4468,7 +4477,7 @@ class TableUtil {
|
|
4468
4477
|
}
|
4469
4478
|
const startRow = startCell.parent;
|
4470
4479
|
const tb = startRow.parent;
|
4471
|
-
|
4480
|
+
startRow.getIndex();
|
4472
4481
|
insertRowIndex = insertRowIndex < 0 ? 0 : insertRowIndex;
|
4473
4482
|
insertRowIndex = insertRowIndex > tb.length ? tb.length : insertRowIndex;
|
4474
4483
|
const newRow = TableRowElement.createRow(tb.getColsCount());
|
@@ -4486,16 +4495,12 @@ class TableUtil {
|
|
4486
4495
|
if (destCell.props.vMerge === 'continue') {
|
4487
4496
|
//获取合并列的最后的行索引
|
4488
4497
|
const vMergeEndRowIndex = this.getVMergeEndIndex(tb, insertRowIndex, i);
|
4489
|
-
|
4498
|
+
//当前单元格处于纵向合并的单元格之中
|
4499
|
+
if (vMergeEndRowIndex >= insertRowIndex) {
|
4490
4500
|
newCell.props.vMerge = 'continue';
|
4491
|
-
//newCell.cellProps.hMerge = destCell.cellProps.hMerge;
|
4492
4501
|
}
|
4493
4502
|
}
|
4494
|
-
|
4495
|
-
//在上方新增行,目标行单元格属于合并的起点
|
4496
|
-
newCell.props.vMerge = 'continue';
|
4497
|
-
//newCell.cellProps.hMerge = destCell.cellProps.hMerge;
|
4498
|
-
}
|
4503
|
+
newCell.props.hMerge = destCell.props.hMerge;
|
4499
4504
|
}
|
4500
4505
|
tb.addChild(newRow, insertRowIndex);
|
4501
4506
|
tb.refreshView();
|
@@ -5196,6 +5201,11 @@ class TextGroupFactory extends ElementFactory {
|
|
5196
5201
|
}
|
5197
5202
|
|
5198
5203
|
class ElementSerialize {
|
5204
|
+
/**
|
5205
|
+
* 将当前文档对象构建并输出到标准的JSON对象
|
5206
|
+
* @param element
|
5207
|
+
* @param viewOptions
|
5208
|
+
*/
|
5199
5209
|
static serialize(element, viewOptions) {
|
5200
5210
|
if (element instanceof BranchElement) {
|
5201
5211
|
const result = element.serialize(viewOptions);
|
@@ -7996,7 +8006,7 @@ class DataElementDate extends DataElementInlineGroup {
|
|
7996
8006
|
return res;
|
7997
8007
|
}
|
7998
8008
|
const format = this.props.format ?? 'YYYY-MM-DD';
|
7999
|
-
const date = moment__default["default"](this.getValue(), format);
|
8009
|
+
const date = moment__default["default"](this.getValue(), format, true);
|
8000
8010
|
if (!date.isValid()) {
|
8001
8011
|
return '日期格式不正确';
|
8002
8012
|
}
|
@@ -13711,24 +13721,6 @@ class DocumentEvent {
|
|
13711
13721
|
this.editor.addEventListener('contextmenu', evt => {
|
13712
13722
|
this.contextMenu.next(evt.sourceEvt);
|
13713
13723
|
});
|
13714
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'mousedown').subscribe((evt) => {
|
13715
|
-
// this.mousedown(evt);
|
13716
|
-
// }));
|
13717
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'mouseup').subscribe((evt) => {
|
13718
|
-
// this.mouseup(evt);
|
13719
|
-
// }));
|
13720
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'click').subscribe((evt) => {
|
13721
|
-
// this.mouseClickHandle(evt);
|
13722
|
-
// }));
|
13723
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'contextmenu').subscribe((evt) => {
|
13724
|
-
// this.contextMenu.next(evt);
|
13725
|
-
// }));
|
13726
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'mousemove').subscribe((evt) => {
|
13727
|
-
// this.mousemove(evt);
|
13728
|
-
// }));
|
13729
|
-
// this.addSubEvent(fromEvent<MouseEvent>(this.canvas, 'dblclick').subscribe((evt) => {
|
13730
|
-
// this.mouseDblClickHandle(evt);
|
13731
|
-
// }));
|
13732
13724
|
this.documentInput.onLeftEvent.subscribe(() => {
|
13733
13725
|
this.moveCursorToLeft();
|
13734
13726
|
});
|
@@ -14472,17 +14464,27 @@ class DocumentEvent {
|
|
14472
14464
|
const moveDistanceX = this.currentPos.x - mousedownPos.x;
|
14473
14465
|
const moveDistanceY = this.currentPos.y - mousedownPos.y;
|
14474
14466
|
const row = cellElement.parent;
|
14467
|
+
const minColWidth = 20;
|
14475
14468
|
const table = row?.parent;
|
14476
14469
|
if (!row || !table) {
|
14477
14470
|
throw new Error('row | table is null');
|
14478
14471
|
}
|
14479
14472
|
const cellIndex = row.getChildIndex(cellElement);
|
14480
14473
|
let cellWidth = table.getCellWidth(cellIndex);
|
14481
|
-
table.getColsCount();
|
14482
14474
|
if (['left', 'right'].includes(border)) {
|
14483
14475
|
if (cellIndex === 0 && border === 'left') {
|
14484
14476
|
return;
|
14485
14477
|
}
|
14478
|
+
//当前操作的是表格的最后一列
|
14479
|
+
if (cellIndex === table.getColsCount() - 1 && border === 'right') {
|
14480
|
+
cellWidth += moveDistanceX;
|
14481
|
+
if (cellWidth < minColWidth) {
|
14482
|
+
return;
|
14483
|
+
}
|
14484
|
+
table.setCellWidth(cellIndex, cellWidth);
|
14485
|
+
this.edgeRenderInfo.mousedownPos = this.currentPos;
|
14486
|
+
return;
|
14487
|
+
}
|
14486
14488
|
let resizeColWidth = 0;
|
14487
14489
|
let resizeColIndex = 0;
|
14488
14490
|
if (border === 'left') {
|
@@ -14500,14 +14502,13 @@ class DocumentEvent {
|
|
14500
14502
|
}
|
14501
14503
|
cellWidth += moveDistanceX;
|
14502
14504
|
}
|
14503
|
-
if (resizeColWidth <
|
14505
|
+
if (resizeColWidth < minColWidth || cellWidth < minColWidth) {
|
14504
14506
|
return;
|
14505
14507
|
}
|
14506
14508
|
console.log(resizeColWidth, cellWidth);
|
14507
14509
|
table.setCellWidth(resizeColIndex, resizeColWidth);
|
14508
14510
|
table.setCellWidth(cellIndex, cellWidth);
|
14509
14511
|
this.edgeRenderInfo.mousedownPos = this.currentPos;
|
14510
|
-
table.pubOnChange('self');
|
14511
14512
|
}
|
14512
14513
|
else if (['bottom', 'top'].includes(border)) {
|
14513
14514
|
let rowIndex = row.getIndex();
|
@@ -21171,6 +21172,36 @@ class CanvasTextEditor extends AbsolutePanel {
|
|
21171
21172
|
appCtx.root.setInputPosition(caretPos);
|
21172
21173
|
}
|
21173
21174
|
}
|
21175
|
+
generatorDoc(data) {
|
21176
|
+
//根据传入的参数,动态生成病情信息的结构化报告
|
21177
|
+
const para = new ParagraphElement();
|
21178
|
+
//创建患者姓名文本标签
|
21179
|
+
const patNameLabel = new TextGroupElement();
|
21180
|
+
patNameLabel.text = "患者姓名:";
|
21181
|
+
//添加到段落中
|
21182
|
+
para.addChild(patNameLabel);
|
21183
|
+
//创建患者姓名数据元
|
21184
|
+
const patNameDataEle = new DataElementText();
|
21185
|
+
patNameDataEle.props.valueTextProps = new TextProps();
|
21186
|
+
patNameDataEle.props.valueTextProps.fontName = '宋体';
|
21187
|
+
patNameDataEle.props.valueTextProps.fontSize = 16;
|
21188
|
+
//数据元赋值
|
21189
|
+
patNameDataEle.setValue(data.patName);
|
21190
|
+
//添加到段落中
|
21191
|
+
para.addChild(patNameDataEle);
|
21192
|
+
//添加到正文中
|
21193
|
+
this.docCtx.document.bodyElement.addChild(para);
|
21194
|
+
}
|
21195
|
+
/**
|
21196
|
+
* 设置关键字
|
21197
|
+
* 匹配用户输入的关键字,回调到应用业务中处理
|
21198
|
+
*/
|
21199
|
+
setKeywords(keys, cb) {
|
21200
|
+
}
|
21201
|
+
/**
|
21202
|
+
* 注册编辑器格式读取器
|
21203
|
+
*/
|
21204
|
+
registerReaderFactory(handler) { }
|
21174
21205
|
}
|
21175
21206
|
|
21176
21207
|
/**
|