@talrace/ngx-noder 19.0.69 → 19.0.70

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.
@@ -12566,6 +12566,22 @@ class RegulatorService {
12566
12566
  });
12567
12567
  this.sessions = [];
12568
12568
  }
12569
+ getIndexWithinMainSession() {
12570
+ if (this.currentSession.session.isEdgeOrWithinEdge()) {
12571
+ return 0; // currently there is no mechanism to track pages and get position according valid page for edge
12572
+ }
12573
+ let session = this.currentSession;
12574
+ while (session.parentSessionId) {
12575
+ const parent = this.sessions.find(x => x.sessionId === session.parentSessionId);
12576
+ if (parent.parentSessionId) {
12577
+ session = parent;
12578
+ }
12579
+ else {
12580
+ break;
12581
+ }
12582
+ }
12583
+ return session.source.table.insertIndex;
12584
+ }
12569
12585
  getCurrentSessionTargets() {
12570
12586
  return this.getTargets(this.currentSession);
12571
12587
  }
@@ -12763,7 +12779,7 @@ class NoderTableCellComponent {
12763
12779
  return;
12764
12780
  }
12765
12781
  this._allParagraphsHeight = event.pageHeight;
12766
- this.heightChanged(this.rowIndex, this.cellIndex, event.pageHeight);
12782
+ this.heightChanged(this.rowIndex, this.columnIndex, event.pageHeight);
12767
12783
  };
12768
12784
  }
