el-text-editor 0.0.78 → 0.0.80

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.
@@ -1015,13 +1015,25 @@ class ElTextEditorComponent {
1015
1015
  addRow() {
1016
1016
  if (this.selectedTable) {
1017
1017
  let row = this.selectedTable.insertRow();
1018
- row.style.borderBottom = this.themeModeClrVerticalLineForTable(); // Add bottom border to the row
1018
+ // Loop through the columns of the first row to determine the number of cells
1019
1019
  for (let i = 0; i < this.selectedTable.rows[0].cells.length; i++) {
1020
1020
  let cell = row.insertCell(i);
1021
1021
  cell.innerHTML = '&nbsp;';
1022
+ // Apply bottom border explicitly
1023
+ cell.style.borderBottom = `2px solid ${this.themeModeClrVerticalLineColorForTable()}`; // You can replace 'black' with your theme color
1022
1024
  }
1023
1025
  }
1024
1026
  }
1027
+ // addRow() {
1028
+ // if (this.selectedTable) {
1029
+ // let row = this.selectedTable.insertRow();
1030
+ // row.style.borderBottom = this.themeModeClrVerticalLineForTable(); // Add bottom border to the row
1031
+ // for (let i = 0; i < this.selectedTable.rows[0].cells.length; i++) {
1032
+ // let cell = row.insertCell(i);
1033
+ // cell.innerHTML = '&nbsp;';
1034
+ // }
1035
+ // }
1036
+ // }
1025
1037
  // deleteRow() {
1026
1038
  // if (this.selectedTable) {
1027
1039
  // this.selectedTable.deleteRow(-1);
@@ -1102,6 +1114,7 @@ class ElTextEditorComponent {
1102
1114
  cell.style.wordBreak = 'break-all';
1103
1115
  cell.style.whiteSpace = 'normal';
1104
1116
  cell.style.minWidth = `${minWidth}px`;
1117
+ cell.style.borderBottom = `2px solid ${this.themeModeClrVerticalLineColorForTable()}`;
1105
1118
  }
1106
1119
  // Update existing rows' bottom border
1107
1120
  for (let i = 0; i < this.selectedTable.rows.length; i++) {
@@ -1135,6 +1148,15 @@ class ElTextEditorComponent {
1135
1148
  return '2px solid #5F5F5F !important';
1136
1149
  }
1137
1150
  }
1151
+ themeModeClrVerticalLineColorForTable() {
1152
+ const clrMode = document.body.getAttribute('data-layout-color');
1153
+ if (clrMode == 'dark') {
1154
+ return '#414141';
1155
+ }
1156
+ else {
1157
+ return '#5F5F5F';
1158
+ }
1159
+ }
1138
1160
  adjustTableWidth(event) {
1139
1161
  if (this.selectedTable) {
1140
1162
  this.selectedTable.style.width = event.target.value + 'px';
@@ -1179,24 +1201,59 @@ class ElTextEditorComponent {
1179
1201
  inputElement.click();
1180
1202
  }
1181
1203
  }
1204
+ // setTextColor(event: any) {
1205
+ // if (this.savedSelection) {
1206
+ // const color = event.target.value;
1207
+ // this.selectedTextColor = color;
1208
+ // // Restore the saved selection
1209
+ // const selection = window.getSelection();
1210
+ // if (selection) {
1211
+ // selection.removeAllRanges();
1212
+ // selection.addRange(this.savedSelection);
1213
+ // // Apply the color using a span
1214
+ // const range = this.savedSelection;
1215
+ // const span = document.createElement('span');
1216
+ // span.style.color = color;
1217
+ // span.textContent = range.toString();
1218
+ // // Replace the selected text with the styled span
1219
+ // range.deleteContents();
1220
+ // range.insertNode(span);
1221
+ // // Clear the saved selection
1222
+ // this.savedSelection = null;
1223
+ // }
1224
+ // }
1225
+ // }
1182
1226
  setTextColor(event) {
1183
1227
  if (this.savedSelection) {
1184
1228
  const color = event.target.value;
1185
1229
  this.selectedTextColor = color;
1186
1230
  // Restore the saved selection
1187
1231
  const selection = window.getSelection();
1188
- if (selection) {
1189
- selection.removeAllRanges();
1190
- selection.addRange(this.savedSelection);
1191
- // Apply the color using a span
1232
+ if (selection && selection.rangeCount > 0) {
1192
1233
  const range = this.savedSelection;
1193
- const span = document.createElement('span');
1194
- span.style.color = color;
1195
- span.textContent = range.toString();
1196
- // Replace the selected text with the styled span
1234
+ selection.removeAllRanges();
1235
+ selection.addRange(range);
1236
+ // Get selected elements
1237
+ const selectedContent = range.cloneContents();
1238
+ const elements = Array.from(selectedContent.querySelectorAll("*")); // ✅ Explicitly cast to HTMLElement[]
1239
+ // Apply color to each element without modifying structure
1240
+ elements.forEach((el) => {
1241
+ el.style.color = color;
1242
+ });
1243
+ // Apply color to the top-level text nodes (without wrapping them)
1244
+ Array.from(selectedContent.childNodes).forEach((node) => {
1245
+ var _a;
1246
+ if (node.nodeType === Node.TEXT_NODE && ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== "") {
1247
+ const parent = range.commonAncestorContainer.parentElement;
1248
+ if (parent) {
1249
+ parent.style.color = color;
1250
+ }
1251
+ }
1252
+ });
1253
+ // Replace selected content
1197
1254
  range.deleteContents();
1198
- range.insertNode(span);
1199
- // Clear the saved selection
1255
+ range.insertNode(selectedContent);
1256
+ // Clear saved selection
1200
1257
  this.savedSelection = null;
1201
1258
  }
1202
1259
  }