@hufe921/canvas-editor 0.9.16 → 0.9.18

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.
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.16";
26
+ const version = "0.9.18";
27
27
  const ZERO = "\u200B";
28
28
  const WRAP = "\n";
29
29
  var RowFlex;
@@ -130,7 +130,18 @@ function mergeObject(source, target) {
130
130
  }
131
131
  return target;
132
132
  }
133
+ function nextTick(fn) {
134
+ setTimeout(() => {
135
+ fn();
136
+ }, 0);
137
+ }
133
138
  const CURSOR_AGENT_HEIGHT = 12;
139
+ const defaultCursorOption = {
140
+ width: 1,
141
+ color: "#000000",
142
+ dragWidth: 2,
143
+ dragColor: "#0000FF"
144
+ };
134
145
  const EDITOR_COMPONENT = "editor-component";
135
146
  const EDITOR_PREFIX = "ce";
136
147
  var ElementType;
@@ -229,11 +240,16 @@ var ImageDisplay;
229
240
  })(ImageDisplay || (ImageDisplay = {}));
230
241
  class ImageParticle {
231
242
  constructor(draw) {
243
+ __publicField(this, "draw");
232
244
  __publicField(this, "options");
233
245
  __publicField(this, "imageCache");
246
+ this.draw = draw;
234
247
  this.options = draw.getOptions();
235
248
  this.imageCache = new Map();
236
249
  }
250
+ addImageObserver(promise) {
251
+ this.draw.getImageObserver().add(promise);
252
+ }
237
253
  render(ctx, element, x, y) {
238
254
  const { scale } = this.options;
239
255
  const width = element.width * scale;
@@ -242,12 +258,19 @@ class ImageParticle {
242
258
  const img = this.imageCache.get(element.id);
243
259
  ctx.drawImage(img, x, y, width, height);
244
260
  } else {
245
- const img = new Image();
246
- img.src = element.value;
247
- img.onload = () => {
248
- ctx.drawImage(img, x, y, width, height);
249
- this.imageCache.set(element.id, img);
250
- };
261
+ const imageLoadPromise = new Promise((resolve, reject) => {
262
+ const img = new Image();
263
+ img.src = element.value;
264
+ img.onload = () => {
265
+ ctx.drawImage(img, x, y, width, height);
266
+ this.imageCache.set(element.id, img);
267
+ resolve(element);
268
+ };
269
+ img.onerror = (error) => {
270
+ reject(error);
271
+ };
272
+ });
273
+ this.addImageObserver(imageLoadPromise);
251
274
  }
252
275
  }
253
276
  }
@@ -3195,12 +3218,19 @@ class LaTexParticle extends ImageParticle {
3195
3218
  const img = this.imageCache.get(element.value);
3196
3219
  ctx.drawImage(img, x, y, width, height);
3197
3220
  } else {
3198
- const img = new Image();
3199
- img.src = element.laTexSVG;
3200
- img.onload = () => {
3201
- ctx.drawImage(img, x, y, width, height);
3202
- this.imageCache.set(element.value, img);
3203
- };
3221
+ const laTexLoadPromise = new Promise((resolve, reject) => {
3222
+ const img = new Image();
3223
+ img.src = element.laTexSVG;
3224
+ img.onload = () => {
3225
+ ctx.drawImage(img, x, y, width, height);
3226
+ this.imageCache.set(element.value, img);
3227
+ resolve(element);
3228
+ };
3229
+ img.onerror = (error) => {
3230
+ reject(error);
3231
+ };
3232
+ });
3233
+ this.addImageObserver(laTexLoadPromise);
3204
3234
  }
3205
3235
  }
3206
3236
  }
@@ -3961,12 +3991,12 @@ class Cursor {
3961
3991
  clearAgentDomValue() {
3962
3992
  return this.getAgentDom().value = "";
3963
3993
  }
3964
- drawCursor() {
3965
- const isReadonly = this.draw.isReadonly();
3994
+ drawCursor(payload) {
3966
3995
  const cursorPosition = this.position.getCursorPosition();
3967
3996
  if (!cursorPosition)
3968
3997
  return;
3969
- const { scale } = this.options;
3998
+ const { scale, cursor } = this.options;
3999
+ const { color, width, isBlink = true } = __spreadValues(__spreadValues({}, cursor), payload);
3970
4000
  const height = this.draw.getHeight();
3971
4001
  const pageGap = this.draw.getPageGap();
3972
4002
  const { metrics, coordinate: { leftTop, rightTop }, ascent, pageNo } = cursorPosition;
@@ -3983,13 +4013,21 @@ class Cursor {
3983
4013
  const cursorLeft = rightTop[0];
3984
4014
  agentCursorDom.style.left = `${cursorLeft}px`;
3985
4015
  agentCursorDom.style.top = `${cursorTop + cursorHeight - CURSOR_AGENT_HEIGHT * scale}px`;
4016
+ const isReadonly = this.draw.isReadonly();
4017
+ this.cursorDom.style.width = `${width}px`;
4018
+ this.cursorDom.style.backgroundColor = color;
3986
4019
  this.cursorDom.style.left = `${cursorLeft}px`;
3987
4020
  this.cursorDom.style.top = `${cursorTop}px`;
3988
4021
  this.cursorDom.style.display = isReadonly ? "none" : "block";
3989
4022
  this.cursorDom.style.height = `${cursorHeight}px`;
3990
- setTimeout(() => {
3991
- this.cursorDom.classList.add(`${EDITOR_PREFIX}-cursor--animation`);
3992
- }, 200);
4023
+ const animationClassName = `${EDITOR_PREFIX}-cursor--animation`;
4024
+ if (isBlink) {
4025
+ setTimeout(() => {
4026
+ this.cursorDom.classList.add(animationClassName);
4027
+ }, 200);
4028
+ } else {
4029
+ this.cursorDom.classList.remove(animationClassName);
4030
+ }
3993
4031
  }
3994
4032
  recoveryCursor() {
3995
4033
  this.cursorDom.style.display = "none";
@@ -4246,7 +4284,7 @@ function mousedown(evt, host) {
4246
4284
  curIndex,
4247
4285
  isSubmitHistory: isSetCheckbox,
4248
4286
  isSetCursor: !isDirectHitImage && !isDirectHitCheckbox,
4249
- isComputeRowList: false
4287
+ isCompute: false
4250
4288
  });
4251
4289
  }
4252
4290
  const previewer = draw.getPreviewer();
@@ -4396,7 +4434,7 @@ function mousemove(evt, host) {
4396
4434
  draw.render({
4397
4435
  isSubmitHistory: false,
4398
4436
  isSetCursor: false,
4399
- isComputeRowList: false
4437
+ isCompute: false
4400
4438
  });
4401
4439
  }
4402
4440
  const isApple = typeof navigator !== "undefined" && /Mac OS X/.test(navigator.userAgent);
@@ -4516,7 +4554,7 @@ function keydown(evt, host) {
4516
4554
  curIndex: isCollapsed2 ? anchorStartIndex : void 0,
4517
4555
  isSetCursor: isCollapsed2,
4518
4556
  isSubmitHistory: false,
4519
- isComputeRowList: false
4557
+ isCompute: false
4520
4558
  });
4521
4559
  evt.preventDefault();
4522
4560
  }
