@hufe921/canvas-editor 0.9.128 → 0.9.129

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,34 @@
1
+ ## [0.9.129](https://github.com/Hufe921/canvas-editor/compare/v0.9.128...v0.9.129) (2026-03-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 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)
7
+ * 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)
8
+ * 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)
9
+ * 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)
10
+ * 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)
11
+
12
+
13
+ ### Chores
14
+
15
+ * expose instance for canvas-editor-devtools ([8ea4798](https://github.com/Hufe921/canvas-editor/commit/8ea4798dc5b5c50b268da41dd2c6134787f669b6))
16
+
17
+
18
+ ### Documentation
19
+
20
+ * add canvas-editor-devtools documentation ([1cbd9ee](https://github.com/Hufe921/canvas-editor/commit/1cbd9ee9c70c22107ece2dc76667211911b64efb))
21
+ * refactor option.md configuration ([43ec928](https://github.com/Hufe921/canvas-editor/commit/43ec9285d080547cab2d6ec4fcebac46caca38df))
22
+
23
+
24
+ ### Features
25
+
26
+ * add executeDeleteArea api #1377 ([10174ec](https://github.com/Hufe921/canvas-editor/commit/10174ecb0f0ade11a01db1b5227dee6a91266d81)), closes [#1377](https://github.com/Hufe921/canvas-editor/issues/1377)
27
+ * 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)
28
+ * 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)
29
+
30
+
31
+
1
32
  ## [0.9.128](https://github.com/Hufe921/canvas-editor/compare/v0.9.127...v0.9.128) (2026-02-28)
2
33
 
3
34
 
@@ -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.129";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -674,7 +674,13 @@ const VIRTUAL_ELEMENT_TYPE = [
674
674
  const _IFrameBlock = class {
675
675
  constructor(element) {
676
676
  __publicField(this, "element");
677
+ __publicField(this, "iframe", null);
678
+ __publicField(this, "isReadonly");
677
679
  this.element = element;
680
+ this.isReadonly = false;
681
+ }
682
+ getIframe() {
683
+ return this.iframe;
678
684
  }
679
685
  _defineIframeProperties(iframeWindow) {
680
686
  Object.defineProperties(iframeWindow, {
@@ -702,6 +708,19 @@ const _IFrameBlock = class {
702
708
  }
703
709
  blockItemContainer.append(iframe);
704
710
  this._defineIframeProperties(iframe.contentWindow);
711
+ this.iframe = iframe;
712
+ }
713
+ setReadonly(readonly) {
714
+ if (!this.iframe || this.isReadonly === readonly)
715
+ return;
716
+ this.isReadonly = readonly;
717
+ if (readonly) {
718
+ this.iframe.style.pointerEvents = "none";
719
+ this.iframe.setAttribute("tabindex", "-1");
720
+ } else {
721
+ this.iframe.style.pointerEvents = "";
722
+ this.iframe.removeAttribute("tabindex");
723
+ }
705
724
  }
706
725
  };
707
726
  let IFrameBlock = _IFrameBlock;
@@ -6271,12 +6290,14 @@ class Cursor {
6271
6290
  } else {
6272
6291
  this._clearBlinkTimeout();
6273
6292
  }
6274
- nextTick(() => {
6275
- this.moveCursorToVisible({
6276
- cursorPosition,
6277
- direction: parseInt(oldTop) > cursorTop ? MoveDirection.UP : MoveDirection.DOWN
6293
+ if (isFocus) {
6294
+ nextTick(() => {
6295
+ this.moveCursorToVisible({
6296
+ cursorPosition,
6297
+ direction: parseInt(oldTop) > cursorTop ? MoveDirection.UP : MoveDirection.DOWN
6298
+ });
6278
6299
  });
6279
- });
6300
+ }
6280
6301
  }
6281
6302
  recoveryCursor() {
6282
6303
  this.cursorDom.style.display = "none";
@@ -8000,6 +8021,10 @@ function home(evt, host) {
8000
8021
  break;
8001
8022
  lineStartIndex = i;
8002
8023
  }
8024
+ const isNonZero = positionList[lineStartIndex].value !== ZERO;
8025
+ if (isNonZero) {
8026
+ lineStartIndex--;
8027
+ }
8003
8028
  let anchorStart = lineStartIndex;
8004
8029
  let anchorEnd = lineStartIndex;
8005
8030
  if (evt.shiftKey) {
@@ -8027,6 +8052,11 @@ function home(evt, host) {
8027
8052
  isSubmitHistory: false,
8028
8053
  isCompute: false
8029
8054
  });
8055
+ if (isNonZero) {
8056
+ draw.getCursor().drawCursor({
8057
+ hitLineStartIndex: lineStartIndex + 1
8058
+ });
8059
+ }
8030
8060
  evt.preventDefault();
8031
8061
  }
8032
8062
  function end(evt, host) {
@@ -8048,7 +8078,11 @@ function end(evt, host) {
8048
8078
  anchorPosition = positionList[startIndex];
8049
8079
  }
8050
8080
  }
8051
- const { rowNo } = anchorPosition;
8081
+ let { rowNo } = anchorPosition;
8082
+ const hitLineStartIndex = draw.getCursor().getHitLineStartIndex();
8083
+ if (hitLineStartIndex !== void 0) {
8084
+ rowNo++;
8085
+ }
8052
8086
  let lineEndIndex = anchorPosition.index;
8053
8087
  for (let i = anchorPosition.index + 1; i < positionList.length; i++) {
8054
8088
  if (positionList[i].rowNo !== rowNo)
@@ -15619,7 +15653,7 @@ class RadioParticle {
15619
15653
  ctx.restore();
15620
15654
  }
15621
15655
  }
15622
- const encodedJs$3 = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBhOyhmdW5jdGlvbihlKXtlLlRFWFQ9InRleHQiLGUuVEFCTEU9InRhYmxlIixlLkhZUEVSTElOSz0iaHlwZXJsaW5rIixlLkNPTlRST0w9ImNvbnRyb2wifSkoYXx8KGE9e30pKTt2YXIgcDsoZnVuY3Rpb24oZSl7ZS5WQUxVRT0idmFsdWUifSkocHx8KHA9e30pKTtjb25zdCBoPSJcdTIwMEIiLGQ9YApgO2Z1bmN0aW9uIHUoZSl7dmFyIGMsZjtsZXQgcj0iIixuPTA7Zm9yKDtuPGUubGVuZ3RoOyl7Y29uc3QgdD1lW25dO2lmKHQudHlwZT09PWEuVEFCTEUpe2lmKHQudHJMaXN0KWZvcihsZXQgbD0wO2w8dC50ckxpc3QubGVuZ3RoO2wrKyl7Y29uc3Qgcz10LnRyTGlzdFtsXTtmb3IobGV0IG89MDtvPHMudGRMaXN0Lmxlbmd0aDtvKyspe2NvbnN0IGk9cy50ZExpc3Rbb107cis9dShpLnZhbHVlKX19fWVsc2UgaWYodC50eXBlPT09YS5IWVBFUkxJTkspe2NvbnN0IGw9dC5oeXBlcmxpbmtJZCxzPVtdO2Zvcig7bjxlLmxlbmd0aDspe2NvbnN0IG89ZVtuXTtpZihsIT09by5oeXBlcmxpbmtJZCl7bi0tO2JyZWFrfWRlbGV0ZSBvLnR5cGUscy5wdXNoKG8pLG4rK31yKz11KHMpfWVsc2UgaWYodC5jb250cm9sSWQpe2lmKCEoKGM9dC5jb250cm9sKT09bnVsbD92b2lkID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IHM9W107bGV0IHI9IiI7Y29uc3QgbD0oKT0+e3ImJihzLnB1c2gocikscj0iIil9LGY9dD0+dDw9MzJ8fHQ9PT0xNjB8fHQ+PTgxOTImJnQ8PTgyMDJ8fHQ9PT04MjM5fHx0PT09MTIyODh8fHQ+PTgyMDMmJnQ8PTgyMDd8fHQ+PTgyMzQmJnQ8PTgyMzh8fHQ9PT04Mjg4fHx0PT09NjUyNzksZT10PT50Pj00OCYmdDw9NTd8fHQ+PTY1JiZ0PD05MHx8dD49OTcmJnQ8PTEyMixvPXQ9PnQ+PTMzJiZ0PD00N3x8dD49NTgmJnQ8PTY0fHx0Pj05MSYmdDw9OTZ8fHQ+PTEyMyYmdDw9MTI2LGk9dD0+dD09PTEyM3x8dD09PTEyNTtmb3IoY29uc3QgdCBvZiBuKXtjb25zdCBhPXQuY2hhckNvZGVBdCgwKTtpZihmKGEpKXtsKCk7Y29udGludWV9aWYoZShhKXx8aShhKXx8byhhKSl7cis9dDtjb250aW51ZX1sKCkscy5wdXNoKHQpfXJldHVybiBsKCksc31vbm1lc3NhZ2U9bj0+e2NvbnN0IHM9bi5kYXRhLGw9YyhzKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke3B9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChwLCJnIiksZyksZj1MKGwpO3Bvc3RNZXNzYWdlKGYubGVuZ3RoKX19KSgpO30pKCk7Cg==";
15623
15657
  const blob$3 = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs$3)], { type: "text/javascript;charset=utf-8" });
15624
15658
  function WorkerWrapper$3() {
15625
15659
  const objURL = blob$3 && (window.URL || window.webkitURL).createObjectURL(blob$3);
@@ -16333,6 +16367,7 @@ class BaseBlock {
16333
16367
  __publicField(this, "block");
16334
16368
  __publicField(this, "blockContainer");
16335
16369
  __publicField(this, "blockItem");
16370
+ __publicField(this, "positionInfo", null);
16336
16371
  __publicField(this, "blockCache");
16337
16372
  __publicField(this, "resizerMask");
16338
16373
  __publicField(this, "resizerSelection");
@@ -16368,6 +16403,12 @@ class BaseBlock {
16368
16403
  getBlockWidth() {
16369
16404
  return this.element.width || this.element.metrics.width;
16370
16405
  }
16406
+ getIFrameBlock() {
16407
+ return this.block instanceof IFrameBlock ? this.block : null;
16408
+ }
16409
+ getPositionInfo() {
16410
+ return this.positionInfo;
16411
+ }
16371
16412
  _createBlockItem() {
16372
16413
  const { scale, resizerColor } = this.options;
16373
16414
  const blockItem = document.createElement("div");
@@ -16518,7 +16559,7 @@ class BaseBlock {
16518
16559
  this.blockItem.style.height = `${elementHeight}px`;
16519
16560
  evt.preventDefault();
16520
16561
  }
16521
- snapshot(ctx, x, y) {
16562
+ snapshot(ctx, pageNo, x, y) {
16522
16563
  const block = this.element.block;
16523
16564
  if (block.type === BlockType.VIDEO) {
16524
16565
  this.blockItem.style.display = "none";
@@ -16531,6 +16572,9 @@ class BaseBlock {
16531
16572
  this.draw.getImageObserver().add(promise);
16532
16573
  this.blockCache.set(this.element.id, this.block);
16533
16574
  }
16575
+ } else if (block.type === BlockType.IFRAME) {
16576
+ this.setClientRects(pageNo, x, y);
16577
+ this.positionInfo = { pageNo, x, y };
16534
16578
  }
16535
16579
  }
16536
16580
  render() {
@@ -16554,6 +16598,11 @@ class BaseBlock {
16554
16598
  this.blockItem.style.left = `${x}px`;
16555
16599
  this.blockItem.style.top = `${preY + y}px`;
16556
16600
  }
16601
+ setStatus() {
16602
+ if (this.block instanceof IFrameBlock) {
16603
+ this.block.setReadonly(this.draw.isReadonly());
16604
+ }
16605
+ }
16557
16606
  remove() {
16558
16607
  this.blockItem.remove();
16559
16608
  }
@@ -16561,10 +16610,12 @@ class BaseBlock {
16561
16610
  class BlockParticle {
16562
16611
  constructor(draw) {
16563
16612
  __publicField(this, "draw");
16613
+ __publicField(this, "options");
16564
16614
  __publicField(this, "container");
16565
16615
  __publicField(this, "blockContainer");
16566
16616
  __publicField(this, "blockMap");
16567
16617
  this.draw = draw;
16618
+ this.options = draw.getOptions();
16568
16619
  this.container = draw.getContainer();
16569
16620
  this.blockMap = new Map();
16570
16621
  this.blockContainer = this._createBlockContainer();
@@ -16590,10 +16641,11 @@ class BlockParticle {
16590
16641
  this.blockMap.set(id, cacheBlock);
16591
16642
  }
16592
16643
  if (this.draw.isPrintMode()) {
16593
- cacheBlock.snapshot(ctx, x, y);
16644
+ cacheBlock.snapshot(ctx, pageNo, x, y);
16594
16645
  } else {
16595
16646
  cacheBlock.setClientRects(pageNo, x, y);
16596
16647
  }
16648
+ cacheBlock.setStatus();
16597
16649
  }
16598
16650
  clear() {
16599
16651
  if (!this.blockMap.size)
@@ -16614,6 +16666,45 @@ class BlockParticle {
16614
16666
  }
16615
16667
  });
16616
16668
  }
16669
+ update() {
16670
+ this.blockMap.forEach((baseBlock) => {
16671
+ var _a, _b, _c, _d, _e;
16672
+ const element = baseBlock.getBlockElement();
16673
+ if (((_a = element.block) == null ? void 0 : _a.type) === BlockType.IFRAME && ((_b = element.block.iframeBlock) == null ? void 0 : _b.srcdoc)) {
16674
+ const iframe = (_e = (_d = (_c = baseBlock.getIFrameBlock) == null ? void 0 : _c.call(baseBlock)) == null ? void 0 : _d.getIframe) == null ? void 0 : _e.call(_d);
16675
+ if (iframe == null ? void 0 : iframe.contentDocument) {
16676
+ element.block.iframeBlock.srcdoc = iframe.contentDocument.documentElement.outerHTML;
16677
+ }
16678
+ }
16679
+ });
16680
+ }
16681
+ pickIframeInfo() {
16682
+ const result = [];
16683
+ const { scale } = this.options;
16684
+ this.blockMap.forEach((cacheBlock) => {
16685
+ var _a;
16686
+ const element = cacheBlock.getBlockElement();
16687
+ if (!((_a = element.block) == null ? void 0 : _a.iframeBlock) || element.block.type !== BlockType.IFRAME) {
16688
+ return;
16689
+ }
16690
+ const positionInfo = cacheBlock.getPositionInfo();
16691
+ if (!positionInfo)
16692
+ return;
16693
+ const { pageNo, x, y } = positionInfo;
16694
+ if (!result[pageNo]) {
16695
+ result[pageNo] = [];
16696
+ }
16697
+ result[pageNo].push({
16698
+ x,
16699
+ y,
16700
+ width: element.metrics.width / scale,
16701
+ height: element.metrics.height / scale,
16702
+ src: element.block.iframeBlock.src,
16703
+ srcdoc: element.block.iframeBlock.srcdoc
16704
+ });
16705
+ });
16706
+ return result;
16707
+ }
16617
16708
  }
16618
16709
  const contextmenu$1 = {
16619
16710
  global: {
@@ -18924,6 +19015,22 @@ class Area {
18924
19015
  isSetCursor: false
18925
19016
  });
18926
19017
  }
19018
+ deleteArea(options = {}) {
19019
+ const areaId = options.id || this.getActiveAreaId();
19020
+ if (!areaId)
19021
+ return;
19022
+ const areaInfo = this.areaInfoMap.get(areaId);
19023
+ if (!areaInfo)
19024
+ return;
19025
+ const { positionList } = areaInfo;
19026
+ const elementList = this.draw.getOriginalMainElementList();
19027
+ this.draw.spliceElementList(elementList, positionList[0].index, positionList.length, [], {
19028
+ isIgnoreDeletedRule: true
19029
+ });
19030
+ this.draw.render({
19031
+ isSetCursor: false
19032
+ });
19033
+ }
18927
19034
  }
18928
19035
  class Badge {
18929
19036
  constructor(draw) {
@@ -19724,6 +19831,9 @@ class Draw {
19724
19831
  getTableParticle() {
19725
19832
  return this.tableParticle;
19726
19833
  }
19834
+ getBlockParticle() {
19835
+ return this.blockParticle;
19836
+ }
19727
19837
  getHeader() {
19728
19838
  return this.header;
19729
19839
  }
@@ -19953,6 +20063,7 @@ class Draw {
19953
20063
  if (Number.isInteger(pageNo) && pageNo >= 0 && pageNo < this.pageRowList.length) {
19954
20064
  mainElementList = this.pageRowList[pageNo].flatMap((row) => row.elementList);
19955
20065
  }
20066
+ this.blockParticle.update();
19956
20067
  const data2 = {
19957
20068
  header: this.getHeaderElementList(),
19958
20069
  main: mainElementList,
@@ -21248,6 +21359,7 @@ class Command {
21248
21359
  __publicField(this, "executeInsertArea");
21249
21360
  __publicField(this, "executeSetAreaValue");
21250
21361
  __publicField(this, "executeSetAreaProperties");
21362
+ __publicField(this, "executeDeleteArea");
21251
21363
  __publicField(this, "executeLocationArea");
21252
21364
  __publicField(this, "executeClearGraffiti");
21253
21365
  __publicField(this, "executeAppendElementList");
@@ -21391,6 +21503,7 @@ class Command {
21391
21503
  this.executeInsertArea = adapt.insertArea.bind(adapt);
21392
21504
  this.executeSetAreaValue = adapt.setAreaValue.bind(adapt);
21393
21505
  this.executeSetAreaProperties = adapt.setAreaProperties.bind(adapt);
21506
+ this.executeDeleteArea = adapt.deleteArea.bind(adapt);
21394
21507
  this.executeLocationArea = adapt.locationArea.bind(adapt);
21395
21508
  this.executeClearGraffiti = adapt.clearGraffiti.bind(adapt);
21396
21509
  this.executeInsertElementList = adapt.insertElementList.bind(adapt);
@@ -21490,8 +21603,8 @@ function convertPxToPaperSize(width, height) {
21490
21603
  height: `${height}px`
21491
21604
  };
21492
21605
  }
21493
- function printImageBase64(base64List, options) {
21494
- const { width, height, direction = PaperDirection.VERTICAL } = options;
21606
+ async function print(base64List, options) {
21607
+ const { width, height, direction = PaperDirection.VERTICAL, iframeInfoList = [] } = options;
21495
21608
  const iframe = document.createElement("iframe");
21496
21609
  iframe.style.visibility = "hidden";
21497
21610
  iframe.style.position = "absolute";
@@ -21506,12 +21619,47 @@ function printImageBase64(base64List, options) {
21506
21619
  doc.open();
21507
21620
  const container = document.createElement("div");
21508
21621
  const paperSize = convertPxToPaperSize(width, height);
21509
- base64List.forEach((base64) => {
21622
+ base64List.forEach((base64, pageIndex) => {
21623
+ const pageWrapper = document.createElement("div");
21624
+ pageWrapper.style.position = "relative";
21625
+ pageWrapper.style.width = direction === PaperDirection.HORIZONTAL ? paperSize.height : paperSize.width;
21626
+ pageWrapper.style.height = direction === PaperDirection.HORIZONTAL ? paperSize.width : paperSize.height;
21510
21627
  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;
21628
+ image.style.width = "100%";
21629
+ image.style.height = "100%";
21630
+ image.style.position = "absolute";
21631
+ image.style.left = "0";
21632
+ image.style.top = "0";
21513
21633
  image.src = base64;
21514
- container.append(image);
21634
+ pageWrapper.append(image);
21635
+ const pageIframes = iframeInfoList[pageIndex] || [];
21636
+ pageIframes.forEach((iframeInfo) => {
21637
+ const iframeEl = document.createElement("iframe");
21638
+ iframeEl.style.position = "absolute";
21639
+ iframeEl.style.left = `${iframeInfo.x}px`;
21640
+ iframeEl.style.top = `${iframeInfo.y}px`;
21641
+ iframeEl.style.width = `${iframeInfo.width}px`;
21642
+ iframeEl.style.height = `${iframeInfo.height}px`;
21643
+ iframeEl.style.border = "none";
21644
+ if (iframeInfo.src) {
21645
+ iframeEl.src = iframeInfo.src;
21646
+ } else if (iframeInfo.srcdoc) {
21647
+ const script = `
21648
+ <script>
21649
+ if (!window.__CUSTOM_CANVAS_EDITOR_LOAD_HOOK__) {
21650
+ window.postMessage({ type: '__LOADED_TO_CANVAS_EDITOR__' }, '*')
21651
+ }
21652
+ <\/script>`;
21653
+ const srcdoc = iframeInfo.srcdoc;
21654
+ if (srcdoc.includes("</body>")) {
21655
+ iframeEl.srcdoc = srcdoc.replace("</body>", `${script}</body>`);
21656
+ } else {
21657
+ iframeEl.srcdoc = srcdoc + script;
21658
+ }
21659
+ }
21660
+ pageWrapper.append(iframeEl);
21661
+ });
21662
+ container.append(pageWrapper);
21515
21663
  });
21516
21664
  const style = document.createElement("style");
21517
21665
  const stylesheet = `
@@ -21524,8 +21672,11 @@ function printImageBase64(base64List, options) {
21524
21672
  size: ${paperSize.size} ${direction === PaperDirection.HORIZONTAL ? `landscape` : `portrait`};
21525
21673
  }`;
21526
21674
  style.append(document.createTextNode(stylesheet));
21527
- setTimeout(() => {
21528
- doc.write(`${style.outerHTML}${container.innerHTML}`);
21675
+ doc.write(`${style.outerHTML}${container.innerHTML}`);
21676
+ if (iframeInfoList.length) {
21677
+ await waitIframeLoad(doc);
21678
+ }
21679
+ setTimeout(async () => {
21529
21680
  contentWindow.print();
21530
21681
  doc.close();
21531
21682
  window.addEventListener("mouseover", () => {
@@ -21535,6 +21686,25 @@ function printImageBase64(base64List, options) {
21535
21686
  });
21536
21687
  });
21537
21688
  }
21689
+ async function waitIframeLoad(doc) {
21690
+ const iframeList = Array.from(doc.querySelectorAll("iframe"));
21691
+ const iframePromises = iframeList.map((iframe) => {
21692
+ const iframePromise = new Promise((resolve) => {
21693
+ var _a;
21694
+ if (iframe.srcdoc) {
21695
+ (_a = iframe.contentWindow) == null ? void 0 : _a.addEventListener("message", (e) => {
21696
+ if (e.data.type === "__LOADED_TO_CANVAS_EDITOR__") {
21697
+ resolve(true);
21698
+ }
21699
+ });
21700
+ } else {
21701
+ resolve(true);
21702
+ }
21703
+ });
21704
+ return iframePromise;
21705
+ });
21706
+ await Promise.allSettled(iframePromises);
21707
+ }
21538
21708
  class CommandAdapt {
21539
21709
  constructor(draw) {
21540
21710
  __publicField(this, "draw");
@@ -22646,10 +22816,11 @@ class CommandAdapt {
22646
22816
  pixelRatio: printPixelRatio,
22647
22817
  mode: EditorMode.PRINT
22648
22818
  });
22649
- printImageBase64(base64List, {
22819
+ await print(base64List, {
22650
22820
  width,
22651
22821
  height,
22652
- direction: paperDirection
22822
+ direction: paperDirection,
22823
+ iframeInfoList: this.draw.getBlockParticle().pickIframeInfo()
22653
22824
  });
22654
22825
  if (scale !== 1) {
22655
22826
  this.draw.setPageScale(scale);
@@ -23720,6 +23891,9 @@ class CommandAdapt {
23720
23891
  setAreaProperties(payload) {
23721
23892
  this.draw.getArea().setAreaProperties(payload);
23722
23893
  }
23894
+ deleteArea(options) {
23895
+ this.draw.getArea().deleteArea(options);
23896
+ }
23723
23897
  locationArea(areaId, options) {
23724
23898
  if ((options == null ? void 0 : options.isAppendLastLineBreak) && (options == null ? void 0 : options.position) === LocationPosition.OUTER_AFTER) {
23725
23899
  const elementList = this.draw.getOriginalMainElementList();