@hailin-zheng/editor-core 1.1.7 → 1.1.9

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
@@ -4317,6 +4317,13 @@ class TableUtil {
4317
4317
  currCell.props.vMerge = i === tbRegion.startRow ? 'restart' : 'continue';
4318
4318
  currCell.props.hMerge = 'restart';
4319
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
+ }
4320
4327
  if (currCell !== startCell) {
4321
4328
  cellContents.push(...ElementUtil.getChildrenElements(currCell));
4322
4329
  currCell.clearItems();
@@ -4456,6 +4463,13 @@ class TableUtil {
4456
4463
  tb.pubOnChange('self');
4457
4464
  tb.refreshView();
4458
4465
  }
4466
+ /**
4467
+ * 在指定位置插入行
4468
+ * 动作:在指定行上方或者下方插入行
4469
+ * 原则:插入的行单元格尽量不纵向合并
4470
+ * @param ss
4471
+ * @param insertRowIndex
4472
+ */
4459
4473
  static insertRow(ss, insertRowIndex) {
4460
4474
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
4461
4475
  if (!startCell?.parent) {
@@ -4463,7 +4477,7 @@ class TableUtil {
4463
4477
  }
4464
4478
  const startRow = startCell.parent;
4465
4479
  const tb = startRow.parent;
4466
- const currRowIndex = startRow.getIndex();
4480
+ startRow.getIndex();
4467
4481
  insertRowIndex = insertRowIndex < 0 ? 0 : insertRowIndex;
4468
4482
  insertRowIndex = insertRowIndex > tb.length ? tb.length : insertRowIndex;
4469
4483
  const newRow = TableRowElement.createRow(tb.getColsCount());
@@ -4481,16 +4495,12 @@ class TableUtil {
4481
4495
  if (destCell.props.vMerge === 'continue') {
4482
4496
  //获取合并列的最后的行索引
4483
4497
  const vMergeEndRowIndex = this.getVMergeEndIndex(tb, insertRowIndex, i);
4484
- if (vMergeEndRowIndex > insertRowIndex || (vMergeEndRowIndex === insertRowIndex && currRowIndex < insertRowIndex)) {
4498
+ //当前单元格处于纵向合并的单元格之中
4499
+ if (vMergeEndRowIndex >= insertRowIndex) {
4485
4500
  newCell.props.vMerge = 'continue';
4486
- //newCell.cellProps.hMerge = destCell.cellProps.hMerge;
4487
4501
  }
4488
4502
  }
4489
- else if (destCell.props.vMerge === 'restart' && currRowIndex > insertRowIndex) {
4490
- //在上方新增行,目标行单元格属于合并的起点
4491
- newCell.props.vMerge = 'continue';
4492
- //newCell.cellProps.hMerge = destCell.cellProps.hMerge;
4493
- }
4503
+ newCell.props.hMerge = destCell.props.hMerge;
4494
4504
  }
4495
4505
  tb.addChild(newRow, insertRowIndex);
4496
4506
  tb.refreshView();
@@ -11348,6 +11358,10 @@ class ParagraphMeasure {
11348
11358
  }
11349
11359
  else if (paraElement.props.textAlign === 'justify') {
11350
11360
  const renderUnitCount = this.getRenderUnitLength(paraLineRender.line);
11361
+ if (paraLineIndex === counter - 1 || renderUnitCount === 1) {
11362
+ return;
11363
+ //return indent;
11364
+ }
11351
11365
  const spaceWidth = (limitWidth - paraLineRender.line.rect.width) / (renderUnitCount - 1);
11352
11366
  this.setAlignJustify(paraLineRender.line, 0, spaceWidth);
11353
11367
  //return indent;
@@ -15865,12 +15879,14 @@ class DocumentChange {
15865
15879
  }
15866
15880
  /**
15867
15881
  * 根据开始位置和结束位置,将字符切割成指定的区间
15868
- * @param splitTextUnit
15882
+ * @param text
15869
15883
  * @param start
15870
15884
  * @param end
15871
15885
  * @returns
15872
15886
  */
15873
15887
  static splitTextGroupByRange(text, start, end) {
15888
+ start = Math.floor(start);
15889
+ end = Math.floor(end);
15874
15890
  end = end === -1 ? text.textMeasures.length : end;
15875
15891
  if (start === end) {
15876
15892
  return null;