@hufe921/canvas-editor 0.9.67 → 0.9.69

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/CHANGELOG.md CHANGED
@@ -1,3 +1,51 @@
1
+ ## [0.9.69](https://github.com/Hufe921/canvas-editor/compare/v0.9.68...v0.9.69) (2024-03-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * adjust the style of converting table element to html #458 ([0003686](https://github.com/Hufe921/canvas-editor/commit/000368636cba3547e3b280e1960e72198b41cb01)), closes [#458](https://github.com/Hufe921/canvas-editor/issues/458)
7
+ * copy html boundary error #470 ([4e46afa](https://github.com/Hufe921/canvas-editor/commit/4e46afab687c696360a96f45dd3cd97551f951ec)), closes [#470](https://github.com/Hufe921/canvas-editor/issues/470)
8
+
9
+
10
+ ### Features
11
+
12
+ * add getControlList api #455 ([0523fc2](https://github.com/Hufe921/canvas-editor/commit/0523fc257ae6f2c9b2511e912a4272c6b962d41e)), closes [#455](https://github.com/Hufe921/canvas-editor/issues/455)
13
+ * add parameter for clearing font color and highlight color #461 ([73f9cfd](https://github.com/Hufe921/canvas-editor/commit/73f9cfdf88afcfab4376bf3c4011b171c0669d2f)), closes [#461](https://github.com/Hufe921/canvas-editor/issues/461)
14
+ * cancel painter style setting #453 ([51427c7](https://github.com/Hufe921/canvas-editor/commit/51427c7dc462ea5a33ae6a92836d1e7ded7cf43d)), closes [#453](https://github.com/Hufe921/canvas-editor/issues/453)
15
+ * table element can be merged after paging #41 ([33a2dd8](https://github.com/Hufe921/canvas-editor/commit/33a2dd8faa7a46bc9290b744dad93a761ed6e1cf)), closes [#41](https://github.com/Hufe921/canvas-editor/issues/41)
16
+
17
+
18
+ ### Refactor
19
+
20
+ * date element renderer #460 ([788f96a](https://github.com/Hufe921/canvas-editor/commit/788f96aa89766cecf0e835fd0ffe64140bb94e87)), closes [#460](https://github.com/Hufe921/canvas-editor/issues/460)
21
+
22
+
23
+ ### Tests
24
+
25
+ * update painter test case (#459) ([a058c59](https://github.com/Hufe921/canvas-editor/commit/a058c5956cc2c26b347e5528d8164e2e1eff1225)), closes [#459](https://github.com/Hufe921/canvas-editor/issues/459)
26
+
27
+
28
+
29
+ ## [0.9.68](https://github.com/Hufe921/canvas-editor/compare/v0.9.67...v0.9.68) (2024-03-10)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * dragging element boundary error ([a2d8dd5](https://github.com/Hufe921/canvas-editor/commit/a2d8dd55b36a09b42fae377e06bf667dced3857e))
35
+ * hyperlink word count statistics #449 ([180bd08](https://github.com/Hufe921/canvas-editor/commit/180bd088397159e32dc70da4eefd507721ced432)), closes [#449](https://github.com/Hufe921/canvas-editor/issues/449)
36
+
37
+
38
+ ### Features
39
+
40
+ * set print layout format when printing #448 ([c6534f7](https://github.com/Hufe921/canvas-editor/commit/c6534f766d8640cbea4e441541065d25e0dd8b82)), closes [#448](https://github.com/Hufe921/canvas-editor/issues/448)
41
+
42
+
43
+ ### Performance Improvements
44
+
45
+ * history stack memory ([5044c31](https://github.com/Hufe921/canvas-editor/commit/5044c319211322c0ab2a2db461b029f34b292939))
46
+
47
+
48
+
1
49
  ## [0.9.67](https://github.com/Hufe921/canvas-editor/compare/v0.9.66...v0.9.67) (2024-03-01)
2
50
 
3
51
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.67";
26
+ const version = "0.9.69";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -119,6 +119,22 @@ function throttle(func, delay) {
119
119
  }
120
120
  };
121
121
  }
122
+ function deepCloneOmitKeys(obj, omitKeys) {
123
+ if (!obj || typeof obj !== "object") {
124
+ return obj;
125
+ }
126
+ let newObj = {};
127
+ if (Array.isArray(obj)) {
128
+ newObj = obj.map((item) => deepCloneOmitKeys(item, omitKeys));
129
+ } else {
130
+ Object.keys(obj).forEach((key) => {
131
+ if (omitKeys.includes(key))
132
+ return;
133
+ return newObj[key] = deepCloneOmitKeys(obj[key], omitKeys);
134
+ });
135
+ }
136
+ return newObj;
137
+ }
122
138
  function deepClone(obj) {
123
139
  if (!obj || typeof obj !== "object") {
124
140
  return obj;
@@ -4058,6 +4074,22 @@ function zipElementList(payload) {
4058
4074
  listElement.valueList = zipElementList(valueList);
4059
4075
  element = listElement;
4060
4076
  } else if (element.type === ElementType.TABLE) {
4077
+ if (element.pagingId) {
4078
+ let tableIndex = e + 1;
4079
+ let combineCount = 0;
4080
+ while (tableIndex < elementList.length) {
4081
+ const nextElement = elementList[tableIndex];
4082
+ if (nextElement.pagingId === element.pagingId) {
4083
+ element.height += nextElement.height;
4084
+ element.trList.push(...nextElement.trList);
4085
+ tableIndex++;
4086
+ combineCount++;
4087
+ } else {
4088
+ break;
4089
+ }
4090
+ }
4091
+ e += combineCount;
4092
+ }
4061
4093
  if (element.trList) {
4062
4094
  for (let t = 0; t < element.trList.length; t++) {
4063
4095
  const tr = element.trList[t];
@@ -4285,16 +4317,31 @@ function createDomFromElementList(elementList, options) {
4285
4317
  const element = payload[e];
4286
4318
  if (element.type === ElementType.TABLE) {
4287
4319
  const tableDom = document.createElement("table");
4320
+ tableDom.setAttribute("cellSpacing", "0");
4321
+ tableDom.setAttribute("cellpadding", "0");
4322
+ tableDom.setAttribute("border", "0");
4323
+ tableDom.style.borderTop = tableDom.style.borderLeft = "1px solid";
4324
+ tableDom.style.width = `${element.width}px`;
4325
+ const colgroupDom = document.createElement("colgroup");
4326
+ for (let c = 0; c < element.colgroup.length; c++) {
4327
+ const colgroup = element.colgroup[c];
4328
+ const colDom = document.createElement("col");
4329
+ colDom.setAttribute("width", `${colgroup.width}`);
4330
+ colgroupDom.append(colDom);
4331
+ }
4332
+ tableDom.append(colgroupDom);
4288
4333
  const trList = element.trList;
4289
4334
  for (let t = 0; t < trList.length; t++) {
4290
4335
  const trDom = document.createElement("tr");
4291
4336
  const tr = trList[t];
4337
+ trDom.style.height = `${tr.height}px`;
4292
4338
  for (let d = 0; d < tr.tdList.length; d++) {
4293
4339
  const tdDom = document.createElement("td");
4294
- tdDom.style.border = "1px solid";
4340
+ tdDom.style.borderBottom = tdDom.style.borderRight = "1px solid";
4295
4341
  const td = tr.tdList[d];
4296
4342
  tdDom.colSpan = td.colspan;
4297
4343
  tdDom.rowSpan = td.rowspan;
4344
+ tdDom.style.verticalAlign = td.verticalAlign || "top";
4298
4345
  const childDom = buildDom(zipElementList(td.value));
4299
4346
  tdDom.innerHTML = childDom.innerHTML;
4300
4347
  if (td.backgroundColor) {
@@ -4631,6 +4678,12 @@ ${listIndex + 1}.${buildText(listElementList)}${isLast ? `
4631
4678
  }
4632
4679
  return buildText(zipElementList(elementList));
4633
4680
  }
4681
+ function getSlimCloneElementList(elementList) {
4682
+ return deepCloneOmitKeys(elementList, [
4683
+ "metrics",
4684
+ "style"
4685
+ ]);
4686
+ }
4634
4687
  function setClipboardData(data2) {
4635
4688
  localStorage.setItem(EDITOR_CLIPBOARD, JSON.stringify({
4636
4689
  text: data2.text,
@@ -4662,6 +4715,9 @@ function writeClipboardItem(text, html, elementList) {
4662
4715
  document.body.append(fakeElement);
4663
4716
  const selection = window.getSelection();
4664
4717
  const range = document.createRange();
4718
+ const br = document.createElement("span");
4719
+ br.innerText = "\n";
4720
+ fakeElement.append(br);
4665
4721
  range.selectNodeContents(fakeElement);
4666
4722
  selection == null ? void 0 : selection.removeAllRanges();
4667
4723
  selection == null ? void 0 : selection.addRange(range);
@@ -5250,6 +5306,7 @@ function setRangeCache(host) {
5250
5306
  host.cacheRange = deepClone(rangeManager.getRange());
5251
5307
  host.cacheElementList = draw.getElementList();
5252
5308
  host.cachePositionList = position.getPositionList();
5309
+ host.cachePositionContext = position.getPositionContext();
5253
5310
  }
5254
5311
  function mousedown(evt, host) {
5255
5312
  var _a;
@@ -5387,13 +5444,14 @@ function moveImgPosition(element, evt, host) {
5387
5444
  draw.getImageParticle().destroyFloatImage();
5388
5445
  }
5389
5446
  function mouseup(evt, host) {
5390
- var _a, _b, _c;
5447
+ var _a, _b, _c, _d;
5391
5448
  if (host.isAllowDrop) {
5392
5449
  const draw = host.getDraw();
5393
5450
  if (draw.isReadonly())
5394
5451
  return;
5395
5452
  const position = draw.getPosition();
5396
5453
  const positionList = position.getPositionList();
5454
+ const positionContext = position.getPositionContext();
5397
5455
  const rangeManager = draw.getRange();
5398
5456
  const cacheRange = host.cacheRange;
5399
5457
  const cacheElementList = host.cacheElementList;
@@ -5402,7 +5460,7 @@ function mouseup(evt, host) {
5402
5460
  const isCacheRangeCollapsed = cacheRange.startIndex === cacheRange.endIndex;
5403
5461
  const cacheStartIndex = isCacheRangeCollapsed ? cacheRange.startIndex - 1 : cacheRange.startIndex;
5404
5462
  const cacheEndIndex = cacheRange.endIndex;
5405
- if (range.startIndex >= cacheStartIndex && range.endIndex <= cacheEndIndex) {
5463
+ if (range.startIndex >= cacheStartIndex && range.endIndex <= cacheEndIndex && ((_a = host.cachePositionContext) == null ? void 0 : _a.tdId) === positionContext.tdId) {
5406
5464
  draw.clearSideEffect();
5407
5465
  let isSubmitHistory = false;
5408
5466
  if (isCacheRangeCollapsed) {
@@ -5431,7 +5489,7 @@ function mouseup(evt, host) {
5431
5489
  if (isContainControl) {
5432
5490
  const cacheStartElement2 = cacheElementList[cacheStartIndex + 1];
5433
5491
  const cacheEndElement2 = cacheElementList[cacheEndIndex];
5434
- const isAllowDragControl = (!cacheStartElement2.controlId || cacheStartElement2.controlComponent === ControlComponent.PREFIX) && (!cacheEndElement2.controlId || cacheEndElement2.controlComponent === ControlComponent.POSTFIX) || cacheStartElement2.controlId === cacheEndElement2.controlId && cacheStartElement2.controlComponent === ControlComponent.PREFIX && cacheEndElement2.controlComponent === ControlComponent.POSTFIX || ((_a = cacheStartElement2.control) == null ? void 0 : _a.type) === ControlType.TEXT && cacheStartElement2.controlComponent === ControlComponent.VALUE && ((_b = cacheEndElement2.control) == null ? void 0 : _b.type) === ControlType.TEXT && cacheEndElement2.controlComponent === ControlComponent.VALUE;
5492
+ const isAllowDragControl = (!cacheStartElement2.controlId || cacheStartElement2.controlComponent === ControlComponent.PREFIX) && (!cacheEndElement2.controlId || cacheEndElement2.controlComponent === ControlComponent.POSTFIX) || cacheStartElement2.controlId === cacheEndElement2.controlId && cacheStartElement2.controlComponent === ControlComponent.PREFIX && cacheEndElement2.controlComponent === ControlComponent.POSTFIX || ((_b = cacheStartElement2.control) == null ? void 0 : _b.type) === ControlType.TEXT && cacheStartElement2.controlComponent === ControlComponent.VALUE && ((_c = cacheEndElement2.control) == null ? void 0 : _c.type) === ControlType.TEXT && cacheEndElement2.controlComponent === ControlComponent.VALUE;
5435
5493
  if (!isAllowDragControl) {
5436
5494
  draw.render({
5437
5495
  curIndex: range.startIndex,
@@ -5465,6 +5523,8 @@ function mouseup(evt, host) {
5465
5523
  }
5466
5524
  });
5467
5525
  formatElementContext(elementList, replaceElementList, range.startIndex);
5526
+ const cacheStartElement = cacheElementList[cacheStartIndex];
5527
+ const cacheStartPosition = cachePositionList[cacheStartIndex];
5468
5528
  const cacheRangeStartId = createDragId(cacheElementList[cacheStartIndex]);
5469
5529
  const cacheRangeEndId = createDragId(cacheElementList[cacheEndIndex]);
5470
5530
  const replaceLength = replaceElementList.length;
@@ -5494,15 +5554,12 @@ function mouseup(evt, host) {
5494
5554
  startIndex: cacheRangeStartIndex,
5495
5555
  endIndex: cacheRangeEndIndex
5496
5556
  }));
5497
- (_c = control.getActiveControl()) == null ? void 0 : _c.cut();
5557
+ (_d = control.getActiveControl()) == null ? void 0 : _d.cut();
5498
5558
  } else {
5499
5559
  draw.spliceElementList(cacheElementList, cacheRangeStartIndex + 1, cacheRangeEndIndex - cacheRangeStartIndex);
5500
5560
  }
5501
5561
  const startElement = elementList[range.startIndex];
5502
- const cacheStartElement = cacheElementList[cacheStartIndex];
5503
5562
  const startPosition = positionList[range.startIndex];
5504
- const cacheStartPosition = cachePositionList[cacheStartIndex];
5505
- const positionContext = position.getPositionContext();
5506
5563
  let positionContextIndex = positionContext.index;
5507
5564
  if (positionContextIndex) {
5508
5565
  if (startElement.tableId && !cacheStartElement.tableId) {
@@ -6395,6 +6452,7 @@ class CanvasEvent {
6395
6452
  __publicField(this, "cacheRange");
6396
6453
  __publicField(this, "cacheElementList");
6397
6454
  __publicField(this, "cachePositionList");
6455
+ __publicField(this, "cachePositionContext");
6398
6456
  __publicField(this, "mouseDownStartPosition");
6399
6457
  __publicField(this, "draw");
6400
6458
  __publicField(this, "pageContainer");
@@ -6414,6 +6472,7 @@ class CanvasEvent {
6414
6472
  this.cacheRange = null;
6415
6473
  this.cacheElementList = null;
6416
6474
  this.cachePositionList = null;
6475
+ this.cachePositionContext = null;
6417
6476
  this.mouseDownStartPosition = null;
6418
6477
  }
6419
6478
  getDraw() {
@@ -10468,6 +10527,23 @@ class Control {
10468
10527
  isSetCursor: false
10469
10528
  });
10470
10529
  }
10530
+ getList() {
10531
+ const data2 = [
10532
+ this.draw.getHeader().getElementList(),
10533
+ this.draw.getOriginalMainElementList(),
10534
+ this.draw.getFooter().getElementList()
10535
+ ];
10536
+ const controlElementList = [];
10537
+ for (const elementList of data2) {
10538
+ for (let e = 0; e < elementList.length; e++) {
10539
+ const element = elementList[e];
10540
+ if (element.controlId) {
10541
+ controlElementList.push(element);
10542
+ }
10543
+ }
10544
+ }
10545
+ return zipElementList(controlElementList);
10546
+ }
10471
10547
  }
10472
10548
  class CheckboxParticle {
10473
10549
  constructor(draw) {
@@ -10525,7 +10601,7 @@ class CheckboxParticle {
10525
10601
  ctx.restore();
10526
10602
  }
10527
10603
  }
10528
- const encodedJs$2 = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBmOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuVEFCTEU9InRhYmxlIix0LkhZUEVSTElOSz0iaHlwZXJsaW5rIix0LkNPTlRST0w9ImNvbnRyb2wifSkoZnx8KGY9e30pKTt2YX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SxuKyt9bCs9YShzKX1lbHNlIGlmKG8uY29udHJvbElkKXtjb25zdCByPW8uY29udHJvbElkLHM9W107Zm9yKDtuPHQubGVuZ3RoOyl7Y29uc3QgZT10W25dO2lmKHIhPT1lLmNvbnRyb2xJZCl7bi0tO2JyZWFrfWUuY29udHJvbENvbXBvbmVudD09PXAuVkFMVUUmJihkZWxldGUgZS5jb250cm9sSWQscy5wdXNoKGUpKSxuKyt9bCs9YShzKX1lbHNlKCFvLnR5cGV8fG8udHlwZT09PWYuVEVYVCkmJihsKz1vLnZhbHVlKTtuKyt9cmV0dXJuIGx9ZnVuY3Rpb24gZCh0KXtjb25zdCBsPVtdLG49L1swLTldLyxvPS9bQS1aYS16XS8scj0vXHMvO2xldCBzPSExLGU9ITEsaT0iIjtmdW5jdGlvbiB1KCl7aSYmKGwucHVzaChpKSxpPSIiKX1mb3IoY29uc3QgYyBvZiB0KW8udGVzdChjKT8oc3x8dSgpLGkrPWMscz0hMCxlPSExKTpuLnRlc3QoYyk/KGV8fHUoKSxpKz1jLHM9ITEsZT0hMCk6KHUoKSxzPSExLGU9ITEsci50ZXN0KGMpfHxsLnB1c2goYykpO3JldHVybiB1KCksbH1vbm1lc3NhZ2U9dD0+e2NvbnN0IGw9dC5kYXRhLG89YShsKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke2h9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChoLCJnIiksZykscj1kKG8pO3Bvc3RNZXNzYWdlKHIubGVuZ3RoKX19KSgpO30pKCk7Cg==";
10529
10605
  const blob$2 = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs$2)], { type: "text/javascript;charset=utf-8" });
10530
10606
  function WorkerWrapper$2() {
10531
10607
  const objURL = blob$2 && (window.URL || window.webkitURL).createObjectURL(blob$2);
@@ -11595,15 +11671,6 @@ class DateParticle {
11595
11671
  startTop
11596
11672
  });
11597
11673
  }
11598
- render(ctx, element, x, y) {
11599
- ctx.save();
11600
- ctx.font = element.style;
11601
- if (element.color) {
11602
- ctx.fillStyle = element.color;
11603
- }
11604
- ctx.fillText(element.value, x, y);
11605
- ctx.restore();
11606
- }
11607
11674
  }
11608
11675
  var BlockType;
11609
11676
  (function(BlockType2) {
@@ -13465,6 +13532,23 @@ class Draw {
13465
13532
  } else if (element.type === ElementType.TABLE) {
13466
13533
  const tdPaddingWidth = tdPadding[1] + tdPadding[3];
13467
13534
  const tdPaddingHeight = tdPadding[0] + tdPadding[2];
13535
+ if (element.pagingId) {
13536
+ let tableIndex = i + 1;
13537
+ let combineCount = 0;
13538
+ while (tableIndex < elementList.length) {
13539
+ const nextElement2 = elementList[tableIndex];
13540
+ if (nextElement2.pagingId === element.pagingId) {
13541
+ element.trList.push(...nextElement2.trList);
13542
+ tableIndex++;
13543
+ combineCount++;
13544
+ } else {
13545
+ break;
13546
+ }
13547
+ }
13548
+ if (combineCount) {
13549
+ elementList.splice(i + 1, combineCount);
13550
+ }
13551
+ }
13468
13552
  this.tableParticle.computeRowColInfo(element);
13469
13553
  const trList = element.trList;
13470
13554
  for (let t = 0; t < trList.length; t++) {
@@ -13566,18 +13650,38 @@ class Draw {
13566
13650
  if (deleteCount) {
13567
13651
  const cloneTrList = trList2.splice(deleteStart, deleteCount);
13568
13652
  const cloneTrHeight = cloneTrList.reduce((pre, cur) => pre + cur.height, 0);
13653
+ const pagingId = getUUID();
13654
+ element.pagingId = pagingId;
13569
13655
  element.height -= cloneTrHeight;
13570
13656
  metrics.height -= cloneTrHeight;
13571
13657
  metrics.boundingBoxDescent -= cloneTrHeight;
13572
13658
  const cloneElement = deepClone(element);
13659
+ cloneElement.pagingId = pagingId;
13573
13660
  cloneElement.trList = cloneTrList;
13574
13661
  cloneElement.id = getUUID();
13575
13662
  this.spliceElementList(elementList, i + 1, 0, cloneElement);
13576
13663
  const positionContext = this.position.getPositionContext();
13577
- if (positionContext.isTable && positionContext.trIndex === deleteStart) {
13578
- positionContext.index += 1;
13579
- positionContext.trIndex = 0;
13580
- this.position.setPositionContext(positionContext);
13664
+ if (positionContext.isTable) {
13665
+ let newPositionContextIndex = -1;
13666
+ let newPositionContextTrIndex = -1;
13667
+ let tableIndex = i;
13668
+ while (tableIndex < elementList.length) {
13669
+ const curElement = elementList[tableIndex];
13670
+ if (curElement.pagingId !== pagingId)
13671
+ break;
13672
+ const trIndex = curElement.trList.findIndex((r) => r.id === positionContext.trId);
13673
+ if (~trIndex) {
13674
+ newPositionContextIndex = tableIndex;
13675
+ newPositionContextTrIndex = trIndex;
13676
+ break;
13677
+ }
13678
+ tableIndex++;
13679
+ }
13680
+ if (~newPositionContextIndex) {
13681
+ positionContext.index = newPositionContextIndex;
13682
+ positionContext.trIndex = newPositionContextTrIndex;
13683
+ this.position.setPositionContext(positionContext);
13684
+ }
13581
13685
  }
13582
13686
  }
13583
13687
  }
@@ -13820,8 +13924,14 @@ class Draw {
13820
13924
  this._drawRichText(ctx);
13821
13925
  this.hyperlinkParticle.render(ctx, element, x, y + offsetY);
13822
13926
  } else if (element.type === ElementType.DATE) {
13823
- this._drawRichText(ctx);
13824
- this.dateParticle.render(ctx, element, x, y + offsetY);
13927
+ const nextElement = curRow.elementList[j + 1];
13928
+ if (!preElement || preElement.dateId !== element.dateId) {
13929
+ this._drawRichText(ctx);
13930
+ }
13931
+ this.textParticle.record(ctx, element, x, y + offsetY);
13932
+ if (!nextElement || nextElement.dateId !== element.dateId) {
13933
+ this._drawRichText(ctx);
13934
+ }
13825
13935
  } else if (element.type === ElementType.SUPERSCRIPT) {
13826
13936
  this._drawRichText(ctx);
13827
13937
  this.superscriptParticle.render(ctx, element, x, y + offsetY);
@@ -14111,23 +14221,22 @@ class Draw {
14111
14221
  this.cursor.drawCursor();
14112
14222
  }
14113
14223
  if (isSubmitHistory) {
14114
- const self = this;
14115
- const oldElementList = deepClone(this.elementList);
14116
- const oldHeaderElementList = deepClone(this.header.getElementList());
14117
- const oldFooterElementList = deepClone(this.footer.getElementList());
14118
- const { startIndex, endIndex } = this.range.getRange();
14224
+ const oldElementList = getSlimCloneElementList(this.elementList);
14225
+ const oldHeaderElementList = getSlimCloneElementList(this.header.getElementList());
14226
+ const oldFooterElementList = getSlimCloneElementList(this.footer.getElementList());
14227
+ const oldRange = deepClone(this.range.getRange());
14119
14228
  const pageNo = this.pageNo;
14120
14229
  const oldPositionContext = deepClone(positionContext);
14121
14230
  const zone2 = this.zone.getZone();
14122
- this.historyManager.execute(function() {
14123
- self.zone.setZone(zone2);
14124
- self.setPageNo(pageNo);
14125
- self.position.setPositionContext(deepClone(oldPositionContext));
14126
- self.header.setElementList(deepClone(oldHeaderElementList));
14127
- self.footer.setElementList(deepClone(oldFooterElementList));
14128
- self.elementList = deepClone(oldElementList);
14129
- self.range.setRange(startIndex, endIndex);
14130
- self.render({
14231
+ this.historyManager.execute(() => {
14232
+ this.zone.setZone(zone2);
14233
+ this.setPageNo(pageNo);
14234
+ this.position.setPositionContext(deepClone(oldPositionContext));
14235
+ this.header.setElementList(deepClone(oldHeaderElementList));
14236
+ this.footer.setElementList(deepClone(oldFooterElementList));
14237
+ this.elementList = deepClone(oldElementList);
14238
+ this.range.replaceRange(deepClone(oldRange));
14239
+ this.render({
14131
14240
  curIndex,
14132
14241
  isSubmitHistory: false,
14133
14242
  isSourceHistory: true
@@ -14278,6 +14387,7 @@ class Command {
14278
14387
  __publicField(this, "getLocale");
14279
14388
  __publicField(this, "getGroupIds");
14280
14389
  __publicField(this, "getControlValue");
14390
+ __publicField(this, "getControlList");
14281
14391
  __publicField(this, "getContainer");
14282
14392
  this.executeMode = adapt.mode.bind(adapt);
14283
14393
  this.executeCut = adapt.cut.bind(adapt);
@@ -14386,6 +14496,7 @@ class Command {
14386
14496
  this.executeSetControlProperties = adapt.setControlProperties.bind(adapt);
14387
14497
  this.executeSetControlHighlight = adapt.setControlHighlight.bind(adapt);
14388
14498
  this.getControlValue = adapt.getControlValue.bind(adapt);
14499
+ this.getControlList = adapt.getControlList.bind(adapt);
14389
14500
  }
14390
14501
  }
14391
14502
  const defaultWatermarkOption = {
@@ -14401,7 +14512,8 @@ var VerticalAlign;
14401
14512
  VerticalAlign2["MIDDLE"] = "middle";
14402
14513
  VerticalAlign2["BOTTOM"] = "bottom";
14403
14514
  })(VerticalAlign || (VerticalAlign = {}));
14404
- function printImageBase64(base64List, width, height) {
14515
+ function printImageBase64(base64List, options) {
14516
+ const { width, height, direction = PaperDirection.VERTICAL } = options;
14405
14517
  const iframe = document.createElement("iframe");
14406
14518
  iframe.style.visibility = "hidden";
14407
14519
  iframe.style.position = "absolute";
@@ -14423,7 +14535,15 @@ function printImageBase64(base64List, width, height) {
14423
14535
  container.append(image);
14424
14536
  });
14425
14537
  const style = document.createElement("style");
14426
- const stylesheet = `*{margin:0;padding:0;}@page{margin:0;}`;
14538
+ const stylesheet = `
14539
+ * {
14540
+ margin: 0;
14541
+ padding: 0;
14542
+ }
14543
+ @page {
14544
+ margin: 0;
14545
+ size: ${direction === PaperDirection.HORIZONTAL ? `landscape` : `portrait`};
14546
+ }`;
14427
14547
  style.append(document.createTextNode(stylesheet));
14428
14548
  setTimeout(() => {
14429
14549
  doc.write(`${style.outerHTML}${container.innerHTML}`);
@@ -14566,6 +14686,10 @@ class CommandAdapt {
14566
14686
  this.historyManager.redo();
14567
14687
  }
14568
14688
  painter(options) {
14689
+ if (!options.isDblclick && this.draw.getPainterStyle()) {
14690
+ this.canvasEvent.clearPainterStyle();
14691
+ return;
14692
+ }
14569
14693
  const selection = this.range.getSelection();
14570
14694
  if (!selection)
14571
14695
  return;
@@ -14901,7 +15025,11 @@ class CommandAdapt {
14901
15025
  const selection = this.range.getSelectionElementList();
14902
15026
  if (selection == null ? void 0 : selection.length) {
14903
15027
  selection.forEach((el) => {
14904
- el.color = payload;
15028
+ if (payload) {
15029
+ el.color = payload;
15030
+ } else {
15031
+ delete el.color;
15032
+ }
14905
15033
  });
14906
15034
  this.draw.render({
14907
15035
  isSetCursor: false,
@@ -14912,7 +15040,11 @@ class CommandAdapt {
14912
15040
  const elementList = this.draw.getElementList();
14913
15041
  const enterElement = elementList[endIndex];
14914
15042
  if ((enterElement == null ? void 0 : enterElement.value) === ZERO) {
14915
- enterElement.color = payload;
15043
+ if (payload) {
15044
+ enterElement.color = payload;
15045
+ } else {
15046
+ delete enterElement.color;
15047
+ }
14916
15048
  this.draw.render({ curIndex: endIndex, isCompute: false });
14917
15049
  }
14918
15050
  }
@@ -14924,7 +15056,11 @@ class CommandAdapt {
14924
15056
  const selection = this.range.getSelectionElementList();
14925
15057
  if (selection == null ? void 0 : selection.length) {
14926
15058
  selection.forEach((el) => {
14927
- el.highlight = payload;
15059
+ if (payload) {
15060
+ el.highlight = payload;
15061
+ } else {
15062
+ delete el.highlight;
15063
+ }
14928
15064
  });
14929
15065
  this.draw.render({
14930
15066
  isSetCursor: false,
@@ -14935,7 +15071,11 @@ class CommandAdapt {
14935
15071
  const elementList = this.draw.getElementList();
14936
15072
  const enterElement = elementList[endIndex];
14937
15073
  if ((enterElement == null ? void 0 : enterElement.value) === ZERO) {
14938
- enterElement.highlight = payload;
15074
+ if (payload) {
15075
+ enterElement.highlight = payload;
15076
+ } else {
15077
+ delete enterElement.highlight;
15078
+ }
14939
15079
  this.draw.render({ curIndex: endIndex, isCompute: false });
14940
15080
  }
14941
15081
  }
@@ -16112,7 +16252,7 @@ class CommandAdapt {
16112
16252
  });
16113
16253
  }
16114
16254
  async print() {
16115
- const { scale, printPixelRatio } = this.options;
16255
+ const { scale, printPixelRatio, paperDirection } = this.options;
16116
16256
  if (scale !== 1) {
16117
16257
  this.draw.setPageScale(1);
16118
16258
  }
@@ -16122,7 +16262,11 @@ class CommandAdapt {
16122
16262
  pixelRatio: printPixelRatio,
16123
16263
  mode: EditorMode.PRINT
16124
16264
  });
16125
- printImageBase64(base64List, width, height);
16265
+ printImageBase64(base64List, {
16266
+ width,
16267
+ height,
16268
+ direction: paperDirection
16269
+ });
16126
16270
  if (scale !== 1) {
16127
16271
  this.draw.setPageScale(scale);
16128
16272
  }
@@ -16486,6 +16630,9 @@ class CommandAdapt {
16486
16630
  setControlHighlight(payload) {
16487
16631
  this.draw.getControl().setHighlightList(payload);
16488
16632
  }
16633
+ getControlList() {
16634
+ return this.draw.getControl().getList();
16635
+ }
16489
16636
  getContainer() {
16490
16637
  return this.draw.getContainer();
16491
16638
  }