12769
12785
  ngOnDestroy() {
@@ -13157,7 +13173,8 @@ class TableSelection {
13157
13173
  return;
13158
13174
  }
13159
13175
  const position = this.regulatorService.currentSession.renderer.screenToParagraph(event.clientX, event.clientY);
13160
- if (!this.session.selection.isEmpty && this.session.isPositionInRange(position, this.session.selection.selectedRange)) {
13176
+ if (!this.session.selection.isEmpty &&
13177
+ this.regulatorService.currentSession.session.isPositionInRange(position, this.session.selection.selectedRange)) {
13161
13178
  return;
13162
13179
  }
13163
13180
  this.overlayService.close();
@@ -13507,36 +13524,32 @@ class NoderTableComponent extends BaseNoderComponent {
13507
13524
  this.regulatorService = regulatorService;
13508
13525
  this.rowMatrix = [];
13509
13526
  this.splits = [];
13510
- this.minRowHeight = 19;
13527
+ this.minRowHeight = 18;
13511
13528
  this.borderSize = 1;
13512
13529
  this.RESIZE_MIN_OFFSET = 5;
13513
13530
  this.startResizing = (cellResizerParameters) => {
13514
- const splitRowIndex = this.getSplitRowIndex(cellResizerParameters.rowIndex);
13515
13531
  const availableTableSpace = this.getAvailableTableSpace();
13516
- this.resizer.resizerHeight = this.getRowsHeightBetweenSplits(splitRowIndex);
13517
- this.resizer.startY = this.getRowsHeightBefore(splitRowIndex);
13518
- this.resizer.splitRowIndex = splitRowIndex;
13532
+ this.resizer.resizerHeight = this.getRowsHeightBetweenSplits(cellResizerParameters.rowIndex);
13533
+ this.resizer.startY = this.getRowsHeightBefore(cellResizerParameters.rowIndex);
13534
+ this.resizer.splitRowIndex = cellResizerParameters.rowIndex;
13519
13535
  this.resizer.tableInsertIndex = this.insertIndex;
13520
13536
  this.resizer.onStartResizing(cellResizerParameters, availableTableSpace);
13521
13537
  };
13522
- this.cellHeightChanged = (rowIndex, cellIndex, height) => {
13523
- const tableRow = this.table.rows[rowIndex];
13524
- this.rowMatrix[rowIndex].cells[cellIndex].cellContentHeight = height < this.minRowHeight ? this.minRowHeight : height;
13525
- if (tableRow.hRule === HRule.Exact) {
13526
- return;
13527
- }
13528
- const rowIndexWithSplit = this.getIndexIncludingSplitRows(this.rowMatrix[rowIndex].row);
13529
- const row = this.tableEl.rows[rowIndexWithSplit];
13530
- const currentHeight = row.offsetHeight;
13531
- const cellHeights = this.rowMatrix[rowIndex].cells.map(x => x.cellContentHeight);
13532
- const maxCellContentHeigh = Math.max(...cellHeights, height);
13533
- if (maxCellContentHeigh > currentHeight ||
13534
- (maxCellContentHeigh < currentHeight && (!tableRow.height || tableRow.height <= maxCellContentHeigh))) {
13535
- row.style.height = `${maxCellContentHeigh}px`;
13536
- this.rowMatrix[rowIndex].height = maxCellContentHeigh;
13537
- this.setTableHeight();
13538
- this.editorService.changedTableSize(this.insertIndex, this.sessionId);
13538
+ this.cellHeightChanged = (rowIndex, columnIndex, height) => {
13539
+ height = height < this.minRowHeight ? this.minRowHeight : height;
13540
+ let index = rowIndex;
13541
+ do {
13542
+ for (let i = columnIndex; this.rowMatrix[index].cells[columnIndex].cell === this.rowMatrix[index].cells[i]?.cell; i++) {
13543
+ this.rowMatrix[index].cells[i].cellContentHeight = height;
13544
+ }
13545
+ index++;
13546
+ } while (this.rowMatrix[index - 1].cells[columnIndex].cell === this.rowMatrix[index]?.cells[columnIndex].cell);
13547
+ let isAdjustable = true;
13548
+ for (let i = rowIndex; isAdjustable && i < this.table.rows.length; i++) {
13549
+ isAdjustable = this.fillTableRow(i);
13539
13550
  }
13551
+ this.setTableHeight();
13552
+ this.editorService.changedTableSize(this.insertIndex, this.sessionId);
13540
13553
  };
13541
13554
  }
13542
13555
  ngOnDestroy() {
@@ -13606,7 +13619,9 @@ class NoderTableComponent extends BaseNoderComponent {
13606
13619
  this.insertCells(targetRowIndex, this.table.rows[targetRowIndex].cells.length, 0);
13607
13620
  rowIndex++;
13608
13621
  }
13609
- this.fillTableRow();
13622
+ for (let i = 0; i < this.table.rows.length; i++) {
13623
+ this.fillTableRow(i);
13624
+ }
13610
13625
  }
13611
13626
  insertCells(rowIndex, cellsCount, targetIndex) {
13612
13627
  let modelTargetIndex = this.getModelTargetIndex(rowIndex, targetIndex);
@@ -13689,49 +13704,56 @@ class NoderTableComponent extends BaseNoderComponent {
13689
13704
  }
13690
13705
  this.tableEl.insertAdjacentElement('afterbegin', colgroup);
13691
13706
  }
13692
- fillTableRow() {
13693
- for (let i = 0; i < this.table.rows.length; i++) {
13694
- switch (this.table.rows[i].hRule) {
13695
- case HRule.AtLeast: {
13696
- const rowHeight = this.getRowHeight(i);
13697
- this.tableEl.rows[i].style.minHeight = `${this.table.rows[i].height}px`;
13698
- this.tableEl.rows[i].style.height = `${rowHeight}px`;
13699
- this.rowMatrix[i].height = rowHeight;
13700
- break;
13701
- }
13702
- case HRule.Exact:
13703
- this.tableEl.rows[i].style.height = `${this.table.rows[i].height}px`;
13704
- this.rowMatrix[i].height = this.table.rows[i].height;
13705
- break;
13706
- default: {
13707
- const rowHeight = this.getRowHeight(i);
13708
- const minRowHeight = this.table.rows[i].height ?? this.minRowHeight;
13709
- const resultHeight = minRowHeight > rowHeight ? minRowHeight : rowHeight;
13710
- this.tableEl.rows[i].style.height = `${resultHeight}px`;
13711
- this.rowMatrix[i].height = resultHeight;
13712
- break;
13713
- }
13707
+ fillTableRow(rowIndex) {
13708
+ switch (this.table.rows[rowIndex].hRule) {
13709
+ case HRule.AtLeast: {
13710
+ const { rowHeight, hasMerges } = this.getRowHeight(rowIndex);
13711
+ this.tableEl.rows[rowIndex].style.minHeight = `${this.table.rows[rowIndex].height}px`;
13712
+ this.tableEl.rows[rowIndex].style.height = `${rowHeight}px`;
13713
+ this.rowMatrix[rowIndex].height = rowHeight;
13714
+ return hasMerges;
13715
+ }
13716
+ case HRule.Exact:
13717
+ this.tableEl.rows[rowIndex].style.height = `${this.table.rows[rowIndex].height}px`;
13718
+ this.rowMatrix[rowIndex].height = this.table.rows[rowIndex].height;
13719
+ return false;
13720
+ default: {
13721
+ const { rowHeight, hasMerges } = this.getRowHeight(rowIndex);
13722
+ const minRowHeight = this.table.rows[rowIndex].height ?? this.minRowHeight;
13723
+ const resultHeight = minRowHeight > rowHeight ? minRowHeight : rowHeight;
13724
+ this.tableEl.rows[rowIndex].style.height = `${resultHeight}px`;
13725
+ this.rowMatrix[rowIndex].height = resultHeight;
13726
+ return hasMerges;
13714
13727
  }
13715
13728
  }
13716
13729
  }
13717
13730
  getRowHeight(rowIndex) {
13718
- const cellHeights = this.rowMatrix[rowIndex].cells.map((x, index) => {
13719
- if (x.componentRef.instance.cell.verticalMerge === VerticalMerge.Restart) {
13720
- const isLastVerticalMergedCell = x.cell !== this.rowMatrix[rowIndex + 1]?.cells[index].cell;
13721
- if (isLastVerticalMergedCell) {
13722
- let i = rowIndex - 1;
13723
- let currentHeight = x.cellContentHeight;
13724
- while (x.cell === this.rowMatrix[i]?.cells[index].cell) {
13725
- currentHeight -= this.rowMatrix[i].height;
13726
- i--;
13727
- }
13728
- return currentHeight;
13729
- }
13730
- return 0;
13731
+ let rowHeight = 0;
13732
+ let hasMerges = false;
13733
+ this.rowMatrix[rowIndex].cells.forEach((x, index) => {
13734
+ const { height, isMerged } = this.getCellHeight(rowIndex, index, x);
13735
+ hasMerges = hasMerges || isMerged;
13736
+ if (rowHeight < height) {
13737
+ rowHeight = height;
13731
13738
  }
13732
- return x.cellContentHeight;
13733
13739
  });
13734
- return Math.max(...cellHeights);
13740
+ return { rowHeight, hasMerges };
13741
+ }
13742
+ getCellHeight(rowIndex, cellIndex, cell) {
13743
+ if (cell.componentRef.instance.cell.verticalMerge === VerticalMerge.Restart) {
13744
+ const isLastVerticalMergedCell = cell.cell !== this.rowMatrix[rowIndex + 1]?.cells[cellIndex].cell;
13745
+ if (isLastVerticalMergedCell) {
13746
+ let i = rowIndex - 1;
13747
+ let currentHeight = cell.cellContentHeight;
13748
+ while (cell.cell === this.rowMatrix[i]?.cells[cellIndex].cell) {
13749
+ currentHeight -= this.rowMatrix[i].height;
13750
+ i--;
13751
+ }
13752
+ return { height: currentHeight, isMerged: false };
13753
+ }
13754
+ return { height: 0, isMerged: true };
13755
+ }
13756
+ return { height: cell.cellContentHeight, isMerged: false };
13735
13757
  }
13736
13758
  fillTableCells() {
13737
13759
  for (let i = 0; i < this.rowMatrix.length; i++) {
@@ -13840,12 +13862,6 @@ class NoderTableComponent extends BaseNoderComponent {
13840
13862
  getTableWidth() {
13841
13863
  return this.table.columns.reduce((prev, next) => prev + next.width + this.borderSize, 1);
13842
13864
  }
13843
- getSplitRowIndex(rowIndex) {
13844
- return this.getIndexIncludingSplitRows(this.rowMatrix[rowIndex].row);
13845
- }
13846
- getIndexIncludingSplitRows(row) {
13847
- return Array.from(this.tableEl.rows).indexOf(row);
13848
- }
13849
13865
  getRowsHeightBefore(rowIndex) {
13850
13866
  let index = 0;
13851
13867
  for (const element of this.splits) {
@@ -17137,11 +17153,13 @@ class Editor {
17137
17153
  }
17138
17154
  this.regulatorService.updateCursorPosition();
17139
17155
  this.editorService.setHasSelection(!this.selection.isEmpty);
17140
- const position = this.mainSession.displayData.positionToIndex(this.selection.selectedRange.start);
17141
- const pageFormat = this.mainSession.displayData.getPageFormatAtPosition(position);
17142
17156
  const paragraphStyle = this.session.model.paragraphs[this.selection.selectedRange.start.row].paragraphStyle;
17143
17157
  const numbering = this.session.generalProperties.numberings.find(x => x.numberingId === paragraphStyle.numberingId) ?? null;
17144
17158
  this.editorService.paragraphStyle(paragraphStyle, numbering);
17159
+ const position = this.session === this.mainSession
17160
+ ? this.mainSession.displayData.positionToIndex(this.selection.selectedRange.start)
17161
+ : this.regulatorService.getIndexWithinMainSession();
17162
+ const pageFormat = this.mainSession.displayData.getPageFormatAtPosition(position);
17145
17163
  this.editorService.setPageFormat(pageFormat.pageFormatModel);
17146
17164
  this.rerenderMarker();
17147
17165
  this.regulatorService.setSelectedCommentAtCursor();