el-header-and-footer 0.0.52 → 0.0.53

Sign up to get free protection for your applications and to get access to all the features.
@@ -659,24 +659,68 @@ class ElHeaderAndFooterComponent {
659
659
  // }
660
660
  // }
661
661
  // }
662
+ // addColumn() {
663
+ // if (this.selectedTable) {
664
+ // const columnCount = this.selectedTable.rows[0].cells.length + 1; // New column count
665
+ // const tableWidth = this.selectedTable.offsetWidth;
666
+ // const minWidth = tableWidth / columnCount;
667
+ // for (let i = 0; i < this.selectedTable.rows.length; i++) {
668
+ // let cell = this.selectedTable.rows[i].insertCell(-1);
669
+ // cell.innerHTML = '&nbsp;';
670
+ // cell.style.border = this.themeModeClrVerticalLineForTable();
671
+ // cell.style.minWidth = `${minWidth}px`;
672
+ // cell.style.wordWrap = 'break-word';
673
+ // cell.style.wordBreak = 'break-all';
674
+ // cell.style.whiteSpace = 'normal';
675
+ // }
676
+ // // Update existing cells' minWidth
677
+ // for (let i = 0; i < this.selectedTable.rows.length; i++) {
678
+ // for (let j = 0; j < this.selectedTable.rows[i].cells.length; j++) {
679
+ // this.selectedTable.rows[i].cells[j].style.minWidth = `${minWidth}px`;
680
+ // }
681
+ // }
682
+ // }
683
+ // }
684
+ // deleteColumn() {
685
+ // if (this.selectedTable) {
686
+ // if (window.getSelection) {
687
+ // let selection = window.getSelection();
688
+ // if (selection) {
689
+ // let cell = selection.anchorNode?.parentElement?.closest('td, th') as HTMLTableCellElement;
690
+ // if (cell) {
691
+ // let cellIndex = cell.cellIndex;
692
+ // for (let i = 0; i < this.selectedTable.rows.length; i++) {
693
+ // this.selectedTable.rows[i].deleteCell(cellIndex);
694
+ // }
695
+ // }
696
+ // }
697
+ // }
698
+ // }
699
+ // }
662
700
  addColumn() {
663
701
  if (this.selectedTable) {
664
- const columnCount = this.selectedTable.rows[0].cells.length + 1; // New column count
702
+ const columnCount = this.selectedTable.rows[0].cells.length; // Get current column count
703
+ if (columnCount >= 3) {
704
+ console.warn("Maximum column limit (3) reached!");
705
+ return; // Stop adding columns if the limit is reached
706
+ }
707
+ const newColumnCount = columnCount + 1; // New column count after adding
665
708
  const tableWidth = this.selectedTable.offsetWidth;
666
- const minWidth = tableWidth / columnCount;
709
+ const minWidth = tableWidth / newColumnCount;
667
710
  for (let i = 0; i < this.selectedTable.rows.length; i++) {
668
711
  let cell = this.selectedTable.rows[i].insertCell(-1);
669
712
  cell.innerHTML = '&nbsp;';
670
- cell.style.border = this.themeModeClrVerticalLineForTable();
713
+ cell.style.border = `1px solid #000`; // Set border color (Black)
671
714
  cell.style.minWidth = `${minWidth}px`;
672
715
  cell.style.wordWrap = 'break-word';
673
716
  cell.style.wordBreak = 'break-all';
674
717
  cell.style.whiteSpace = 'normal';
675
718
  }
676
- // Update existing cells' minWidth
719
+ // Update existing cells' minWidth and border color
677
720
  for (let i = 0; i < this.selectedTable.rows.length; i++) {
678
721
  for (let j = 0; j < this.selectedTable.rows[i].cells.length; j++) {
679
722
  this.selectedTable.rows[i].cells[j].style.minWidth = `${minWidth}px`;
723
+ this.selectedTable.rows[i].cells[j].style.border = `1px solid${this.themeModeClrBorderForTable()}`; // Apply border color
680
724
  }
681
725
  }
682
726
  }
@@ -684,6 +728,11 @@ class ElHeaderAndFooterComponent {
684
728
  deleteColumn() {
685
729
  var _a, _b;
686
730
  if (this.selectedTable) {
731
+ const columnCount = this.selectedTable.rows[0].cells.length; // Get current column count
732
+ if (columnCount <= 1) {
733
+ console.warn("Cannot delete the last column!");
734
+ return; // Stop deleting if only one column is left
735
+ }
687
736
  if (window.getSelection) {
688
737
  let selection = window.getSelection();
689
738
  if (selection) {