@@ -4550,7 +4588,7 @@ function keydown(evt, host) {
4550
4588
  curIndex: isCollapsed2 ? anchorStartIndex : void 0,
4551
4589
  isSetCursor: isCollapsed2,
4552
4590
  isSubmitHistory: false,
4553
- isComputeRowList: false
4591
+ isCompute: false
4554
4592
  });
4555
4593
  evt.preventDefault();
4556
4594
  }
@@ -4619,7 +4657,7 @@ function keydown(evt, host) {
4619
4657
  curIndex: isCollapsed2 ? anchorStartIndex : void 0,
4620
4658
  isSetCursor: isCollapsed2,
4621
4659
  isSubmitHistory: false,
4622
- isComputeRowList: false
4660
+ isCompute: false
4623
4661
  });
4624
4662
  }
4625
4663
  } else if (isMod(evt) && evt.key === KeyMap.Z) {
@@ -4674,7 +4712,8 @@ function input(data2, host) {
4674
4712
  if (control.isPartRangeInControlOutside()) {
4675
4713
  return;
4676
4714
  }
4677
- if (!host.isComposing) {
4715
+ const isComposing = host.isComposing;
4716
+ if (!isComposing) {
4678
4717
  const cursor = draw.getCursor();
4679
4718
  cursor.clearAgentDomValue();
4680
4719
  } else {
@@ -4707,7 +4746,7 @@ function input(data2, host) {
4707
4746
  }
4708
4747
  });
4709
4748
  }
4710
- if (host.isComposing) {
4749
+ if (isComposing) {
4711
4750
  newElement.underline = true;
4712
4751
  }
4713
4752
  return newElement;
@@ -4727,9 +4766,10 @@ function input(data2, host) {
4727
4766
  }
4728
4767
  rangeManager.setRange(curIndex, curIndex);
4729
4768
  draw.render({
4730
- curIndex
4769
+ curIndex,
4770
+ isSubmitHistory: !isComposing
4731
4771
  });
4732
- if (host.isComposing) {
4772
+ if (isComposing) {
4733
4773
  host.compositionInfo = {
4734
4774
  elementList,
4735
4775
  value: text,
@@ -4853,7 +4893,7 @@ function dblclick(host) {
4853
4893
  draw.render({
4854
4894
  isSubmitHistory: false,
4855
4895
  isSetCursor: false,
4856
- isComputeRowList: false
4896
+ isCompute: false
4857
4897
  });
4858
4898
  }
4859
4899
  function threeClick(host) {
@@ -4891,7 +4931,7 @@ function threeClick(host) {
4891
4931
  draw.render({
4892
4932
  isSubmitHistory: false,
4893
4933
  isSetCursor: false,
4894
- isComputeRowList: false
4934
+ isCompute: false
4895
4935
  });
4896
4936
  }
4897
4937
  var click = {
@@ -4952,7 +4992,12 @@ function dragover(evt, host) {
4952
4992
  position.setCursorPosition(positionList[curIndex]);
4953
4993
  }
4954
4994
  const cursor = draw.getCursor();
4955
- cursor.drawCursor();
4995
+ const { cursor: { dragColor, dragWidth } } = draw.getOptions();
4996
+ cursor.drawCursor({
4997
+ width: dragWidth,
4998
+ color: dragColor,
4999
+ isBlink: false
5000
+ });
4956
5001
  }
4957
5002
  var drag = {
4958
5003
  dragover
@@ -5043,7 +5088,7 @@ class CanvasEvent {
5043
5088
  this.draw.render({
5044
5089
  isSubmitHistory: false,
5045
5090
  isSetCursor: false,
5046
- isComputeRowList: false
5091
+ isCompute: false
5047
5092
  });
5048
5093
  }
5049
5094
  mousemove(evt) {
@@ -5264,6 +5309,94 @@ class Position {
5264
5309
  setPositionList(payload) {
5265
5310
  this.positionList = payload;
5266
5311
  }
5312
+ computePageRowPosition(payload) {
5313
+ const { positionList, rowList, pageNo, startX, startY, startIndex, innerWidth } = payload;
5314
+ const { scale, tdPadding } = this.options;
5315
+ let x = startX;
5316
+ let y = startY;
5317
+ let index2 = startIndex;
5318
+ for (let i = 0; i < rowList.length; i++) {
5319
+ const curRow = rowList[i];
5320
+ if (curRow.rowFlex === RowFlex.CENTER) {
5321
+ x += (innerWidth - curRow.width) / 2;
5322
+ } else if (curRow.rowFlex === RowFlex.RIGHT) {
5323
+ x += innerWidth - curRow.width;
5324
+ }
5325
+ const tablePreX = x;
5326
+ const tablePreY = y;
5327
+ for (let j = 0; j < curRow.elementList.length; j++) {
5328
+ const element = curRow.elementList[j];
5329
+ const metrics = element.metrics;
5330
+ const offsetY = element.imgDisplay !== ImageDisplay.INLINE && element.type === ElementType.IMAGE || element.type === ElementType.LATEX ? curRow.ascent - metrics.height : curRow.ascent;
5331
+ const positionItem = {
5332
+ pageNo,
5333
+ index: index2,
5334
+ value: element.value,
5335
+ rowNo: i,
5336
+ metrics,
5337
+ ascent: offsetY,
5338
+ lineHeight: curRow.height,
5339
+ isLastLetter: j === curRow.elementList.length - 1,
5340
+ coordinate: {
5341
+ leftTop: [x, y],
5342
+ leftBottom: [x, y + curRow.height],
5343
+ rightTop: [x + metrics.width, y],
5344
+ rightBottom: [x + metrics.width, y + curRow.height]
5345
+ }
5346
+ };
5347
+ positionList.push(positionItem);
5348
+ index2++;
5349
+ x += metrics.width;
5350
+ if (element.type === ElementType.TABLE) {
5351
+ const tdGap = tdPadding * 2;
5352
+ for (let t = 0; t < element.trList.length; t++) {
5353
+ const tr = element.trList[t];
5354
+ for (let d = 0; d < tr.tdList.length; d++) {
5355
+ const td = tr.tdList[d];
5356
+ td.positionList = [];
5357
+ const drawRowResult = this.computePageRowPosition({
5358
+ positionList: td.positionList,
5359
+ rowList: td.rowList,
5360
+ pageNo,
5361
+ startIndex: 0,
5362
+ startX: (td.x + tdPadding) * scale + tablePreX,
5363
+ startY: td.y * scale + tablePreY,
5364
+ innerWidth: (td.width - tdGap) * scale
5365
+ });
5366
+ x = drawRowResult.x;
5367
+ y = drawRowResult.y;
5368
+ }
5369
+ }
5370
+ x = tablePreX;
5371
+ y = tablePreY;
5372
+ }
5373
+ }
5374
+ x = startX;
5375
+ y += curRow.height;
5376
+ }
5377
+ return { x, y, index: index2 };
5378
+ }
5379
+ computePositionList() {
5380
+ this.positionList = [];
5381
+ const innerWidth = this.draw.getInnerWidth();
5382
+ const pageRowList = this.draw.getPageRowList();
5383
+ const margins = this.draw.getMargins();
5384
+ const startX = margins[3];
5385
+ const startY = margins[0];
5386
+ for (let i = 0; i < pageRowList.length; i++) {
5387
+ const rowList = pageRowList[i];
5388
+ const startIndex = rowList[0].startIndex;
5389
+ this.computePageRowPosition({
5390
+ positionList: this.positionList,
5391
+ rowList,
5392
+ pageNo: i,
5393
+ startIndex,
5394
+ startX,
5395
+ startY,
5396
+ innerWidth
5397
+ });
5398
+ }
5399
+ }
5267
5400
  setCursorPosition(position) {
5268
5401
  this.cursorPosition = position;
5269
5402
  }
@@ -6015,7 +6148,10 @@ class Search {
6015
6148
  const searchMatchIndexList = this.getSearchNavigateIndexList();
6016
6149
  if (searchMatchIndexList.includes(s)) {
6017
6150
  ctx.fillStyle = searchNavigateMatchColor;
6018
- this.searchNavigateScrollIntoView(position);
6151
+ const preSearchMatch = this.searchMatchList[s - 1];
6152
+ if (!preSearchMatch || preSearchMatch.groupId !== searchMatch.groupId) {
6153
+ this.searchNavigateScrollIntoView(position);
6154
+ }
6019
6155
  } else {
6020
6156
  ctx.fillStyle = searchMatchColor;
6021
6157
  }
@@ -6153,46 +6289,12 @@ class PageNumber {
6153
6289
  class ScrollObserver {
6154
6290
  constructor(draw) {
6155
6291
  __publicField(this, "draw");
6156
- __publicField(this, "options");
6157
- __publicField(this, "pageContainer");
6158
- __publicField(this, "pageHeight");
6159
6292
  __publicField(this, "_observer", debounce(() => {
6160
- const rect = this.pageContainer.getBoundingClientRect();
6161
- const top = Math.abs(rect.top);
6162
- const bottom = top + window.innerHeight;
6163
- const pageList = this.draw.getPageList();
6164
- const visiblePageNoList = [];
6165
- let intersectionPageNo = 0;
6166
- let intersectionMaxHeight = 0;
6167
- for (let i = 0; i < pageList.length; i++) {
6168
- const curTop = i * this.pageHeight;
6169
- const curBottom = (i + 1) * this.pageHeight;
6170
- if (curTop > bottom)
6171
- break;
6172
- if (curBottom < top)
6173
- continue;
6174
- let intersectionHeight = 0;
6175
- if (curTop < top && curBottom < bottom) {
6176
- intersectionHeight = curBottom - top;
6177
- } else if (curTop > top && curBottom > bottom) {
6178
- intersectionHeight = bottom - curTop;
6179
- } else {
6180
- intersectionHeight = rect.height;
6181
- }
6182
- if (intersectionHeight > intersectionMaxHeight) {
6183
- intersectionMaxHeight = intersectionHeight;
6184
- intersectionPageNo = i;
6185
- }
6186
- visiblePageNoList.push(i);
6187
- }
6293
+ const { intersectionPageNo, visiblePageNoList } = this.getPageVisibleInfo();
6188
6294
  this.draw.setIntersectionPageNo(intersectionPageNo);
6189
6295
  this.draw.setVisiblePageNoList(visiblePageNoList);
6190
6296
  }, 150));
6191
6297
  this.draw = draw;
6192
- this.options = draw.getOptions();
6193
- this.pageContainer = draw.getPageContainer();
6194
- const { height, pageGap } = this.options;
6195
- this.pageHeight = height + pageGap;
6196
6298
  setTimeout(() => {
6197
6299
  if (!window.scrollY) {
6198
6300
  this._observer();
@@ -6206,6 +6308,37 @@ class ScrollObserver {
6206
6308
  removeEvent() {
6207
6309
  document.removeEventListener("scroll", this._observer);
6208
6310
  }
6311
+ getElementVisibleInfo(element) {
6312
+ const rect = element.getBoundingClientRect();
6313
+ const viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight);
6314
+ const visibleHeight = Math.min(rect.bottom, viewHeight) - Math.max(rect.top, 0);
6315
+ return {
6316
+ intersectionHeight: visibleHeight > 0 ? visibleHeight : 0
6317
+ };
6318
+ }
6319
+ getPageVisibleInfo() {
6320
+ const pageList = this.draw.getPageList();
6321
+ const visiblePageNoList = [];
6322
+ let intersectionPageNo = 0;
6323
+ let intersectionMaxHeight = 0;
6324
+ for (let i = 0; i < pageList.length; i++) {
6325
+ const curPage = pageList[i];
6326
+ const { intersectionHeight } = this.getElementVisibleInfo(curPage);
6327
+ if (intersectionMaxHeight && !intersectionHeight)
6328
+ break;
6329
+ if (intersectionHeight) {
6330
+ visiblePageNoList.push(i);
6331
+ }
6332
+ if (intersectionHeight > intersectionMaxHeight) {
6333
+ intersectionMaxHeight = intersectionHeight;
6334
+ intersectionPageNo = i;
6335
+ }
6336
+ }
6337
+ return {
6338
+ intersectionPageNo,
6339
+ visiblePageNoList
6340
+ };
6341
+ }
6209
6342
  }
6210
6343
  var MoveDirection;
6211
6344
  (function(MoveDirection2) {
@@ -6216,13 +6349,11 @@ var MoveDirection;
6216
6349
  })(MoveDirection || (MoveDirection = {}));
6217
6350
  class SelectionObserver {
6218
6351
  constructor() {
6219
- __publicField(this, "threshold");
6352
+ __publicField(this, "step", 5);
6353
+ __publicField(this, "thresholdPoints", [70, 40, 10, 20]);
6220
6354
  __publicField(this, "requestAnimationFrameId");
6221
- __publicField(this, "tippingPoints");
6222
6355
  __publicField(this, "isMousedown");
6223
6356
  __publicField(this, "isMoving");
6224
- __publicField(this, "clientWidth");
6225
- __publicField(this, "clientHeight");
6226
6357
  __publicField(this, "_mousedown", () => {
6227
6358
  this.isMousedown = true;
6228
6359
  });
@@ -6234,25 +6365,23 @@ class SelectionObserver {
6234
6365
  if (!this.isMousedown)
6235
6366
  return;
6236
6367
  const { x, y } = evt;
6237
- if (y < this.tippingPoints[0]) {
6368
+ const clientWidth = document.documentElement.clientWidth;
6369
+ const clientHeight = document.documentElement.clientHeight;
6370
+ if (y < this.thresholdPoints[0]) {
6238
6371
  this._startMove(MoveDirection.UP);
6239
- } else if (this.clientHeight - y <= this.tippingPoints[1]) {
6372
+ } else if (clientHeight - y <= this.thresholdPoints[1]) {
6240
6373
  this._startMove(MoveDirection.DOWN);
6241
- } else if (x < this.tippingPoints[2]) {
6374
+ } else if (x < this.thresholdPoints[2]) {
6242
6375
  this._startMove(MoveDirection.LEFT);
6243
- } else if (this.clientWidth - x < this.tippingPoints[3]) {
6376
+ } else if (clientWidth - x < this.thresholdPoints[3]) {
6244
6377
  this._startMove(MoveDirection.RIGHT);
6245
6378
  } else {
6246
6379
  this._stopMove();
6247
6380
  }
6248
6381
  });
6249
- this.threshold = 10;
6250
- this.tippingPoints = [70, 40, 10, 20];
6251
- this.requestAnimationFrameId = -1;
6382
+ this.requestAnimationFrameId = null;
6252
6383
  this.isMousedown = false;
6253
6384
  this.isMoving = false;
6254
- this.clientWidth = 0;
6255
- this.clientHeight = 0;
6256
6385
  this._addEvent();
6257
6386
  }
6258
6387
  _addEvent() {
@@ -6266,34 +6395,31 @@ class SelectionObserver {
6266
6395
  document.removeEventListener("mouseup", this._mouseup);
6267
6396
  }
6268
6397
  _move(direction) {
6269
- const x = window.screenX;
6270
- const y = window.screenY;
6398
+ const x = window.scrollX;
6399
+ const y = window.scrollY;
6271
6400
  if (direction === MoveDirection.DOWN) {
6272
- window.scrollBy(x, y + this.threshold);
6401
+ window.scrollTo(x, y + this.step);
6273
6402
  } else if (direction === MoveDirection.UP) {
6274
- window.scrollBy(x, y - this.threshold);
6403
+ window.scrollTo(x, y - this.step);
6275
6404
  } else if (direction === MoveDirection.LEFT) {
6276
- window.scrollBy(x - this.threshold, y);
6405
+ window.scrollTo(x - this.step, y);
6277
6406
  } else {
6278
- window.scrollBy(x + this.threshold, y);
6407
+ window.scrollTo(x + this.step, y);
6279
6408
  }
6280
6409
  this.requestAnimationFrameId = window.requestAnimationFrame(this._move.bind(this, direction));
6281
6410
  }
6282
6411
  _startMove(direction) {
6283
6412
  if (this.isMoving)
6284
6413
  return;
6285
- this.clientWidth = document.documentElement.clientWidth;
6286
- this.clientHeight = document.documentElement.clientHeight;
6287
6414
  this.isMoving = true;
6288
- this.requestAnimationFrameId = window.requestAnimationFrame(this._move.bind(this, direction));
6415
+ this._move(direction);
6289
6416
  }
6290
6417
  _stopMove() {
6291
- if (!this.isMoving)
6292
- return;
6293
- if (~this.requestAnimationFrameId) {
6418
+ if (this.requestAnimationFrameId) {
6294
6419
  window.cancelAnimationFrame(this.requestAnimationFrameId);
6420
+ this.requestAnimationFrameId = null;
6421
+ this.isMoving = false;
6295
6422
  }
6296
- this.isMoving = false;
6297
6423
  }
6298
6424
  }
6299
6425
  class TableParticle {
@@ -7368,8 +7494,9 @@ class Control {
7368
7494
  if (nextIndex === elementList.length) {
7369
7495
  rightIndex = nextIndex - 1;
7370
7496
  }
7371
- if (!~leftIndex || !~rightIndex)
7497
+ if (!~leftIndex && !~rightIndex)
7372
7498
  return startIndex;
7499
+ leftIndex = ~leftIndex ? leftIndex : 0;
7373
7500
  elementList.splice(leftIndex + 1, rightIndex - leftIndex);
7374
7501
  return leftIndex;
7375
7502
  }
@@ -8644,6 +8771,21 @@ class I18n {
8644
8771
  return value;
8645
8772
  }
8646
8773
  }
8774
+ class ImageObserver {
8775
+ constructor() {
8776
+ __publicField(this, "promiseList");
8777
+ this.promiseList = [];
8778
+ }
8779
+ add(payload) {
8780
+ this.promiseList.push(payload);
8781
+ }
8782
+ clearAll() {
8783
+ this.promiseList = [];
8784
+ }
8785
+ allSettled() {
8786
+ return Promise.allSettled(this.promiseList);
8787
+ }
8788
+ }
8647
8789
  class Draw {
8648
8790
  constructor(rootContainer, options, elementList, listener) {
8649
8791
  __publicField(this, "container");
@@ -8689,11 +8831,14 @@ class Draw {
8689
8831
  __publicField(this, "workerManager");
8690
8832
  __publicField(this, "scrollObserver");
8691
8833
  __publicField(this, "selectionObserver");
8834
+ __publicField(this, "imageObserver");
8692
8835
  __publicField(this, "rowList");
8836
+ __publicField(this, "pageRowList");
8693
8837
  __publicField(this, "painterStyle");
8694
8838
  __publicField(this, "painterOptions");
8695
8839
  __publicField(this, "visiblePageNoList");
8696
8840
  __publicField(this, "intersectionPageNo");
8841
+ __publicField(this, "lazyRenderIntersectionObserver");
8697
8842
  this.container = this._wrapContainer(rootContainer);
8698
8843
  this.pageList = [];
8699
8844
  this.ctxList = [];
@@ -8735,6 +8880,7 @@ class Draw {
8735
8880
  this.control = new Control(this);
8736
8881
  this.scrollObserver = new ScrollObserver(this);
8737
8882
  this.selectionObserver = new SelectionObserver();
8883
+ this.imageObserver = new ImageObserver();
8738
8884
  this.canvasEvent = new CanvasEvent(this);
8739
8885
  this.cursor = new Cursor(this, this.canvasEvent);
8740
8886
  this.canvasEvent.register();
@@ -8742,10 +8888,12 @@ class Draw {
8742
8888
  this.globalEvent.register();
8743
8889
  this.workerManager = new WorkerManager(this);
8744
8890
  this.rowList = [];
8891
+ this.pageRowList = [];
8745
8892
  this.painterStyle = null;
8746
8893
  this.painterOptions = null;
8747
8894
  this.visiblePageNoList = [];
8748
8895
  this.intersectionPageNo = 0;
8896
+ this.lazyRenderIntersectionObserver = null;
8749
8897
  this.render({ isSetCursor: false });
8750
8898
  }
8751
8899
  getMode() {
@@ -8840,6 +8988,12 @@ class Draw {
8840
8988
  getPageList() {
8841
8989
  return this.pageList;
8842
8990
  }
8991
+ getRowList() {
8992
+ return this.rowList;
8993
+ }
8994
+ getPageRowList() {
8995
+ return this.pageRowList;
8996
+ }
8843
8997
  getCtx() {
8844
8998
  return this.ctxList[this.pageNo];
8845
8999
  }
@@ -8870,8 +9024,11 @@ class Draw {
8870
9024
  if (!payload.length)
8871
9025
  return;
8872
9026
  const activeControl = this.control.getActiveControl();
8873
- if (activeControl)
8874
- return;
9027
+ if (activeControl) {
9028
+ const element = activeControl.getElement();
9029
+ if (element.controlComponent !== ControlComponent.POSTFIX)
9030
+ return;
9031
+ }
8875
9032
  const isPartRangeInControlOutside = this.control.isPartRangeInControlOutside();
8876
9033
  if (isPartRangeInControlOutside)
8877
9034
  return;
@@ -8937,13 +9094,23 @@ class Draw {
8937
9094
  getWorkerManager() {
8938
9095
  return this.workerManager;
8939
9096
  }
9097
+ getImageObserver() {
9098
+ return this.imageObserver;
9099
+ }
8940
9100
  getI18n() {
8941
9101
  return this.i18n;
8942
9102
  }
8943
9103
  getRowCount() {
8944
9104
  return this.rowList.length;
8945
9105
  }
8946
- getDataURL() {
9106
+ async getDataURL() {
9107
+ this.render({
9108
+ isLazy: false,
9109
+ isCompute: false,
9110
+ isSetCursor: false,
9111
+ isSubmitHistory: false
9112
+ });
9113
+ await this.imageObserver.allSettled();
8947
9114
  return this.pageList.map((c) => c.toDataURL());
8948
9115
  }
8949
9116
  getPainterStyle() {
@@ -9108,7 +9275,6 @@ class Draw {
9108
9275
  var _a, _b, _c, _d;
9109
9276
  const { defaultSize, defaultRowMargin, scale, tdPadding, defaultTabWidth } = this.options;
9110
9277
  const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight();
9111
- const tdGap = tdPadding * 2;
9112
9278
  const canvas = document.createElement("canvas");
9113
9279
  const ctx = canvas.getContext("2d");
9114
9280
  const rowList = [];
@@ -9118,6 +9284,7 @@ class Draw {
9118
9284
  height: 0,
9119
9285
  ascent: 0,
9120
9286
  elementList: [],
9287
+ startIndex: 0,
9121
9288
  rowFlex: (_a = elementList == null ? void 0 : elementList[1]) == null ? void 0 : _a.rowFlex
9122
9289
  });
9123
9290
  }
@@ -9149,6 +9316,7 @@ class Draw {
9149
9316
  }
9150
9317
  metrics.boundingBoxAscent = 0;
9151
9318
  } else if (element.type === ElementType.TABLE) {
9319
+ const tdGap = tdPadding * 2;
9152
9320
  this.tableParticle.computeRowColInfo(element);
9153
9321
  const trList = element.trList;
9154
9322
  for (let t = 0; t < trList.length; t++) {
@@ -9302,6 +9470,7 @@ class Draw {
9302
9470
  rowList.push({
9303
9471
  width: metrics.width,
9304
9472
  height,
9473
+ startIndex: i,
9305
9474
  elementList: [rowElement],
9306
9475
  ascent,
9307
9476
  rowFlex: (_d = elementList[i + 1]) == null ? void 0 : _d.rowFlex,
@@ -9322,6 +9491,44 @@ class Draw {
9322
9491
  }
9323
9492
  return rowList;
9324
9493
  }
9494
+ _computePageList() {
9495
+ var _a;
9496
+ const pageRowList = [[]];
9497
+ const { pageMode } = this.options;
9498
+ const height = this.getHeight();
9499
+ const margins = this.getMargins();
9500
+ const marginHeight = margins[0] + margins[2];
9501
+ let pageHeight = marginHeight;
9502
+ let pageNo = 0;
9503
+ if (pageMode === PageMode.CONTINUITY) {
9504
+ pageRowList[0] = this.rowList;
9505
+ pageHeight += this.rowList.reduce((pre, cur) => pre + cur.height, 0);
9506
+ const dpr = window.devicePixelRatio;
9507
+ const pageDom = this.pageList[0];
9508
+ const pageDomHeight = Number(pageDom.style.height.replace("px", ""));
9509
+ if (pageHeight > pageDomHeight) {
9510
+ pageDom.style.height = `${pageHeight}px`;
9511
+ pageDom.height = pageHeight * dpr;
9512
+ } else {
9513
+ const reduceHeight = pageHeight < height ? height : pageHeight;
9514
+ pageDom.style.height = `${reduceHeight}px`;
9515
+ pageDom.height = reduceHeight * dpr;
9516
+ }
9517
+ } else {
9518
+ for (let i = 0; i < this.rowList.length; i++) {
9519
+ const row = this.rowList[i];
9520
+ if (row.height + pageHeight > height || ((_a = this.rowList[i - 1]) == null ? void 0 : _a.isPageBreak)) {
9521
+ pageHeight = marginHeight + row.height;
9522
+ pageRowList.push([row]);
9523
+ pageNo++;
9524
+ } else {
9525
+ pageHeight += row.height;
9526
+ pageRowList[pageNo].push(row);
9527
+ }
9528
+ }
9529
+ }
9530
+ return pageRowList;
9531
+ }
9325
9532
  _drawRichText(ctx) {
9326
9533
  this.underline.render(ctx);
9327
9534
  this.strikeout.render(ctx);
@@ -9329,22 +9536,12 @@ class Draw {
9329
9536
  this.textParticle.complete();
9330
9537
  }
9331
9538
  _drawRow(ctx, payload) {
9332
- const { positionList, rowList, pageNo, startX, startY, startIndex, innerWidth } = payload;
9539
+ const { rowList, pageNo, positionList, startIndex } = payload;
9333
9540
  const { scale, tdPadding } = this.options;
9334
9541
  const { isCrossRowCol, tableId } = this.range.getRange();
9335
- const tdGap = tdPadding * 2;
9336
- let x = startX;
9337
- let y = startY;
9338
9542
  let index2 = startIndex;
9339
9543
  for (let i = 0; i < rowList.length; i++) {
9340
9544
  const curRow = rowList[i];
9341
- if (curRow.rowFlex === RowFlex.CENTER) {
9342
- x += (innerWidth - curRow.width) / 2;
9343
- } else if (curRow.rowFlex === RowFlex.RIGHT) {
9344
- x += innerWidth - curRow.width;
9345
- }
9346
- const tablePreX = x;
9347
- const tablePreY = y;
9348
9545
  const rangeRecord = {
9349
9546
  x: 0,
9350
9547
  y: 0,
@@ -9355,24 +9552,7 @@ class Draw {
9355
9552
  for (let j = 0; j < curRow.elementList.length; j++) {
9356
9553
  const element = curRow.elementList[j];
9357
9554
  const metrics = element.metrics;
9358
- const offsetY = element.imgDisplay !== ImageDisplay.INLINE && element.type === ElementType.IMAGE || element.type === ElementType.LATEX ? curRow.ascent - metrics.height : curRow.ascent;
9359
- const positionItem = {
9360
- pageNo,
9361
- index: index2,
9362
- value: element.value,
9363
- rowNo: i,
9364
- metrics,
9365
- ascent: offsetY,
9366
- lineHeight: curRow.height,
9367
- isLastLetter: j === curRow.elementList.length - 1,
9368
- coordinate: {
9369
- leftTop: [x, y],
9370
- leftBottom: [x, y + curRow.height],
9371
- rightTop: [x + metrics.width, y],
9372
- rightBottom: [x + metrics.width, y + curRow.height]
9373
- }
9374
- };
9375
- positionList.push(positionItem);
9555
+ const { ascent: offsetY, coordinate: { leftTop: [x, y] } } = positionList[curRow.startIndex + j];
9376
9556
  if (element.type === ElementType.IMAGE) {
9377
9557
  this._drawRichText(ctx);
9378
9558
  this.imageParticle.render(ctx, element, x, y + offsetY);
@@ -9461,42 +9641,33 @@ class Draw {
9461
9641
  }
9462
9642
  }
9463
9643
  index2++;
9464
- x += metrics.width;
9465
9644
  if (element.type === ElementType.TABLE) {
9645
+ const tdGap = tdPadding * 2;
9466
9646
  for (let t = 0; t < element.trList.length; t++) {
9467
9647
  const tr = element.trList[t];
9468
9648
  for (let d = 0; d < tr.tdList.length; d++) {
9469
9649
  const td = tr.tdList[d];
9470
- td.positionList = [];
9471
- const drawRowResult = this._drawRow(ctx, {
9650
+ this._drawRow(ctx, {
9472
9651
  positionList: td.positionList,
9473
9652
  rowList: td.rowList,
9474
9653
  pageNo,
9475
9654
  startIndex: 0,
9476
- startX: (td.x + tdPadding) * scale + tablePreX,
9477
- startY: td.y * scale + tablePreY,
9478
9655
  innerWidth: (td.width - tdGap) * scale
9479
9656
  });
9480
- x = drawRowResult.x;
9481
- y = drawRowResult.y;
9482
9657
  }
9483
9658
  }
9484
- x = tablePreX;
9485
- y = tablePreY;
9486
9659
  }
9487
9660
  }
9488
9661
  this._drawRichText(ctx);
9489
9662
  if (rangeRecord.width && rangeRecord.height) {
9490
- const { x: x2, y: y2, width, height } = rangeRecord;
9491
- this.range.render(ctx, x2, y2, width, height);
9663
+ const { x, y, width, height } = rangeRecord;
9664
+ this.range.render(ctx, x, y, width, height);
9492
9665
  }
9493
9666
  if (isCrossRowCol && tableRangeElement && tableRangeElement.id === tableId) {
9667
+ const { coordinate: { leftTop: [x, y] } } = positionList[curRow.startIndex];
9494
9668
  this.tableParticle.drawRange(ctx, tableRangeElement, x, y);
9495
9669
  }
9496
- x = startX;
9497
- y += curRow.height;
9498
9670
  }
9499
- return { x, y, index: index2 };
9500
9671
  }
9501
9672
  _clearPage(pageNo) {
9502
9673
  const ctx = this.ctxList[pageNo];
@@ -9506,28 +9677,19 @@ class Draw {
9506
9677
  }
9507
9678
  _drawPage(positionList, rowList, pageNo) {
9508
9679
  const { pageMode } = this.options;
9509
- const margins = this.getMargins();
9510
9680
  const innerWidth = this.getInnerWidth();
9511
9681
  const ctx = this.ctxList[pageNo];
9512
9682
  this._clearPage(pageNo);
9513
9683
  this.background.render(ctx);
9514
- const leftTopPoint = [margins[3], margins[0]];
9515
9684
  this.margin.render(ctx);
9516
- let x = leftTopPoint[0];
9517
- let y = leftTopPoint[1];
9518
- let index2 = positionList.length;
9519
- const drawRowResult = this._drawRow(ctx, {
9685
+ const index2 = rowList[0].startIndex;
9686
+ this._drawRow(ctx, {
9520
9687
  positionList,
9521
9688
  rowList,
9522
9689
  pageNo,
9523
9690
  startIndex: index2,
9524
- startX: x,
9525
- startY: y,
9526
9691
  innerWidth
9527
9692
  });
9528
- x = drawRowResult.x;
9529
- y = drawRowResult.y;
9530
- index2 = drawRowResult.index;
9531
9693
  this.header.render(ctx);
9532
9694
  this.pageNumber.render(ctx, pageNo);
9533
9695
  if (this.search.getSearchKeyword()) {
@@ -9537,76 +9699,67 @@ class Draw {
9537
9699
  this.waterMark.render(ctx);
9538
9700
  }
9539
9701
  }
9702
+ _lazyRender() {
9703
+ var _a;
9704
+ const positionList = this.position.getOriginalPositionList();
9705
+ (_a = this.lazyRenderIntersectionObserver) == null ? void 0 : _a.disconnect();
9706
+ this.lazyRenderIntersectionObserver = new IntersectionObserver((entries) => {
9707
+ entries.forEach((entry) => {
9708
+ if (entry.isIntersecting) {
9709
+ const index2 = Number(entry.target.dataset.index);
9710
+ this._drawPage(positionList, this.pageRowList[index2], index2);
9711
+ }
9712
+ });
9713
+ });
9714
+ this.pageList.forEach((el) => {
9715
+ this.lazyRenderIntersectionObserver.observe(el);
9716
+ });
9717
+ }
9718
+ _immediateRender() {
9719
+ const positionList = this.position.getOriginalPositionList();
9720
+ for (let i = 0; i < this.pageRowList.length; i++) {
9721
+ this._drawPage(positionList, this.pageRowList[i], i);
9722
+ }
9723
+ }
9540
9724
  render(payload) {
9541
- var _a, _b;
9542
- const { pageMode } = this.options;
9543
- const { isSubmitHistory = true, isSetCursor = true, isComputeRowList = true } = payload || {};
9725
+ var _a;
9726
+ const { isSubmitHistory = true, isSetCursor = true, isCompute = true, isLazy = true } = payload || {};
9544
9727
  let { curIndex } = payload || {};
9545
- const height = this.getHeight();
9546
9728
  const innerWidth = this.getInnerWidth();
9547
- if (isComputeRowList) {
9729
+ if (isCompute) {
9548
9730
  this.rowList = this._computeRowList(innerWidth, this.elementList);
9731
+ this.pageRowList = this._computePageList();
9732
+ this.position.computePositionList();
9549
9733
  const searchKeyword = this.search.getSearchKeyword();
9550
9734
  if (searchKeyword) {
9551
9735
  this.search.compute(searchKeyword);
9552
9736
  }
9553
9737
  }
9738
+ this.imageObserver.clearAll();
9554
9739
  this.cursor.recoveryCursor();
9555
- this.position.setPositionList([]);
9556
9740
  const positionList = this.position.getOriginalPositionList();
9557
- const margins = this.getMargins();
9558
- const marginHeight = margins[0] + margins[2];
9559
- let pageHeight = marginHeight;
9560
- let pageNo = 0;
9561
- const pageRowList = [[]];
9562
- if (pageMode === PageMode.CONTINUITY) {
9563
- pageRowList[0] = this.rowList;
9564
- pageHeight += this.rowList.reduce((pre, cur) => pre + cur.height, 0);
9565
- const dpr = window.devicePixelRatio;
9566
- const pageDom = this.pageList[0];
9567
- const pageDomHeight = Number(pageDom.style.height.replace("px", ""));
9568
- if (pageHeight > pageDomHeight) {
9569
- pageDom.style.height = `${pageHeight}px`;
9570
- pageDom.height = pageHeight * dpr;
9571
- } else {
9572
- const reduceHeight = pageHeight < height ? height : pageHeight;
9573
- pageDom.style.height = `${reduceHeight}px`;
9574
- pageDom.height = reduceHeight * dpr;
9575
- }
9576
- } else {
9577
- for (let i = 0; i < this.rowList.length; i++) {
9578
- const row = this.rowList[i];
9579
- if (row.height + pageHeight > height || ((_a = this.rowList[i - 1]) == null ? void 0 : _a.isPageBreak)) {
9580
- pageHeight = marginHeight + row.height;
9581
- pageRowList.push([row]);
9582
- pageNo++;
9583
- } else {
9584
- pageHeight += row.height;
9585
- pageRowList[pageNo].push(row);
9586
- }
9587
- }
9588
- }
9589
- for (let i = 0; i < pageRowList.length; i++) {
9741
+ for (let i = 0; i < this.pageRowList.length; i++) {
9590
9742
  if (!this.pageList[i]) {
9591
9743
  this._createPage(i);
9592
9744
  }
9593
- const rowList = pageRowList[i];
9594
- this._drawPage(positionList, rowList, i);
9595
9745
  }
9596
- setTimeout(() => {
9597
- const curPageCount = pageRowList.length;
9598
- const prePageCount = this.pageList.length;
9599
- if (prePageCount > curPageCount) {
9600
- const deleteCount = prePageCount - curPageCount;
9601
- this.ctxList.splice(curPageCount, deleteCount);
9602
- this.pageList.splice(curPageCount, deleteCount).forEach((page) => page.remove());
9603
- }
9604
- });
9746
+ const curPageCount = this.pageRowList.length;
9747
+ const prePageCount = this.pageList.length;
9748
+ if (prePageCount > curPageCount) {
9749
+ const deleteCount = prePageCount - curPageCount;
9750
+ this.ctxList.splice(curPageCount, deleteCount);
9751
+ this.pageList.splice(curPageCount, deleteCount).forEach((page) => page.remove());
9752
+ }
9753
+ if (isLazy) {
9754
+ this._lazyRender();
9755
+ } else {
9756
+ this._immediateRender();
9757
+ }
9605
9758
  if (isSetCursor) {
9606
9759
  const positionContext = this.position.getPositionContext();
9607
9760
  if (positionContext.isTable) {
9608
9761
  const { index: index2, trIndex, tdIndex } = positionContext;
9609
- const tablePositionList = (_b = this.elementList[index2].trList) == null ? void 0 : _b[trIndex].tdList[tdIndex].positionList;
9762
+ const tablePositionList = (_a = this.elementList[index2].trList) == null ? void 0 : _a[trIndex].tdList[tdIndex].positionList;
9610
9763
  if (curIndex === void 0 && tablePositionList) {
9611
9764
  curIndex = tablePositionList.length - 1;
9612
9765
  }
@@ -9624,19 +9777,19 @@ class Draw {
9624
9777
  const self = this;
9625
9778
  const oldElementList = deepClone(this.elementList);
9626
9779
  const { startIndex, endIndex } = this.range.getRange();
9627
- const pageNo2 = this.pageNo;
9780
+ const pageNo = this.pageNo;
9628
9781
  const oldPositionContext = deepClone(this.position.getPositionContext());
9629
9782
  this.historyManager.execute(function() {
9630
- self.setPageNo(pageNo2);
9783
+ self.setPageNo(pageNo);
9631
9784
  self.position.setPositionContext(oldPositionContext);
9632
9785
  self.elementList = deepClone(oldElementList);
9633
9786
  self.range.setRange(startIndex, endIndex);
9634
9787
  self.render({ curIndex, isSubmitHistory: false });
9635
9788
  });
9636
9789
  }
9637
- setTimeout(() => {
9790
+ nextTick(() => {
9638
9791
  if (this.listener.pageSizeChange) {
9639
- this.listener.pageSizeChange(pageRowList.length);
9792
+ this.listener.pageSizeChange(this.pageRowList.length);
9640
9793
  }
9641
9794
  if (this.listener.contentChange && isSubmitHistory) {
9642
9795
  this.listener.contentChange();
@@ -10130,7 +10283,7 @@ class CommandAdapt {
10130
10283
  const isCollapsed = startIndex === endIndex;
10131
10284
  this.draw.render({
10132
10285
  curIndex: isCollapsed ? startIndex : void 0,
10133
- isComputeRowList: false,
10286
+ isCompute: false,
10134
10287
  isSubmitHistory: false,
10135
10288
  isSetCursor: isCollapsed
10136
10289
  });
@@ -10352,7 +10505,10 @@ class CommandAdapt {
10352
10505
  selection.forEach((el) => {
10353
10506
  el.color = payload;
10354
10507
  });
10355
- this.draw.render({ isSetCursor: false });
10508
+ this.draw.render({
10509
+ isSetCursor: false,
10510
+ isCompute: false
10511
+ });
10356
10512
  }
10357
10513
  highlight(payload) {
10358
10514
  const isReadonly = this.draw.isReadonly();
@@ -10364,7 +10520,10 @@ class CommandAdapt {
10364
10520
  selection.forEach((el) => {
10365
10521
  el.highlight = payload;
10366
10522
  });
10367
- this.draw.render({ isSetCursor: false });
10523
+ this.draw.render({
10524
+ isSetCursor: false,
10525
+ isCompute: false
10526
+ });
10368
10527
  }
10369
10528
  rowFlex(payload) {
10370
10529
  const isReadonly = this.draw.isReadonly();
@@ -11081,7 +11240,7 @@ class CommandAdapt {
11081
11240
  const { endIndex } = this.range.getRange();
11082
11241
  this.draw.render({
11083
11242
  curIndex: endIndex,
11084
- isComputeRowList: false
11243
+ isCompute: false
11085
11244
  });
11086
11245
  }
11087
11246
  editHyperlink(payload) {
@@ -11098,7 +11257,7 @@ class CommandAdapt {
11098
11257
  const { endIndex } = this.range.getRange();
11099
11258
  this.draw.render({
11100
11259
  curIndex: endIndex,
11101
- isComputeRowList: false
11260
+ isCompute: false
11102
11261
  });
11103
11262
  }
11104
11263
  separator(payload) {
@@ -11161,7 +11320,8 @@ class CommandAdapt {
11161
11320
  options.watermark.font = payload.font || font;
11162
11321
  this.draw.render({
11163
11322
  isSetCursor: false,
11164
- isSubmitHistory: false
11323
+ isSubmitHistory: false,
11324
+ isCompute: false
11165
11325
  });
11166
11326
  }
11167
11327
  deleteWatermark() {
@@ -11173,7 +11333,8 @@ class CommandAdapt {
11173
11333
  options.watermark = __spreadValues({}, defaultWatermarkOption);
11174
11334
  this.draw.render({
11175
11335
  isSetCursor: false,
11176
- isSubmitHistory: false
11336
+ isSubmitHistory: false,
11337
+ isCompute: false
11177
11338
  });
11178
11339
  }
11179
11340
  }
@@ -11218,7 +11379,9 @@ class CommandAdapt {
11218
11379
  return;
11219
11380
  this.draw.render({
11220
11381
  isSetCursor: false,
11221
- isSubmitHistory: false
11382
+ isSubmitHistory: false,
11383
+ isCompute: false,
11384
+ isLazy: false
11222
11385
  });
11223
11386
  }
11224
11387
  searchNavigateNext() {
@@ -11227,7 +11390,9 @@ class CommandAdapt {
11227
11390
  return;
11228
11391
  this.draw.render({
11229
11392
  isSetCursor: false,
11230
- isSubmitHistory: false
11393
+ isSubmitHistory: false,
11394
+ isCompute: false,
11395
+ isLazy: false
11231
11396
  });
11232
11397
  }
11233
11398
  getSearchNavigateInfo() {
@@ -11330,12 +11495,13 @@ class CommandAdapt {
11330
11495
  curIndex: firstIndex
11331
11496
  });
11332
11497
  }
11333
- print() {
11498
+ async print() {
11334
11499
  const { width, height, scale } = this.options;
11335
11500
  if (scale !== 1) {
11336
11501
  this.draw.setPageScale(1);
11337
11502
  }
11338
- printImageBase64(this.draw.getDataURL(), width, height);
11503
+ const base64List = await this.draw.getDataURL();
11504
+ printImageBase64(base64List, width, height);
11339
11505
  if (scale !== 1) {
11340
11506
  this.draw.setPageScale(scale);
11341
11507
  }
@@ -12118,6 +12284,7 @@ class Editor {
12118
12284
  const waterMarkOptions = __spreadValues(__spreadValues({}, defaultWatermarkOption), options.watermark);
12119
12285
  const controlOptions = __spreadValues(__spreadValues({}, defaultControlOption), options.control);
12120
12286
  const checkboxOptions = __spreadValues(__spreadValues({}, defaultCheckboxOption), options.checkbox);
12287
+ const cursorOptions = __spreadValues(__spreadValues({}, defaultCursorOption), options.cursor);
12121
12288
  const editorOptions = __spreadProps(__spreadValues({
12122
12289
  mode: EditorMode.EDIT,
12123
12290
  defaultType: "TEXT",
@@ -12156,7 +12323,8 @@ class Editor {
12156
12323
  header: headerOptions,
12157
12324
  watermark: waterMarkOptions,
12158
12325
  control: controlOptions,
12159
- checkbox: checkboxOptions
12326
+ checkbox: checkboxOptions,
12327
+ cursor: cursorOptions
12160
12328
  });
12161
12329
  formatElementList(elementList, {
12162
12330
  editorOptions