el-text-editor 0.0.29 → 0.0.31
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.
@@ -772,20 +772,41 @@ class ElTextEditorComponent {
|
|
772
772
|
reader.readAsDataURL(file);
|
773
773
|
}
|
774
774
|
}
|
775
|
+
// addTable() {
|
776
|
+
// const tableWidth = 825; // Table width in pixels
|
777
|
+
// const cols = 3; // Number of columns
|
778
|
+
// const cellMinWidth = tableWidth / cols; // Calculate minimum width for each cell
|
779
|
+
// let table = `<br /><table style="width: ${tableWidth}px;">`;
|
780
|
+
// for (let i = 0; i < 3; i++) { // Number of rows
|
781
|
+
// table += '<tr >';
|
782
|
+
// for (let j = 0; j < cols; j++) {
|
783
|
+
// table += `<td style=" word-wrap: break-word; word-break: break-all; white-space: normal; min-width: ${cellMinWidth}px;"> </td>`;
|
784
|
+
// }
|
785
|
+
// table += '</tr>';
|
786
|
+
// }
|
787
|
+
// table += '</table><br/ >';
|
788
|
+
// // document.execCommand('insertHTML', false, table);
|
789
|
+
// const editor = document.getElementById('editor');
|
790
|
+
// if (editor) {
|
791
|
+
// editor.focus();
|
792
|
+
// document.execCommand('insertHTML', false, table);
|
793
|
+
// }
|
794
|
+
// this.tableAdded = true;
|
795
|
+
// this.checkTableSelection();
|
796
|
+
// }
|
775
797
|
addTable() {
|
776
798
|
const tableWidth = 825; // Table width in pixels
|
777
799
|
const cols = 3; // Number of columns
|
778
800
|
const cellMinWidth = tableWidth / cols; // Calculate minimum width for each cell
|
779
|
-
let table = `<br /><table
|
801
|
+
let table = `<br /><table style="width: ${tableWidth}px;">`;
|
780
802
|
for (let i = 0; i < 3; i++) { // Number of rows
|
781
|
-
table += '<tr
|
803
|
+
table += '<tr style="border-bottom: 1px solid #000;">'; // Add border-bottom to the row
|
782
804
|
for (let j = 0; j < cols; j++) {
|
783
|
-
table += `<td style="
|
805
|
+
table += `<td style="word-wrap: break-word; word-break: break-all; white-space: normal; min-width: ${cellMinWidth}px;"> </td>`;
|
784
806
|
}
|
785
807
|
table += '</tr>';
|
786
808
|
}
|
787
|
-
table += '</table><br
|
788
|
-
// document.execCommand('insertHTML', false, table);
|
809
|
+
table += '</table><br/>';
|
789
810
|
const editor = document.getElementById('editor');
|
790
811
|
if (editor) {
|
791
812
|
editor.focus();
|
@@ -833,13 +854,23 @@ class ElTextEditorComponent {
|
|
833
854
|
onBlur() {
|
834
855
|
this.checkPlaceholder();
|
835
856
|
}
|
857
|
+
// addRow() {
|
858
|
+
// if (this.selectedTable) {
|
859
|
+
// let row = this.selectedTable.insertRow();
|
860
|
+
// for (let i = 0; i < this.selectedTable.rows[0].cells.length; i++) {
|
861
|
+
// let cell = row.insertCell(i);
|
862
|
+
// cell.innerHTML = ' ';
|
863
|
+
// cell.style.border = '1px solid black';
|
864
|
+
// }
|
865
|
+
// }
|
866
|
+
// }
|
836
867
|
addRow() {
|
837
868
|
if (this.selectedTable) {
|
838
869
|
let row = this.selectedTable.insertRow();
|
870
|
+
row.style.borderBottom = '1px solid black'; // Add bottom border to the row
|
839
871
|
for (let i = 0; i < this.selectedTable.rows[0].cells.length; i++) {
|
840
872
|
let cell = row.insertCell(i);
|
841
873
|
cell.innerHTML = ' ';
|
842
|
-
cell.style.border = '1px solid black';
|
843
874
|
}
|
844
875
|
}
|
845
876
|
}
|
@@ -888,6 +919,28 @@ class ElTextEditorComponent {
|
|
888
919
|
// }
|
889
920
|
// }
|
890
921
|
// }
|
922
|
+
// addColumn() {
|
923
|
+
// if (this.selectedTable) {
|
924
|
+
// const columnCount = this.selectedTable.rows[0].cells.length + 1; // New column count
|
925
|
+
// const tableWidth = this.selectedTable.offsetWidth;
|
926
|
+
// const minWidth = tableWidth / columnCount;
|
927
|
+
// for (let i = 0; i < this.selectedTable.rows.length; i++) {
|
928
|
+
// let cell = this.selectedTable.rows[i].insertCell(-1);
|
929
|
+
// cell.innerHTML = ' ';
|
930
|
+
// cell.style.border = '1px solid black';
|
931
|
+
// cell.style.minWidth = `${minWidth}px`;
|
932
|
+
// cell.style.wordWrap = 'break-word';
|
933
|
+
// cell.style.wordBreak = 'break-all';
|
934
|
+
// cell.style.whiteSpace = 'normal';
|
935
|
+
// }
|
936
|
+
// // Update existing cells' minWidth
|
937
|
+
// for (let i = 0; i < this.selectedTable.rows.length; i++) {
|
938
|
+
// for (let j = 0; j < this.selectedTable.rows[i].cells.length; j++) {
|
939
|
+
// this.selectedTable.rows[i].cells[j].style.minWidth = `${minWidth}px`;
|
940
|
+
// }
|
941
|
+
// }
|
942
|
+
// }
|
943
|
+
// }
|
891
944
|
addColumn() {
|
892
945
|
if (this.selectedTable) {
|
893
946
|
const columnCount = this.selectedTable.rows[0].cells.length + 1; // New column count
|
@@ -896,17 +949,14 @@ class ElTextEditorComponent {
|
|
896
949
|
for (let i = 0; i < this.selectedTable.rows.length; i++) {
|
897
950
|
let cell = this.selectedTable.rows[i].insertCell(-1);
|
898
951
|
cell.innerHTML = ' ';
|
899
|
-
cell.style.border = '1px solid black';
|
900
|
-
cell.style.minWidth = `${minWidth}px`;
|
901
952
|
cell.style.wordWrap = 'break-word';
|
902
953
|
cell.style.wordBreak = 'break-all';
|
903
954
|
cell.style.whiteSpace = 'normal';
|
955
|
+
cell.style.minWidth = `${minWidth}px`;
|
904
956
|
}
|
905
|
-
// Update existing
|
957
|
+
// Update existing rows' bottom border
|
906
958
|
for (let i = 0; i < this.selectedTable.rows.length; i++) {
|
907
|
-
|
908
|
-
this.selectedTable.rows[i].cells[j].style.minWidth = `${minWidth}px`;
|
909
|
-
}
|
959
|
+
this.selectedTable.rows[i].style.borderBottom = '1px solid black';
|
910
960
|
}
|
911
961
|
}
|
912
962
|
}
|