aden-editor-vue 0.1.3 → 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) {
@@ -7459,10 +7472,11 @@ var ImageController = class {
7459
7472
  return;
7460
7473
  }
7461
7474
  const msg = (e == null ? void 0 : e.message) || "\u672A\u77E5\u9519\u8BEF";
7462
- showToast(this.opts.upload ? `\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF1A${msg}` : `\u56FE\u7247\u5904\u7406\u5931\u8D25\uFF1A${msg}\u3002\u8BF7\u914D\u7F6E uploadImage \u56FE\u7247\u4E0A\u4F20\u63A5\u53E3\u540E\u91CD\u8BD5`, 5200);
7475
+ const userMessage = this.opts.upload ? `\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF1A${msg}\u3002\u8BF7\u68C0\u67E5 uploadImage \u63A5\u53E3\u5730\u5740\u3001\u9274\u6743\u548C\u670D\u52A1\u7AEF\u54CD\u5E94` : `\u56FE\u7247\u5904\u7406\u5931\u8D25\uFF1A${msg}\u3002\u8BF7\u914D\u7F6E uploadImage \u56FE\u7247\u4E0A\u4F20\u63A5\u53E3\u540E\u91CD\u8BD5`;
7476
+ showToast(userMessage, 6500);
7463
7477
  const blockId = this.uploadToBlock.get(uploadId);
7464
7478
  const blockStillExists = !!blockId && this.opts.editor.getDoc().blocks.some((block) => block.id === blockId);
7465
- resolveImageUpload(this.opts.editor, uploadId, { error: msg });
7479
+ resolveImageUpload(this.opts.editor, uploadId, { error: userMessage });
7466
7480
  if (!blockStillExists) {
7467
7481
  this.pending.delete(uploadId);
7468
7482
  this.uploadToBlock.delete(uploadId);
@@ -9384,7 +9398,7 @@ var WebAdapter = class {
9384
9398
  }
9385
9399
  if (images.length) {
9386
9400
  e.preventDefault();
9387
- const existingImageIds = new Set(
9401
+ const existingImageIds2 = new Set(
9388
9402
  this.editor.getDoc().blocks.filter((block) => block.type === "image").map((block) => block.id)
9389
9403
  );
9390
9404
  if (pasteHtml2) {
@@ -9393,7 +9407,7 @@ var WebAdapter = class {
9393
9407
  this.runCommand((cmd) => cmd.pastePlainText(this.editor, pasteText));
9394
9408
  }
9395
9409
  const pastedImages = this.editor.getDoc().blocks.filter(
9396
- (block) => block.type === "image" && !existingImageIds.has(block.id)
9410
+ (block) => block.type === "image" && !existingImageIds2.has(block.id)
9397
9411
  );
9398
9412
  images.forEach((file, index) => {
9399
9413
  const target = pastedImages[index];
@@ -9402,10 +9416,25 @@ var WebAdapter = class {
9402
9416
  });
9403
9417
  return;
9404
9418
  }
9419
+ const clipboardContainsImageMarkup = /<img\b|v:imagedata|w:drawing/i.test(pasteHtml2);
9420
+ const existingImageIds = new Set(
9421
+ this.editor.getDoc().blocks.filter((block) => block.type === "image").map((block) => block.id)
9422
+ );
9405
9423
  e.preventDefault();
9406
9424
  this.runCommand((cmd) => {
9407
9425
  if (pasteHtml2) cmd.pasteHtml(this.editor, pasteHtml2);
9408
9426
  else if (pasteText) cmd.pastePlainText(this.editor, pasteText);
9427
+ if (clipboardContainsImageMarkup) {
9428
+ const pastedImages = this.editor.getDoc().blocks.filter(
9429
+ (block) => block.type === "image" && !existingImageIds.has(block.id)
9430
+ );
9431
+ if (!pastedImages.some((block) => {
9432
+ var _a22, _b2;
9433
+ return sanitizeUrl(String((_b2 = (_a22 = block.attrs) == null ? void 0 : _a22.src) != null ? _b2 : ""), "media");
9434
+ })) {
9435
+ showToast("\u672A\u80FD\u4ECE\u526A\u8D34\u677F\u8BFB\u53D6\u56FE\u7247\u6587\u4EF6\u6216\u6709\u6548\u56FE\u7247\u5730\u5740\u3002\u8BF7\u68C0\u67E5 Word \u590D\u5236\u5185\u5BB9\uFF0C\u6216\u5728 options \u4E2D\u914D\u7F6E uploadImage \u56FE\u7247\u4E0A\u4F20\u63A5\u53E3\u3002", 6500);
9436
+ }
9437
+ }
9409
9438
  });
9410
9439
  };
9411
9440
  this.handleDragOver = (e) => {