aden-editor-vue 0.1.4 → 0.1.5

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/dist/index.cjs CHANGED
@@ -1350,11 +1350,13 @@ function extractTables(html) {
1350
1350
  return { html: out, tables };
1351
1351
  }
1352
1352
  function parseTableHtml(tableHtml) {
1353
+ var _a, _b;
1353
1354
  const rows = [];
1354
- const rowRe = /<tr[^>]*>([\s\S]*?)<\/tr>/gi;
1355
+ const rowRe = /<tr([^>]*)>([\s\S]*?)<\/tr>/gi;
1355
1356
  let rm;
1356
1357
  while (rm = rowRe.exec(tableHtml)) {
1357
- const rowHtml = rm[1];
1358
+ const rowAttrs = safeTableCellStyle(parseAttrs(rm[1] || ""));
1359
+ const rowHtml = rm[2];
1358
1360
  const cells = [];
1359
1361
  const cellRe = /<(td|th)([^>]*)>([\s\S]*?)<\/\1>/gi;
1360
1362
  let cm;
@@ -1371,17 +1373,28 @@ function parseTableHtml(tableHtml) {
1371
1373
  }
1372
1374
  }
1373
1375
  }
1376
+ const cellStyle = safeTableCellStyle(attrs);
1377
+ const style = { ...rowAttrs, ...cellStyle };
1374
1378
  cells.push({
1375
1379
  id: genId(),
1376
1380
  rowspan: attrs.rowspan ? Number(attrs.rowspan) || 1 : void 0,
1377
1381
  colspan: attrs.colspan ? Number(attrs.colspan) || 1 : void 0,
1378
1382
  content,
1379
- style: safeTableCellStyle(attrs)
1383
+ style: Object.keys(style).length ? style : void 0
1380
1384
  });
1381
1385
  }
1382
1386
  if (cells.length) rows.push(cells);
1383
1387
  }
1384
1388
  if (!rows.length) return null;
1389
+ const colRe = /<col\b([^>]*)>/gi;
1390
+ let colMatch;
1391
+ let colIndex = 0;
1392
+ while (colMatch = colRe.exec(tableHtml)) {
1393
+ const width = (_a = safeTableCellStyle(parseAttrs(colMatch[1] || ""))) == null ? void 0 : _a.width;
1394
+ const cell = (_b = rows[0]) == null ? void 0 : _b[colIndex];
1395
+ if (width && cell) cell.style = { ...cell.style, width };
1396
+ colIndex += 1;
1397
+ }
1385
1398
  return normalizeTableShape({ rows });
1386
1399
  }
1387
1400
  function normalizeTableShape(data) {