@hufe921/canvas-editor 0.9.128 → 0.9.130

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.130](https://github.com/Hufe921/canvas-editor/compare/v0.9.129...v0.9.130) (2026-03-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * correct duplicate variable check in TextParticle render ([4b72161](https://github.com/Hufe921/canvas-editor/commit/4b721618d10ef484e92b79f52ea27ee4be316814))
7
+ * ensure trailing line break in element list formatting #1378 ([30074b6](https://github.com/Hufe921/canvas-editor/commit/30074b6b703b3da581c5446a75edb38f4bff56b7)), closes [#1378](https://github.com/Hufe921/canvas-editor/issues/1378)
8
+ * optimize cursor positioning for left/right key handlers #1378 ([a79928f](https://github.com/Hufe921/canvas-editor/commit/a79928fc507cac0302e105110bc31f2baeefb74c)), closes [#1378](https://github.com/Hufe921/canvas-editor/issues/1378)
9
+ * prevent extra line break when list is first element in table #1381 ([bae2394](https://github.com/Hufe921/canvas-editor/commit/bae2394ceffee5e1a5b8f55d5ef8d60f7edc44b9)), closes [#1381](https://github.com/Hufe921/canvas-editor/issues/1381)
10
+
11
+
12
+ ### Features
13
+
14
+ * support iframe snapshot in getImage api #1380 ([d980298](https://github.com/Hufe921/canvas-editor/commit/d9802988587333b8b624112f554d2b4e9d702e00)), closes [#1380](https://github.com/Hufe921/canvas-editor/issues/1380)
15
+
16
+
17
+
18
+ ## [0.9.129](https://github.com/Hufe921/canvas-editor/compare/v0.9.128...v0.9.129) (2026-03-13)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * cursor positioning when pressing home key at line start #1376 ([3158103](https://github.com/Hufe921/canvas-editor/commit/3158103158d9a048b15b796b7dd89488e5ddef7b)), closes [#1376](https://github.com/Hufe921/canvas-editor/issues/1376)
24
+ * disable iframe editing in readonly mode #1373 ([d2b2cf1](https://github.com/Hufe921/canvas-editor/commit/d2b2cf13adb5b545d27f9afc00387a0bb679a26d)), closes [#1373](https://github.com/Hufe921/canvas-editor/issues/1373)
25
+ * iframe block position in print mode #1374 ([bc03f7b](https://github.com/Hufe921/canvas-editor/commit/bc03f7bf1126e8f484ebd6d6433f946efdf2a681)), closes [#1374](https://github.com/Hufe921/canvas-editor/issues/1374)
26
+ * prevent auto-scroll when clicking menu bar #1371 ([ee09e93](https://github.com/Hufe921/canvas-editor/commit/ee09e9362d3034188ab4f5ef468533199df167ff)), closes [#1371](https://github.com/Hufe921/canvas-editor/issues/1371)
27
+ * sync iframe block srcdoc when getValue #1369 ([53400b4](https://github.com/Hufe921/canvas-editor/commit/53400b4a6846b980d3e59385210eec8e768765ab)), closes [#1369](https://github.com/Hufe921/canvas-editor/issues/1369)
28
+
29
+
30
+ ### Chores
31
+
32
+ * expose instance for canvas-editor-devtools ([8ea4798](https://github.com/Hufe921/canvas-editor/commit/8ea4798dc5b5c50b268da41dd2c6134787f669b6))
33
+
34
+
35
+ ### Documentation
36
+
37
+ * add canvas-editor-devtools documentation ([1cbd9ee](https://github.com/Hufe921/canvas-editor/commit/1cbd9ee9c70c22107ece2dc76667211911b64efb))
38
+ * refactor option.md configuration ([43ec928](https://github.com/Hufe921/canvas-editor/commit/43ec9285d080547cab2d6ec4fcebac46caca38df))
39
+
40
+
41
+ ### Features
42
+
43
+ * add executeDeleteArea api #1377 ([10174ec](https://github.com/Hufe921/canvas-editor/commit/10174ecb0f0ade11a01db1b5227dee6a91266d81)), closes [#1377](https://github.com/Hufe921/canvas-editor/issues/1377)
44
+ * improve word count logic to match mainstream word processors #452 ([117b1cb](https://github.com/Hufe921/canvas-editor/commit/117b1cb4ef2e3025464e66c44f398822cb7fbcda)), closes [#452](https://github.com/Hufe921/canvas-editor/issues/452)
45
+ * print support for iframe block #1375 ([dfc3191](https://github.com/Hufe921/canvas-editor/commit/dfc31912173b7b44d2b81145d37080475f6dd9fe)), closes [#1375](https://github.com/Hufe921/canvas-editor/issues/1375)
46
+
47
+
48
+
1
49
  ## [0.9.128](https://github.com/Hufe921/canvas-editor/compare/v0.9.127...v0.9.128) (2026-02-28)
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.128";
26
+ const version = "0.9.130";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -414,6 +414,14 @@ function isRectIntersect(rect1, rect2) {
414
414
  function isNonValue(value) {
415
415
  return value === void 0 || value === null;
416
416
  }
417
+ function loadImage(src) {
418
+ return new Promise((resolve, reject) => {
419
+ const img = new Image();
420
+ img.onload = () => resolve(img);
421
+ img.onerror = reject;
422
+ img.src = src;
423
+ });
424
+ }
417
425
  function normalizeLineBreak(text) {
418
426
  return text.replace(/\r\n|\r/g, "\n");
419
427
  }
@@ -674,7 +682,13 @@ const VIRTUAL_ELEMENT_TYPE = [
674
682
  const _IFrameBlock = class {
675
683
  constructor(element) {
676
684
  __publicField(this, "element");
685
+ __publicField(this, "iframe", null);
686
+ __publicField(this, "isReadonly");
677
687
  this.element = element;
688
+ this.isReadonly = false;
689
+ }
690
+ getIframe() {
691
+ return this.iframe;
678
692
  }
679
693
  _defineIframeProperties(iframeWindow) {
680
694
  Object.defineProperties(iframeWindow, {
@@ -702,6 +716,19 @@ const _IFrameBlock = class {
702
716
  }
703
717
  blockItemContainer.append(iframe);
704
718
  this._defineIframeProperties(iframe.contentWindow);
719
+ this.iframe = iframe;
720
+ }
721
+ setReadonly(readonly) {
722
+ if (!this.iframe || this.isReadonly === readonly)
723
+ return;
724
+ this.isReadonly = readonly;
725
+ if (readonly) {
726
+ this.iframe.style.pointerEvents = "none";
727
+ this.iframe.setAttribute("tabindex", "-1");
728
+ } else {
729
+ this.iframe.style.pointerEvents = "";
730
+ this.iframe.removeAttribute("tabindex");
731
+ }
705
732
  }
706
733
  };
707
734
  let IFrameBlock = _IFrameBlock;
@@ -4424,7 +4451,7 @@ function formatElementList(elementList, options) {
4424
4451
  var _a, _b;
4425
4452
  const { isHandleFirstElement = true, isForceCompensation = false, editorOptions } = options;
4426
4453
  const startElement = elementList[0];
4427
- if (isForceCompensation || isHandleFirstElement && (startElement == null ? void 0 : startElement.type) !== ElementType.LIST && ((startElement == null ? void 0 : startElement.type) && startElement.type !== ElementType.TEXT || !START_LINE_BREAK_REG.test(startElement == null ? void 0 : startElement.value))) {
4454
+ if ((startElement == null ? void 0 : startElement.type) !== ElementType.LIST && (isForceCompensation || isHandleFirstElement && ((startElement == null ? void 0 : startElement.type) && startElement.type !== ElementType.TEXT || !START_LINE_BREAK_REG.test(startElement == null ? void 0 : startElement.value)))) {
4428
4455
  elementList.unshift({
4429
4456
  value: ZERO
4430
4457
  });
@@ -4479,6 +4506,12 @@ function formatElementList(elementList, options) {
4479
4506
  elementList.splice(i, 0, value);
4480
4507
  i++;
4481
4508
  }
4509
+ if (elementList[i] && !START_LINE_BREAK_REG.test(elementList[i].value)) {
4510
+ elementList.splice(i, 0, {
4511
+ value: ZERO
4512
+ });
4513
+ i++;
4514
+ }
4482
4515
  }
4483
4516
  i--;
4484
4517
  } else if (el.type === ElementType.AREA) {
@@ -6271,12 +6304,14 @@ class Cursor {
6271
6304
  } else {
6272
6305
  this._clearBlinkTimeout();
6273
6306
  }
6274
- nextTick(() => {
6275
- this.moveCursorToVisible({
6276
- cursorPosition,
6277
- direction: parseInt(oldTop) > cursorTop ? MoveDirection.UP : MoveDirection.DOWN
6307
+ if (isFocus) {
6308
+ nextTick(() => {
6309
+ this.moveCursorToVisible({
6310
+ cursorPosition,
6311
+ direction: parseInt(oldTop) > cursorTop ? MoveDirection.UP : MoveDirection.DOWN
6312
+ });
6278
6313
  });
6279
- });
6314
+ }
6280
6315
  }
6281
6316
  recoveryCursor() {
6282
6317
  this.cursorDom.style.display = "none";
@@ -7512,6 +7547,20 @@ function left(evt, host) {
7512
7547
  isSubmitHistory: false,
7513
7548
  isCompute: false
7514
7549
  });
7550
+ if (isAnchorCollapsed) {
7551
+ const positionList = position.getPositionList();
7552
+ const anchorPosition = positionList[anchorStartIndex];
7553
+ if ((anchorPosition == null ? void 0 : anchorPosition.isLastLetter) && anchorPosition.value !== ZERO && anchorStartIndex + 1 < positionList.length) {
7554
+ const nextPosition = positionList[anchorStartIndex + 1];
7555
+ const element = newElementList[anchorStartIndex];
7556
+ const nextElement = newElementList[anchorStartIndex + 1];
7557
+ if (nextPosition.value !== ZERO && !getIsBlockElement(nextElement) && element.listId === nextElement.listId) {
7558
+ draw.getCursor().drawCursor({
7559
+ hitLineStartIndex: anchorStartIndex + 1
7560
+ });
7561
+ }
7562
+ }
7563
+ }
7515
7564
  evt.preventDefault();
7516
7565
  }
7517
7566
  function right(evt, host) {
@@ -7656,6 +7705,19 @@ function right(evt, host) {
7656
7705
  isSubmitHistory: false,
7657
7706
  isCompute: false
7658
7707
  });
7708
+ if (isAnchorCollapsed) {
7709
+ const anchorPosition = positionList[anchorStartIndex];
7710
+ if ((anchorPosition == null ? void 0 : anchorPosition.isLastLetter) && anchorPosition.value !== ZERO && anchorStartIndex + 1 < positionList.length) {
7711
+ const nextPosition = positionList[anchorStartIndex + 1];
7712
+ const element = elementList[anchorStartIndex];
7713
+ const nextElement = elementList[anchorStartIndex + 1];
7714
+ if (nextPosition.value !== ZERO && !getIsBlockElement(nextElement) && element.listId === nextElement.listId) {
7715
+ draw.getCursor().drawCursor({
7716
+ hitLineStartIndex: anchorStartIndex + 1
7717
+ });
7718
+ }
7719
+ }
7720
+ }
7659
7721
  evt.preventDefault();
7660
7722
  }
7661
7723
  function tab(evt, host) {
@@ -8000,6 +8062,10 @@ function home(evt, host) {
8000
8062
  break;
8001
8063
  lineStartIndex = i;
8002
8064
  }
8065
+ const isNonZero = positionList[lineStartIndex].value !== ZERO;
8066
+ if (isNonZero) {
8067
+ lineStartIndex--;
8068
+ }
8003
8069
  let anchorStart = lineStartIndex;
8004
8070
  let anchorEnd = lineStartIndex;
8005
8071
  if (evt.shiftKey) {
@@ -8027,6 +8093,11 @@ function home(evt, host) {
8027
8093
  isSubmitHistory: false,
8028
8094
  isCompute: false
8029
8095
  });
8096
+ if (isNonZero) {
8097
+ draw.getCursor().drawCursor({
8098
+ hitLineStartIndex: lineStartIndex + 1
8099
+ });
8100
+ }
8030
8101
  evt.preventDefault();
8031
8102
  }
8032
8103
  function end(evt, host) {
@@ -8048,7 +8119,11 @@ function end(evt, host) {
8048
8119
  anchorPosition = positionList[startIndex];
8049
8120
  }
8050
8121
  }
8051
- const { rowNo } = anchorPosition;
8122
+ let { rowNo } = anchorPosition;
8123
+ const hitLineStartIndex = draw.getCursor().getHitLineStartIndex();
8124
+ if (hitLineStartIndex !== void 0) {
8125
+ rowNo++;
8126
+ }
8052
8127
  let lineEndIndex = anchorPosition.index;
8053
8128
  for (let i = anchorPosition.index + 1; i < positionList.length; i++) {
8054
8129
  if (positionList[i].rowNo !== rowNo)
@@ -10939,7 +11014,7 @@ class TextParticle {
10939
11014
  this.curY = y;
10940
11015
  }
10941
11016
  _render() {
10942
- if (!this.text || !~this.curX || !~this.curX)
11017
+ if (!this.text || !~this.curX || !~this.curY)
10943
11018
  return;
10944
11019
  this.ctx.save();
10945
11020
  this.ctx.font = this.curStyle;
@@ -15619,7 +15694,7 @@ class RadioParticle {
15619
15694
  ctx.restore();
15620
15695
  }
15621
15696
  }
15622
- const encodedJs$3 = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBhOyhmdW5jdGlvbihlKXtlLlRFWFQ9InRleHQiLGUuVEFCTEU9InRhYmxlIixlLkhZUEVSTElOSz0iaHlwZXJsaW5rIixlLkNPTlRST0w9ImNvbnRyb2wifSkoYXx8KGE9e30pKTt2YXIgcDsoZnVuY3Rpb24oZSl7ZS5WQUxVRT0idmFsdWUifSkocHx8KHA9e30pKTtjb25zdCBoPSJcdTIwMEIiLGQ9YApgO2Z1bmN0aW9uIHUoZSl7dmFyIG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b250aW51ZX1sKCkscy5wdXNoKHQpfXJldHVybiBsKCksc31vbm1lc3NhZ2U9bj0+e2NvbnN0IHM9bi5kYXRhLGw9YyhzKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke3B9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChwLCJnIiksZyksZj1MKGwpO3Bvc3RNZXNzYWdlKGYubGVuZ3RoKX19KSgpO30pKCk7Cg==";
15623
15698
  const blob$3 = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs$3)], { type: "text/javascript;charset=utf-8" });
15624
15699
  function WorkerWrapper$3() {
15625
15700
  const objURL = blob$3 && (window.URL || window.webkitURL).createObjectURL(blob$3);
@@ -16333,6 +16408,7 @@ class BaseBlock {
16333
16408
  __publicField(this, "block");
16334
16409
  __publicField(this, "blockContainer");
16335
16410
  __publicField(this, "blockItem");
16411
+ __publicField(this, "positionInfo", null);
16336
16412
  __publicField(this, "blockCache");
16337
16413
  __publicField(this, "resizerMask");
16338
16414
  __publicField(this, "resizerSelection");
@@ -16368,6 +16444,12 @@ class BaseBlock {
16368
16444
  getBlockWidth() {
16369
16445
  return this.element.width || this.element.metrics.width;
16370
16446
  }
16447
+ getIFrameBlock() {
16448
+ return this.block instanceof IFrameBlock ? this.block : null;
16449
+ }
16450
+ getPositionInfo() {
16451
+ return this.positionInfo;
16452
+ }
16371
16453
  _createBlockItem() {
16372
16454
  const { scale, resizerColor } = this.options;
16373
16455
  const blockItem = document.createElement("div");
@@ -16518,7 +16600,7 @@ class BaseBlock {
16518
16600
  this.blockItem.style.height = `${elementHeight}px`;
16519
16601
  evt.preventDefault();
16520
16602
  }
16521
- snapshot(ctx, x, y) {
16603
+ snapshot(ctx, pageNo, x, y) {
16522
16604
  const block = this.element.block;
16523
16605
  if (block.type === BlockType.VIDEO) {
16524
16606
  this.blockItem.style.display = "none";
@@ -16531,6 +16613,8 @@ class BaseBlock {
16531
16613
  this.draw.getImageObserver().add(promise);
16532
16614
  this.blockCache.set(this.element.id, this.block);
16533
16615
  }
16616
+ } else if (block.type === BlockType.IFRAME) {
16617
+ this.setClientRects(pageNo, x, y);
16534
16618
  }
16535
16619
  }
16536
16620
  render() {
@@ -16553,6 +16637,12 @@ class BaseBlock {
16553
16637
  this.blockItem.style.height = `${metrics.height}px`;
16554
16638
  this.blockItem.style.left = `${x}px`;
16555
16639
  this.blockItem.style.top = `${preY + y}px`;
16640
+ this.positionInfo = { pageNo, x, y };
16641
+ }
16642
+ setStatus() {
16643
+ if (this.block instanceof IFrameBlock) {
16644
+ this.block.setReadonly(this.draw.isReadonly());
16645
+ }
16556
16646
  }
16557
16647
  remove() {
16558
16648
  this.blockItem.remove();
@@ -16561,10 +16651,12 @@ class BaseBlock {
16561
16651
  class BlockParticle {
16562
16652
  constructor(draw) {
16563
16653
  __publicField(this, "draw");
16654
+ __publicField(this, "options");
16564
16655
  __publicField(this, "container");
16565
16656
  __publicField(this, "blockContainer");
16566
16657
  __publicField(this, "blockMap");
16567
16658
  this.draw = draw;
16659
+ this.options = draw.getOptions();
16568
16660
  this.container = draw.getContainer();
16569
16661
  this.blockMap = new Map();
16570
16662
  this.blockContainer = this._createBlockContainer();
@@ -16590,10 +16682,11 @@ class BlockParticle {
16590
16682
  this.blockMap.set(id, cacheBlock);
16591
16683
  }
16592
16684
  if (this.draw.isPrintMode()) {
16593
- cacheBlock.snapshot(ctx, x, y);
16685
+ cacheBlock.snapshot(ctx, pageNo, x, y);
16594
16686
  } else {
16595
16687
  cacheBlock.setClientRects(pageNo, x, y);
16596
16688
  }
16689
+ cacheBlock.setStatus();
16597
16690
  }
16598
16691
  clear() {
16599
16692
  if (!this.blockMap.size)
@@ -16614,6 +16707,66 @@ class BlockParticle {
16614
16707
  }
16615
16708
  });
16616
16709
  }
16710
+ update() {
16711
+ this.blockMap.forEach((baseBlock) => {
16712
+ var _a, _b, _c, _d, _e;
16713
+ const element = baseBlock.getBlockElement();
16714
+ if (((_a = element.block) == null ? void 0 : _a.type) === BlockType.IFRAME && ((_b = element.block.iframeBlock) == null ? void 0 : _b.srcdoc)) {
16715
+ const iframe = (_e = (_d = (_c = baseBlock.getIFrameBlock) == null ? void 0 : _c.call(baseBlock)) == null ? void 0 : _d.getIframe) == null ? void 0 : _e.call(_d);
16716
+ if (iframe == null ? void 0 : iframe.contentDocument) {
16717
+ element.block.iframeBlock.srcdoc = iframe.contentDocument.documentElement.outerHTML;
16718
+ }
16719
+ }
16720
+ });
16721
+ }
16722
+ async drawIframeToPage(pageList, snapDomFunction) {
16723
+ const tasks = [];
16724
+ this.blockMap.forEach((cacheBlock) => {
16725
+ var _a, _b, _c;
16726
+ if (((_a = cacheBlock.getBlockElement().block) == null ? void 0 : _a.type) !== BlockType.IFRAME)
16727
+ return;
16728
+ const positionInfo = cacheBlock.getPositionInfo();
16729
+ if (!positionInfo)
16730
+ return;
16731
+ const iframe = (_b = cacheBlock.getIFrameBlock()) == null ? void 0 : _b.getIframe();
16732
+ if (!iframe)
16733
+ return;
16734
+ const { pageNo, x, y } = positionInfo;
16735
+ const ctx = (_c = pageList[pageNo]) == null ? void 0 : _c.getContext("2d");
16736
+ if (!ctx)
16737
+ return;
16738
+ const { width, height } = cacheBlock.getBlockElement().metrics;
16739
+ tasks.push(snapDomFunction(iframe).then((base64) => loadImage(base64)).then((img) => ctx.drawImage(img, x, y, width, height)));
16740
+ });
16741
+ await Promise.allSettled(tasks);
16742
+ }
16743
+ pickIframeInfo() {
16744
+ const result = [];
16745
+ const { scale } = this.options;
16746
+ this.blockMap.forEach((cacheBlock) => {
16747
+ var _a;
16748
+ const element = cacheBlock.getBlockElement();
16749
+ if (!((_a = element.block) == null ? void 0 : _a.iframeBlock) || element.block.type !== BlockType.IFRAME) {
16750
+ return;
16751
+ }
16752
+ const positionInfo = cacheBlock.getPositionInfo();
16753
+ if (!positionInfo)
16754
+ return;
16755
+ const { pageNo, x, y } = positionInfo;
16756
+ if (!result[pageNo]) {
16757
+ result[pageNo] = [];
16758
+ }
16759
+ result[pageNo].push({
16760
+ x,
16761
+ y,
16762
+ width: element.metrics.width / scale,
16763
+ height: element.metrics.height / scale,
16764
+ src: element.block.iframeBlock.src,
16765
+ srcdoc: element.block.iframeBlock.srcdoc
16766
+ });
16767
+ });
16768
+ return result;
16769
+ }
16617
16770
  }
16618
16771
  const contextmenu$1 = {
16619
16772
  global: {
@@ -18924,6 +19077,22 @@ class Area {
18924
19077
  isSetCursor: false
18925
19078
  });
18926
19079
  }
19080
+ deleteArea(options = {}) {
19081
+ const areaId = options.id || this.getActiveAreaId();
19082
+ if (!areaId)
19083
+ return;
19084
+ const areaInfo = this.areaInfoMap.get(areaId);
19085
+ if (!areaInfo)
19086
+ return;
19087
+ const { positionList } = areaInfo;
19088
+ const elementList = this.draw.getOriginalMainElementList();
19089
+ this.draw.spliceElementList(elementList, positionList[0].index, positionList.length, [], {
19090
+ isIgnoreDeletedRule: true
19091
+ });
19092
+ this.draw.render({
19093
+ isSetCursor: false
19094
+ });
19095
+ }
18927
19096
  }
18928
19097
  class Badge {
18929
19098
  constructor(draw) {
@@ -19724,6 +19893,9 @@ class Draw {
19724
19893
  getTableParticle() {
19725
19894
  return this.tableParticle;
19726
19895
  }
19896
+ getBlockParticle() {
19897
+ return this.blockParticle;
19898
+ }
19727
19899
  getHeader() {
19728
19900
  return this.header;
19729
19901
  }
@@ -19764,7 +19936,7 @@ class Draw {
19764
19936
  return this.getRowList().length;
19765
19937
  }
19766
19938
  async getDataURL(payload = {}) {
19767
- const { pixelRatio, mode } = payload;
19939
+ const { pixelRatio, mode, snapDomFunction } = payload;
19768
19940
  if (pixelRatio) {
19769
19941
  this.setPagePixelRatio(pixelRatio);
19770
19942
  }
@@ -19780,6 +19952,9 @@ class Draw {
19780
19952
  isSubmitHistory: false
19781
19953
  });
19782
19954
  await this.imageObserver.allSettled();
19955
+ if (snapDomFunction) {
19956
+ await this.blockParticle.drawIframeToPage(this.pageList, snapDomFunction);
19957
+ }
19783
19958
  const dataUrlList = this.pageList.map((c) => c.toDataURL());
19784
19959
  if (pixelRatio) {
19785
19960
  this.setPagePixelRatio(null);
@@ -19953,6 +20128,7 @@ class Draw {
19953
20128
  if (Number.isInteger(pageNo) && pageNo >= 0 && pageNo < this.pageRowList.length) {
19954
20129
  mainElementList = this.pageRowList[pageNo].flatMap((row) => row.elementList);
19955
20130
  }
20131
+ this.blockParticle.update();
19956
20132
  const data2 = {
19957
20133
  header: this.getHeaderElementList(),
19958
20134
  main: mainElementList,
@@ -21248,6 +21424,7 @@ class Command {
21248
21424
  __publicField(this, "executeInsertArea");
21249
21425
  __publicField(this, "executeSetAreaValue");
21250
21426
  __publicField(this, "executeSetAreaProperties");
21427
+ __publicField(this, "executeDeleteArea");
21251
21428
  __publicField(this, "executeLocationArea");
21252
21429
  __publicField(this, "executeClearGraffiti");
21253
21430
  __publicField(this, "executeAppendElementList");
@@ -21391,6 +21568,7 @@ class Command {
21391
21568
  this.executeInsertArea = adapt.insertArea.bind(adapt);
21392
21569
  this.executeSetAreaValue = adapt.setAreaValue.bind(adapt);
21393
21570
  this.executeSetAreaProperties = adapt.setAreaProperties.bind(adapt);
21571
+ this.executeDeleteArea = adapt.deleteArea.bind(adapt);
21394
21572
  this.executeLocationArea = adapt.locationArea.bind(adapt);
21395
21573
  this.executeClearGraffiti = adapt.clearGraffiti.bind(adapt);
21396
21574
  this.executeInsertElementList = adapt.insertElementList.bind(adapt);
@@ -21490,8 +21668,8 @@ function convertPxToPaperSize(width, height) {
21490
21668
  height: `${height}px`
21491
21669
  };
21492
21670
  }
21493
- function printImageBase64(base64List, options) {
21494
- const { width, height, direction = PaperDirection.VERTICAL } = options;
21671
+ async function print(base64List, options) {
21672
+ const { width, height, direction = PaperDirection.VERTICAL, iframeInfoList = [] } = options;
21495
21673
  const iframe = document.createElement("iframe");
21496
21674
  iframe.style.visibility = "hidden";
21497
21675
  iframe.style.position = "absolute";
@@ -21506,12 +21684,47 @@ function printImageBase64(base64List, options) {
21506
21684
  doc.open();
21507
21685
  const container = document.createElement("div");
21508
21686
  const paperSize = convertPxToPaperSize(width, height);
21509
- base64List.forEach((base64) => {
21687
+ base64List.forEach((base64, pageIndex) => {
21688
+ const pageWrapper = document.createElement("div");
21689
+ pageWrapper.style.position = "relative";
21690
+ pageWrapper.style.width = direction === PaperDirection.HORIZONTAL ? paperSize.height : paperSize.width;
21691
+ pageWrapper.style.height = direction === PaperDirection.HORIZONTAL ? paperSize.width : paperSize.height;
21510
21692
  const image = document.createElement("img");
21511
- image.style.width = direction === PaperDirection.HORIZONTAL ? paperSize.height : paperSize.width;
21512
- image.style.height = direction === PaperDirection.HORIZONTAL ? paperSize.width : paperSize.height;
21693
+ image.style.width = "100%";
21694
+ image.style.height = "100%";
21695
+ image.style.position = "absolute";
21696
+ image.style.left = "0";
21697
+ image.style.top = "0";
21513
21698
  image.src = base64;
21514
- container.append(image);
21699
+ pageWrapper.append(image);
21700
+ const pageIframes = iframeInfoList[pageIndex] || [];
21701
+ pageIframes.forEach((iframeInfo) => {
21702
+ const iframeEl = document.createElement("iframe");
21703
+ iframeEl.style.position = "absolute";
21704
+ iframeEl.style.left = `${iframeInfo.x}px`;
21705
+ iframeEl.style.top = `${iframeInfo.y}px`;
21706
+ iframeEl.style.width = `${iframeInfo.width}px`;
21707
+ iframeEl.style.height = `${iframeInfo.height}px`;
21708
+ iframeEl.style.border = "none";
21709
+ if (iframeInfo.src) {
21710
+ iframeEl.src = iframeInfo.src;
21711
+ } else if (iframeInfo.srcdoc) {
21712
+ const script = `
21713
+ <script>
21714
+ if (!window.__CUSTOM_CANVAS_EDITOR_LOAD_HOOK__) {
21715
+ window.postMessage({ type: '__LOADED_TO_CANVAS_EDITOR__' }, '*')
21716
+ }
21717
+ <\/script>`;
21718
+ const srcdoc = iframeInfo.srcdoc;
21719
+ if (srcdoc.includes("</body>")) {
21720
+ iframeEl.srcdoc = srcdoc.replace("</body>", `${script}</body>`);
21721
+ } else {
21722
+ iframeEl.srcdoc = srcdoc + script;
21723
+ }
21724
+ }
21725
+ pageWrapper.append(iframeEl);
21726
+ });
21727
+ container.append(pageWrapper);
21515
21728
  });
21516
21729
  const style = document.createElement("style");
21517
21730
  const stylesheet = `
@@ -21524,8 +21737,11 @@ function printImageBase64(base64List, options) {
21524
21737
  size: ${paperSize.size} ${direction === PaperDirection.HORIZONTAL ? `landscape` : `portrait`};
21525
21738
  }`;
21526
21739
  style.append(document.createTextNode(stylesheet));
21527
- setTimeout(() => {
21528
- doc.write(`${style.outerHTML}${container.innerHTML}`);
21740
+ doc.write(`${style.outerHTML}${container.innerHTML}`);
21741
+ if (iframeInfoList.length) {
21742
+ await waitIframeLoad(doc);
21743
+ }
21744
+ setTimeout(async () => {
21529
21745
  contentWindow.print();
21530
21746
  doc.close();
21531
21747
  window.addEventListener("mouseover", () => {
@@ -21535,6 +21751,25 @@ function printImageBase64(base64List, options) {
21535
21751
  });
21536
21752
  });
21537
21753
  }
21754
+ async function waitIframeLoad(doc) {
21755
+ const iframeList = Array.from(doc.querySelectorAll("iframe"));
21756
+ const iframePromises = iframeList.map((iframe) => {
21757
+ const iframePromise = new Promise((resolve) => {
21758
+ var _a;
21759
+ if (iframe.srcdoc) {
21760
+ (_a = iframe.contentWindow) == null ? void 0 : _a.addEventListener("message", (e) => {
21761
+ if (e.data.type === "__LOADED_TO_CANVAS_EDITOR__") {
21762
+ resolve(true);
21763
+ }
21764
+ });
21765
+ } else {
21766
+ resolve(true);
21767
+ }
21768
+ });
21769
+ return iframePromise;
21770
+ });
21771
+ await Promise.allSettled(iframePromises);
21772
+ }
21538
21773
  class CommandAdapt {
21539
21774
  constructor(draw) {
21540
21775
  __publicField(this, "draw");
@@ -22646,10 +22881,11 @@ class CommandAdapt {
22646
22881
  pixelRatio: printPixelRatio,
22647
22882
  mode: EditorMode.PRINT
22648
22883
  });
22649
- printImageBase64(base64List, {
22884
+ await print(base64List, {
22650
22885
  width,
22651
22886
  height,
22652
- direction: paperDirection
22887
+ direction: paperDirection,
22888
+ iframeInfoList: this.draw.getBlockParticle().pickIframeInfo()
22653
22889
  });
22654
22890
  if (scale !== 1) {
22655
22891
  this.draw.setPageScale(scale);
@@ -23720,6 +23956,9 @@ class CommandAdapt {
23720
23956
  setAreaProperties(payload) {
23721
23957
  this.draw.getArea().setAreaProperties(payload);
23722
23958
  }
23959
+ deleteArea(options) {
23960
+ this.draw.getArea().deleteArea(options);
23961
+ }
23723
23962
  locationArea(areaId, options) {
23724
23963
  if ((options == null ? void 0 : options.isAppendLastLineBreak) && (options == null ? void 0 : options.position) === LocationPosition.OUTER_AFTER) {
23725
23964
  const elementList = this.draw.getOriginalMainElementList();