@hufe921/canvas-editor 0.9.86 → 0.9.88

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.86";
26
+ const version = "0.9.88";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -3919,7 +3919,7 @@ function formatElementList(elementList, options) {
3919
3919
  let valueStyleIndex = 0;
3920
3920
  for (let v = 0; v < valueSets.length; v++) {
3921
3921
  const valueSet = valueSets[v];
3922
- elementList.splice(i, 0, __spreadProps(__spreadValues({}, controlContext), {
3922
+ elementList.splice(i, 0, __spreadProps(__spreadValues(__spreadValues({}, controlContext), controlDefaultStyle), {
3923
3923
  controlId,
3924
3924
  value: "",
3925
3925
  type: el.type,
@@ -3953,7 +3953,7 @@ function formatElementList(elementList, options) {
3953
3953
  let valueStyleIndex = 0;
3954
3954
  for (let v = 0; v < valueSets.length; v++) {
3955
3955
  const valueSet = valueSets[v];
3956
- elementList.splice(i, 0, __spreadProps(__spreadValues({}, controlContext), {
3956
+ elementList.splice(i, 0, __spreadProps(__spreadValues(__spreadValues({}, controlContext), controlDefaultStyle), {
3957
3957
  controlId,
3958
3958
  value: "",
3959
3959
  type: el.type,
@@ -4343,10 +4343,13 @@ function getAnchorElement(elementList, anchorIndex) {
4343
4343
  return !anchorElement.listId && anchorElement.value === ZERO && anchorNextElement && anchorNextElement.value !== ZERO ? anchorNextElement : anchorElement;
4344
4344
  }
4345
4345
  function formatElementContext(sourceElementList, formatElementList2, anchorIndex, options) {
4346
- var _a, _b;
4347
- const copyElement = getAnchorElement(sourceElementList, anchorIndex);
4346
+ var _a, _b, _c;
4347
+ let copyElement = getAnchorElement(sourceElementList, anchorIndex);
4348
4348
  if (!copyElement)
4349
4349
  return;
4350
+ if ((_a = copyElement.title) == null ? void 0 : _a.disabled) {
4351
+ copyElement = omitObject(copyElement, TITLE_CONTEXT_ATTR);
4352
+ }
4350
4353
  const { isBreakWhenWrap = false } = options || {};
4351
4354
  let isBreakWarped = false;
4352
4355
  for (let e = 0; e < formatElementList2.length; e++) {
@@ -4357,12 +4360,12 @@ function formatElementContext(sourceElementList, formatElementList2, anchorIndex
4357
4360
  if (isBreakWarped || !copyElement.listId && targetElement.type === ElementType.LIST) {
4358
4361
  const cloneAttr = [...TABLE_CONTEXT_ATTR, ...EDITOR_ROW_ATTR];
4359
4362
  cloneProperty(cloneAttr, copyElement, targetElement);
4360
- (_a = targetElement.valueList) == null ? void 0 : _a.forEach((valueItem) => {
4363
+ (_b = targetElement.valueList) == null ? void 0 : _b.forEach((valueItem) => {
4361
4364
  cloneProperty(cloneAttr, copyElement, valueItem);
4362
4365
  });
4363
4366
  continue;
4364
4367
  }
4365
- if ((_b = targetElement.valueList) == null ? void 0 : _b.length) {
4368
+ if ((_c = targetElement.valueList) == null ? void 0 : _c.length) {
4366
4369
  formatElementContext(sourceElementList, targetElement.valueList, anchorIndex);
4367
4370
  }
4368
4371
  cloneProperty(EDITOR_ELEMENT_CONTEXT_ATTR, copyElement, targetElement);
@@ -4980,8 +4983,7 @@ function getIsClipboardContainFile(clipboardData) {
4980
4983
  }
4981
4984
  function pasteElement(host, elementList) {
4982
4985
  const draw = host.getDraw();
4983
- const isReadonly = draw.isReadonly();
4984
- if (isReadonly)
4986
+ if (draw.isReadonly() || draw.isDisabled())
4985
4987
  return;
4986
4988
  const rangeManager = draw.getRange();
4987
4989
  const { startIndex } = rangeManager.getRange();
@@ -5020,8 +5022,7 @@ function pasteElement(host, elementList) {
5020
5022
  }
5021
5023
  function pasteHTML(host, htmlText) {
5022
5024
  const draw = host.getDraw();
5023
- const isReadonly = draw.isReadonly();
5024
- if (isReadonly)
5025
+ if (draw.isReadonly() || draw.isDisabled())
5025
5026
  return;
5026
5027
  const elementList = getElementListByHTML(htmlText, {
5027
5028
  innerWidth: draw.getOriginalInnerWidth()
@@ -5030,8 +5031,7 @@ function pasteHTML(host, htmlText) {
5030
5031
  }
5031
5032
  function pasteImage(host, file) {
5032
5033
  const draw = host.getDraw();
5033
- const isReadonly = draw.isReadonly();
5034
- if (isReadonly)
5034
+ if (draw.isReadonly() || draw.isDisabled())
5035
5035
  return;
5036
5036
  const rangeManager = draw.getRange();
5037
5037
  const { startIndex } = rangeManager.getRange();
@@ -5058,8 +5058,7 @@ function pasteImage(host, file) {
5058
5058
  }
5059
5059
  function pasteByEvent(host, evt) {
5060
5060
  const draw = host.getDraw();
5061
- const isReadonly = draw.isReadonly();
5062
- if (isReadonly)
5061
+ if (draw.isReadonly() || draw.isDisabled())
5063
5062
  return;
5064
5063
  const clipboardData = evt.clipboardData;
5065
5064
  if (!clipboardData)
@@ -5114,8 +5113,7 @@ function pasteByEvent(host, evt) {
5114
5113
  }
5115
5114
  async function pasteByApi(host, options) {
5116
5115
  const draw = host.getDraw();
5117
- const isReadonly = draw.isReadonly();
5118
- if (isReadonly)
5116
+ if (draw.isReadonly() || draw.isDisabled())
5119
5117
  return;
5120
5118
  const { paste } = draw.getOverride();
5121
5119
  if (paste) {
@@ -5650,7 +5648,6 @@ function setRangeCache(host) {
5650
5648
  host.cachePositionContext = position.getPositionContext();
5651
5649
  }
5652
5650
  function mousedown(evt, host) {
5653
- var _a;
5654
5651
  if (evt.button === MouseEventButton.RIGHT)
5655
5652
  return;
5656
5653
  const draw = host.getDraw();
@@ -5702,7 +5699,7 @@ function mousedown(evt, host) {
5702
5699
  if (!control) {
5703
5700
  draw.getCheckboxParticle().setSelect(curElement);
5704
5701
  } else {
5705
- const codes = ((_a = control == null ? void 0 : control.code) == null ? void 0 : _a.split(",")) || [];
5702
+ const codes = (control == null ? void 0 : control.code) ? control.code.split(",") : [];
5706
5703
  if (checkbox == null ? void 0 : checkbox.value) {
5707
5704
  const codeIndex = codes.findIndex((c) => c === checkbox.code);
5708
5705
  codes.splice(codeIndex, 1);
@@ -5805,8 +5802,10 @@ function mouseup(evt, host) {
5805
5802
  var _a, _b, _c, _d;
5806
5803
  if (host.isAllowDrop) {
5807
5804
  const draw = host.getDraw();
5808
- if (draw.isReadonly())
5805
+ if (draw.isReadonly() || draw.isDisabled()) {
5806
+ host.mousedown(evt);
5809
5807
  return;
5808
+ }
5810
5809
  const position = draw.getPosition();
5811
5810
  const positionList = position.getPositionList();
5812
5811
  const positionContext = position.getPositionContext();
@@ -6056,9 +6055,26 @@ function backspace(evt, host) {
6056
6055
  const rangeManager = draw.getRange();
6057
6056
  if (!rangeManager.getIsCanInput())
6058
6057
  return;
6058
+ const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
6059
6059
  const control = draw.getControl();
6060
6060
  let curIndex;
6061
- if (control.getActiveControl() && control.getIsRangeCanCaptureEvent()) {
6061
+ if (isCrossRowCol) {
6062
+ const rowCol = draw.getTableParticle().getRangeRowCol();
6063
+ if (!rowCol)
6064
+ return;
6065
+ let isDeleted = false;
6066
+ for (let r = 0; r < rowCol.length; r++) {
6067
+ const row = rowCol[r];
6068
+ for (let c = 0; c < row.length; c++) {
6069
+ const col = row[c];
6070
+ if (col.value.length > 1) {
6071
+ draw.spliceElementList(col.value, 1, col.value.length - 1);
6072
+ isDeleted = true;
6073
+ }
6074
+ }
6075
+ }
6076
+ curIndex = isDeleted ? 0 : null;
6077
+ } else if (control.getActiveControl() && control.getIsRangeCanCaptureEvent()) {
6062
6078
  curIndex = control.keydown(evt);
6063
6079
  } else {
6064
6080
  const position = draw.getPosition();
@@ -6066,7 +6082,6 @@ function backspace(evt, host) {
6066
6082
  if (!cursorPosition)
6067
6083
  return;
6068
6084
  const { index: index2 } = cursorPosition;
6069
- const { startIndex, endIndex } = rangeManager.getRange();
6070
6085
  const isCollapsed = rangeManager.getIsCollapsed();
6071
6086
  const elementList = draw.getElementList();
6072
6087
  if (isCollapsed && index2 === 0) {
@@ -6096,11 +6111,19 @@ function backspace(evt, host) {
6096
6111
  }
6097
6112
  curIndex = isCollapsed ? index2 - 1 : startIndex;
6098
6113
  }
6099
- if (curIndex === null)
6100
- return;
6101
6114
  draw.getGlobalEvent().setCanvasEventAbility();
6102
- rangeManager.setRange(curIndex, curIndex);
6103
- draw.render({ curIndex });
6115
+ if (curIndex === null) {
6116
+ rangeManager.setRange(startIndex, startIndex);
6117
+ draw.render({
6118
+ curIndex: startIndex,
6119
+ isSubmitHistory: false
6120
+ });
6121
+ } else {
6122
+ rangeManager.setRange(curIndex, curIndex);
6123
+ draw.render({
6124
+ curIndex
6125
+ });
6126
+ }
6104
6127
  }
6105
6128
  function del(evt, host) {
6106
6129
  var _a;
@@ -6110,11 +6133,27 @@ function del(evt, host) {
6110
6133
  const rangeManager = draw.getRange();
6111
6134
  if (!rangeManager.getIsCanInput())
6112
6135
  return;
6113
- const { startIndex, endIndex } = rangeManager.getRange();
6136
+ const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
6114
6137
  const elementList = draw.getElementList();
6115
6138
  const control = draw.getControl();
6116
6139
  let curIndex;
6117
- if (control.getActiveControl() && control.getIsRangeWithinControl()) {
6140
+ if (isCrossRowCol) {
6141
+ const rowCol = draw.getTableParticle().getRangeRowCol();
6142
+ if (!rowCol)
6143
+ return;
6144
+ let isDeleted = false;
6145
+ for (let r = 0; r < rowCol.length; r++) {
6146
+ const row = rowCol[r];
6147
+ for (let c = 0; c < row.length; c++) {
6148
+ const col = row[c];
6149
+ if (col.value.length > 1) {
6150
+ draw.spliceElementList(col.value, 1, col.value.length - 1);
6151
+ isDeleted = true;
6152
+ }
6153
+ }
6154
+ }
6155
+ curIndex = isDeleted ? 0 : null;
6156
+ } else if (control.getActiveControl() && control.getIsRangeWithinControl()) {
6118
6157
  curIndex = control.keydown(evt);
6119
6158
  } else if ((_a = elementList[endIndex + 1]) == null ? void 0 : _a.controlId) {
6120
6159
  curIndex = control.removeControl(endIndex + 1);
@@ -6140,11 +6179,19 @@ function del(evt, host) {
6140
6179
  curIndex = isCollapsed ? index2 : startIndex;
6141
6180
  }
6142
6181
  }
6143
- if (curIndex === null)
6144
- return;
6145
6182
  draw.getGlobalEvent().setCanvasEventAbility();
6146
- rangeManager.setRange(curIndex, curIndex);
6147
- draw.render({ curIndex });
6183
+ if (curIndex === null) {
6184
+ rangeManager.setRange(startIndex, startIndex);
6185
+ draw.render({
6186
+ curIndex: startIndex,
6187
+ isSubmitHistory: false
6188
+ });
6189
+ } else {
6190
+ rangeManager.setRange(curIndex, curIndex);
6191
+ draw.render({
6192
+ curIndex
6193
+ });
6194
+ }
6148
6195
  }
6149
6196
  function enter(evt, host) {
6150
6197
  var _a, _b;
@@ -6861,7 +6908,7 @@ function keydown(evt, host) {
6861
6908
  function input(data2, host) {
6862
6909
  var _a;
6863
6910
  const draw = host.getDraw();
6864
- if (draw.isReadonly())
6911
+ if (draw.isReadonly() || draw.isDisabled())
6865
6912
  return;
6866
6913
  const position = draw.getPosition();
6867
6914
  const cursorPosition = position.getCursorPosition();
@@ -6887,22 +6934,25 @@ function input(data2, host) {
6887
6934
  if (!copyElement)
6888
6935
  return;
6889
6936
  const inputData = splitText(text).map((value) => {
6937
+ var _a2, _b;
6890
6938
  const newElement = {
6891
6939
  value
6892
6940
  };
6893
- const nextElement = elementList[endIndex + 1];
6894
- if (!copyElement.type || copyElement.type === TEXT || copyElement.type === HYPERLINK && (nextElement == null ? void 0 : nextElement.type) === HYPERLINK || copyElement.type === DATE && (nextElement == null ? void 0 : nextElement.type) === DATE || copyElement.type === SUBSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUBSCRIPT || copyElement.type === SUPERSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUPERSCRIPT) {
6895
- EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
6896
- if (attr === "groupIds" && !(nextElement == null ? void 0 : nextElement.groupIds))
6897
- return;
6898
- const value2 = copyElement[attr];
6899
- if (value2 !== void 0) {
6900
- newElement[attr] = value2;
6901
- }
6902
- });
6903
- }
6904
- if (isComposing) {
6905
- newElement.underline = true;
6941
+ if (!((_a2 = copyElement.title) == null ? void 0 : _a2.disabled) && !((_b = copyElement.control) == null ? void 0 : _b.disabled)) {
6942
+ const nextElement = elementList[endIndex + 1];
6943
+ if (!copyElement.type || copyElement.type === TEXT || copyElement.type === HYPERLINK && (nextElement == null ? void 0 : nextElement.type) === HYPERLINK || copyElement.type === DATE && (nextElement == null ? void 0 : nextElement.type) === DATE || copyElement.type === SUBSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUBSCRIPT || copyElement.type === SUPERSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUPERSCRIPT) {
6944
+ EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
6945
+ if (attr === "groupIds" && !(nextElement == null ? void 0 : nextElement.groupIds))
6946
+ return;
6947
+ const value2 = copyElement[attr];
6948
+ if (value2 !== void 0) {
6949
+ newElement[attr] = value2;
6950
+ }
6951
+ });
6952
+ }
6953
+ if (isComposing) {
6954
+ newElement.underline = true;
6955
+ }
6906
6956
  }
6907
6957
  return newElement;
6908
6958
  });
@@ -7361,6 +7411,9 @@ class CanvasEvent {
7361
7411
  const painterStyle = this.draw.getPainterStyle();
7362
7412
  if (!painterStyle)
7363
7413
  return;
7414
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
7415
+ if (isDisabled)
7416
+ return;
7364
7417
  const selection = this.range.getSelection();
7365
7418
  if (!selection)
7366
7419
  return;
@@ -7980,9 +8033,12 @@ class Position {
7980
8033
  const { index: index2, rowNo, coordinate: { leftTop, leftBottom } } = lastLetterList[j];
7981
8034
  if (y > leftTop[1] && y <= leftBottom[1]) {
7982
8035
  const headIndex = positionList.findIndex((p) => p.pageNo === positionNo && p.rowNo === rowNo);
7983
- if (x < this.options.margins[3]) {
8036
+ const headElement = elementList[headIndex];
8037
+ const headPosition = positionList[headIndex];
8038
+ const headStartX = headElement.listStyle === ListStyle.CHECKBOX ? this.options.margins[3] : headPosition.coordinate.leftTop[0];
8039
+ if (x < headStartX) {
7984
8040
  if (~headIndex) {
7985
- if (positionList[headIndex].value === ZERO) {
8041
+ if (headPosition.value === ZERO) {
7986
8042
  curPositionIndex = headIndex;
7987
8043
  } else {
7988
8044
  curPositionIndex = headIndex - 1;
@@ -7992,7 +8048,7 @@ class Position {
7992
8048
  curPositionIndex = index2;
7993
8049
  }
7994
8050
  } else {
7995
- if (elementList[headIndex].listStyle === ListStyle.CHECKBOX && x < leftTop[0]) {
8051
+ if (headElement.listStyle === ListStyle.CHECKBOX && x < leftTop[0]) {
7996
8052
  return {
7997
8053
  index: headIndex,
7998
8054
  isDirectHit: true,
@@ -8075,11 +8131,13 @@ class Position {
8075
8131
  };
8076
8132
  }
8077
8133
  getFloatPositionByXY(payload) {
8134
+ var _a;
8078
8135
  const { x, y } = payload;
8136
+ const currentPageNo = (_a = payload.pageNo) != null ? _a : this.draw.getPageNo();
8079
8137
  const currentZone = this.draw.getZone().getZone();
8080
8138
  for (let f = 0; f < this.floatPositionList.length; f++) {
8081
- const { position, element, isTable, index: index2, trIndex, tdIndex, tdValueIndex, zone: floatElementZone } = this.floatPositionList[f];
8082
- if (element.type === ElementType.IMAGE && element.imgDisplay === payload.imgDisplay && (!floatElementZone || floatElementZone === currentZone)) {
8139
+ const { position, element, isTable, index: index2, trIndex, tdIndex, tdValueIndex, zone: floatElementZone, pageNo } = this.floatPositionList[f];
8140
+ if (currentPageNo === pageNo && element.type === ElementType.IMAGE && element.imgDisplay === payload.imgDisplay && (!floatElementZone || floatElementZone === currentZone)) {
8083
8141
  const imgFloatPosition = element.imgFloatPosition;
8084
8142
  if (x >= imgFloatPosition.x && x <= imgFloatPosition.x + element.width && y >= imgFloatPosition.y && y <= imgFloatPosition.y + element.height) {
8085
8143
  if (isTable) {
@@ -8705,14 +8763,14 @@ class Background {
8705
8763
  }
8706
8764
  }
8707
8765
  render(ctx, pageNo) {
8708
- const { background } = this.options;
8709
- if (background.image) {
8766
+ const { background: { image, color, applyPageNumbers } } = this.options;
8767
+ if (image && (!(applyPageNumbers == null ? void 0 : applyPageNumbers.length) || applyPageNumbers.includes(pageNo))) {
8710
8768
  const { width, height } = this.options;
8711
8769
  this._renderBackgroundImage(ctx, width, height);
8712
8770
  } else {
8713
8771
  const width = this.draw.getCanvasWidth(pageNo);
8714
8772
  const height = this.draw.getCanvasHeight(pageNo);
8715
- this._renderBackgroundColor(ctx, background.color, width, height);
8773
+ this._renderBackgroundColor(ctx, color, width, height);
8716
8774
  }
8717
8775
  }
8718
8776
  }
@@ -9415,12 +9473,22 @@ class SelectionObserver {
9415
9473
  constructor(draw) {
9416
9474
  __publicField(this, "step", 5);
9417
9475
  __publicField(this, "thresholdPoints", [70, 40, 10, 20]);
9476
+ __publicField(this, "selectionContainer");
9418
9477
  __publicField(this, "rangeManager");
9419
9478
  __publicField(this, "requestAnimationFrameId");
9420
9479
  __publicField(this, "isMousedown");
9421
9480
  __publicField(this, "isMoving");
9481
+ __publicField(this, "clientWidth");
9482
+ __publicField(this, "clientHeight");
9483
+ __publicField(this, "containerRect");
9422
9484
  __publicField(this, "_mousedown", () => {
9423
9485
  this.isMousedown = true;
9486
+ this.clientWidth = this.selectionContainer instanceof Document ? document.documentElement.clientWidth : this.selectionContainer.clientWidth;
9487
+ this.clientHeight = this.selectionContainer instanceof Document ? document.documentElement.clientHeight : this.selectionContainer.clientHeight;
9488
+ if (!(this.selectionContainer instanceof Document)) {
9489
+ const rect = this.selectionContainer.getBoundingClientRect();
9490
+ this.containerRect = rect;
9491
+ }
9424
9492
  });
9425
9493
  __publicField(this, "_mouseup", () => {
9426
9494
  this.isMousedown = false;
@@ -9429,48 +9497,60 @@ class SelectionObserver {
9429
9497
  __publicField(this, "_mousemove", (evt) => {
9430
9498
  if (!this.isMousedown || this.rangeManager.getIsCollapsed())
9431
9499
  return;
9432
- const { x, y } = evt;
9433
- const clientWidth = document.documentElement.clientWidth;
9434
- const clientHeight = document.documentElement.clientHeight;
9500
+ let { x, y } = evt;
9501
+ if (this.containerRect) {
9502
+ x = x - this.containerRect.x;
9503
+ y = y - this.containerRect.y;
9504
+ }
9435
9505
  if (y < this.thresholdPoints[0]) {
9436
9506
  this._startMove(MoveDirection.UP);
9437
- } else if (clientHeight - y <= this.thresholdPoints[1]) {
9507
+ } else if (this.clientHeight - y <= this.thresholdPoints[1]) {
9438
9508
  this._startMove(MoveDirection.DOWN);
9439
9509
  } else if (x < this.thresholdPoints[2]) {
9440
9510
  this._startMove(MoveDirection.LEFT);
9441
- } else if (clientWidth - x < this.thresholdPoints[3]) {
9511
+ } else if (this.clientWidth - x < this.thresholdPoints[3]) {
9442
9512
  this._startMove(MoveDirection.RIGHT);
9443
9513
  } else {
9444
9514
  this._stopMove();
9445
9515
  }
9446
9516
  });
9517
+ this.rangeManager = draw.getRange();
9518
+ const { scrollContainerSelector } = draw.getOptions();
9519
+ this.selectionContainer = scrollContainerSelector ? document.querySelector(scrollContainerSelector) || document : document;
9447
9520
  this.requestAnimationFrameId = null;
9448
9521
  this.isMousedown = false;
9449
9522
  this.isMoving = false;
9450
- this.rangeManager = draw.getRange();
9523
+ this.clientWidth = 0;
9524
+ this.clientHeight = 0;
9525
+ this.containerRect = null;
9451
9526
  this._addEvent();
9452
9527
  }
9453
9528
  _addEvent() {
9454
- document.addEventListener("mousedown", this._mousedown);
9455
- document.addEventListener("mousemove", this._mousemove);
9456
- document.addEventListener("mouseup", this._mouseup);
9529
+ const container = this.selectionContainer;
9530
+ container.addEventListener("mousedown", this._mousedown);
9531
+ container.addEventListener("mousemove", this._mousemove);
9532
+ container.addEventListener("mouseup", this._mouseup);
9533
+ document.addEventListener("mouseleave", this._mouseup);
9457
9534
  }
9458
9535
  removeEvent() {
9459
- document.removeEventListener("mousedown", this._mousedown);
9460
- document.removeEventListener("mousemove", this._mousemove);
9461
- document.removeEventListener("mouseup", this._mouseup);
9536
+ const container = this.selectionContainer;
9537
+ container.removeEventListener("mousedown", this._mousedown);
9538
+ container.removeEventListener("mousemove", this._mousemove);
9539
+ container.removeEventListener("mouseup", this._mouseup);
9540
+ document.removeEventListener("mouseleave", this._mouseup);
9462
9541
  }
9463
9542
  _move(direction) {
9464
- const x = window.scrollX;
9465
- const y = window.scrollY;
9543
+ const container = this.selectionContainer instanceof Document ? window : this.selectionContainer;
9544
+ const x = this.selectionContainer instanceof Document ? window.scrollX : container.scrollLeft;
9545
+ const y = this.selectionContainer instanceof Document ? window.scrollY : container.scrollTop;
9466
9546
  if (direction === MoveDirection.DOWN) {
9467
- window.scrollTo(x, y + this.step);
9547
+ container.scrollTo(x, y + this.step);
9468
9548
  } else if (direction === MoveDirection.UP) {
9469
- window.scrollTo(x, y - this.step);
9549
+ container.scrollTo(x, y - this.step);
9470
9550
  } else if (direction === MoveDirection.LEFT) {
9471
- window.scrollTo(x - this.step, y);
9551
+ container.scrollTo(x - this.step, y);
9472
9552
  } else {
9473
- window.scrollTo(x + this.step, y);
9553
+ container.scrollTo(x + this.step, y);
9474
9554
  }
9475
9555
  this.requestAnimationFrameId = window.requestAnimationFrame(this._move.bind(this, direction));
9476
9556
  }
@@ -10476,7 +10556,7 @@ class ControlSearch {
10476
10556
  newEndIndex++;
10477
10557
  }
10478
10558
  i = newEndIndex;
10479
- const controlElementList = elementList.slice(startIndex, newEndIndex);
10559
+ const controlElementList = elementList.slice(startIndex, newEndIndex).map((element2) => element2.controlComponent === ControlComponent.VALUE ? element2 : { value: ZERO });
10480
10560
  const highlight = this.highlightList[highlightIndex];
10481
10561
  const { ruleList } = highlight;
10482
10562
  for (let r = 0; r < ruleList.length; r++) {
@@ -11809,7 +11889,17 @@ class Control {
11809
11889
  }
11810
11890
  getIsDisabledControl() {
11811
11891
  var _a, _b;
11812
- return !!((_b = (_a = this.activeControl) == null ? void 0 : _a.getElement().control) == null ? void 0 : _b.disabled);
11892
+ if (!this.activeControl)
11893
+ return false;
11894
+ const { startIndex, endIndex } = this.range.getRange();
11895
+ if (startIndex === endIndex) {
11896
+ const elementList = this.getElementList();
11897
+ const startElement = elementList[startIndex];
11898
+ if (startElement.controlComponent === ControlComponent.POSTFIX) {
11899
+ return false;
11900
+ }
11901
+ }
11902
+ return !!((_b = (_a = this.activeControl.getElement()) == null ? void 0 : _a.control) == null ? void 0 : _b.disabled);
11813
11903
  }
11814
11904
  getContainer() {
11815
11905
  return this.draw.getContainer();
@@ -12175,9 +12265,6 @@ class Control {
12175
12265
  return result;
12176
12266
  }
12177
12267
  setValueByConceptId(payload) {
12178
- const isReadonly = this.draw.isReadonly();
12179
- if (isReadonly)
12180
- return;
12181
12268
  let isExistSet = false;
12182
12269
  const { conceptId, value } = payload;
12183
12270
  const setValue = (elementList) => {
@@ -12242,7 +12329,7 @@ class Control {
12242
12329
  } else if (type === ControlType.CHECKBOX) {
12243
12330
  const checkbox = new CheckboxControl(element, this);
12244
12331
  this.activeControl = checkbox;
12245
- const codes = (value == null ? void 0 : value.split(",")) || [];
12332
+ const codes = value ? value.split(",") : [];
12246
12333
  checkbox.setSelect(codes, controlContext, controlRule);
12247
12334
  } else if (type === ControlType.RADIO) {
12248
12335
  const radio = new RadioControl(element, this);
@@ -12285,9 +12372,6 @@ class Control {
12285
12372
  }
12286
12373
  }
12287
12374
  setExtensionByConceptId(payload) {
12288
- const isReadonly = this.draw.isReadonly();
12289
- if (isReadonly)
12290
- return;
12291
12375
  const { conceptId, extension } = payload;
12292
12376
  const setExtension = (elementList) => {
12293
12377
  var _a;
@@ -12328,9 +12412,6 @@ class Control {
12328
12412
  }
12329
12413
  }
12330
12414
  setPropertiesByConceptId(payload) {
12331
- const isReadonly = this.draw.isReadonly();
12332
- if (isReadonly)
12333
- return;
12334
12415
  const { conceptId, properties } = payload;
12335
12416
  let isExistUpdate = false;
12336
12417
  function setProperties(elementList) {
@@ -14687,6 +14768,21 @@ class Draw {
14687
14768
  return false;
14688
14769
  }
14689
14770
  }
14771
+ isDisabled() {
14772
+ var _a, _b, _c, _d;
14773
+ const { startIndex, endIndex } = this.range.getRange();
14774
+ const elementList = this.getElementList();
14775
+ if (startIndex === endIndex) {
14776
+ const startElement = elementList[startIndex];
14777
+ const nextElement = elementList[startIndex + 1];
14778
+ return !!(((_a = startElement == null ? void 0 : startElement.title) == null ? void 0 : _a.disabled) && ((_b = nextElement == null ? void 0 : nextElement.title) == null ? void 0 : _b.disabled) || ((_c = startElement == null ? void 0 : startElement.control) == null ? void 0 : _c.disabled) && ((_d = nextElement == null ? void 0 : nextElement.control) == null ? void 0 : _d.disabled));
14779
+ }
14780
+ const selectionElementList = elementList.slice(startIndex + 1, endIndex + 1);
14781
+ return selectionElementList.some((element) => {
14782
+ var _a2, _b2;
14783
+ return ((_a2 = element.title) == null ? void 0 : _a2.disabled) || ((_b2 = element.control) == null ? void 0 : _b2.disabled);
14784
+ });
14785
+ }
14690
14786
  getOriginalWidth() {
14691
14787
  const { paperDirection, width, height } = this.options;
14692
14788
  return paperDirection === PaperDirection.VERTICAL ? width : height;
@@ -15234,15 +15330,21 @@ class Draw {
15234
15330
  });
15235
15331
  }
15236
15332
  getValue(options = {}) {
15237
- const { pageNo } = options;
15333
+ const { pageNo, extraPickAttrs } = options;
15238
15334
  let mainElementList = this.elementList;
15239
15335
  if (Number.isInteger(pageNo) && pageNo >= 0 && pageNo < this.pageRowList.length) {
15240
15336
  mainElementList = this.pageRowList[pageNo].flatMap((row) => row.elementList);
15241
15337
  }
15242
15338
  const data2 = {
15243
- header: zipElementList(this.getHeaderElementList()),
15244
- main: zipElementList(mainElementList),
15245
- footer: zipElementList(this.getFooterElementList())
15339
+ header: zipElementList(this.getHeaderElementList(), {
15340
+ extraPickAttrs
15341
+ }),
15342
+ main: zipElementList(mainElementList, {
15343
+ extraPickAttrs
15344
+ }),
15345
+ footer: zipElementList(this.getFooterElementList(), {
15346
+ extraPickAttrs
15347
+ })
15246
15348
  };
15247
15349
  return {
15248
15350
  version,
@@ -15250,10 +15352,11 @@ class Draw {
15250
15352
  options: deepClone(this.options)
15251
15353
  };
15252
15354
  }
15253
- setValue(payload) {
15355
+ setValue(payload, options) {
15254
15356
  const { header, main, footer } = deepClone(payload);
15255
15357
  if (!header && !main && !footer)
15256
15358
  return;
15359
+ const { isSetCursor = false } = options || {};
15257
15360
  const pageComponentData = [header, main, footer];
15258
15361
  pageComponentData.forEach((data2) => {
15259
15362
  if (!data2)
@@ -15268,8 +15371,13 @@ class Draw {
15268
15371
  footer
15269
15372
  });
15270
15373
  this.historyManager.recovery();
15374
+ const curIndex = isSetCursor ? (main == null ? void 0 : main.length) ? main.length - 1 : 0 : void 0;
15375
+ if (curIndex !== void 0) {
15376
+ this.range.setRange(curIndex, curIndex);
15377
+ }
15271
15378
  this.render({
15272
- isSetCursor: false,
15379
+ curIndex,
15380
+ isSetCursor,
15273
15381
  isFirstRender: true
15274
15382
  });
15275
15383
  }
@@ -15664,12 +15772,14 @@ class Draw {
15664
15772
  const word = `${(preElement == null ? void 0 : preElement.value) || ""}${element.value}`;
15665
15773
  if (this.WORD_LIKE_REG.test(word)) {
15666
15774
  const { width, endElement } = this.textParticle.measureWord(ctx, elementList, i);
15667
- if (width <= availableWidth) {
15668
- curRowWidth += width;
15775
+ const wordWidth = width * scale;
15776
+ if (wordWidth <= availableWidth) {
15777
+ curRowWidth += wordWidth;
15669
15778
  nextElement = endElement;
15670
15779
  }
15671
15780
  }
15672
- curRowWidth += this.textParticle.measurePunctuationWidth(ctx, nextElement);
15781
+ const punctuationWidth = this.textParticle.measurePunctuationWidth(ctx, nextElement);
15782
+ curRowWidth += punctuationWidth * scale;
15673
15783
  }
15674
15784
  }
15675
15785
  if (element.listId) {
@@ -16504,7 +16614,8 @@ const defaultBackground = {
16504
16614
  color: "#FFFFFF",
16505
16615
  image: "",
16506
16616
  size: BackgroundSize.COVER,
16507
- repeat: BackgroundRepeat.NO_REPEAT
16617
+ repeat: BackgroundRepeat.NO_REPEAT,
16618
+ applyPageNumbers: []
16508
16619
  };
16509
16620
  const defaultCheckboxOption = {
16510
16621
  width: 14,
@@ -16851,13 +16962,13 @@ class CommandAdapt {
16851
16962
  this.draw.setPainterStyle(painterStyle, options);
16852
16963
  }
16853
16964
  applyPainterStyle() {
16854
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
16965
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16855
16966
  if (isDisabled)
16856
16967
  return;
16857
16968
  this.canvasEvent.applyPainterStyle();
16858
16969
  }
16859
16970
  format() {
16860
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
16971
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16861
16972
  if (isDisabled)
16862
16973
  return;
16863
16974
  const selection = this.range.getSelectionElementList();
@@ -16885,7 +16996,7 @@ class CommandAdapt {
16885
16996
  this.draw.render(renderOption);
16886
16997
  }
16887
16998
  font(payload) {
16888
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
16999
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16889
17000
  if (isDisabled)
16890
17001
  return;
16891
17002
  const selection = this.range.getSelectionElementList();
@@ -16908,7 +17019,7 @@ class CommandAdapt {
16908
17019
  const { minSize, maxSize, defaultSize } = this.options;
16909
17020
  if (payload < minSize || payload > maxSize)
16910
17021
  return;
16911
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17022
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16912
17023
  if (isDisabled)
16913
17024
  return;
16914
17025
  let renderOption = {};
@@ -16941,7 +17052,7 @@ class CommandAdapt {
16941
17052
  }
16942
17053
  }
16943
17054
  sizeAdd() {
16944
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17055
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16945
17056
  if (isDisabled)
16946
17057
  return;
16947
17058
  const selection = this.range.getTextLikeSelectionElementList();
@@ -16981,7 +17092,7 @@ class CommandAdapt {
16981
17092
  }
16982
17093
  }
16983
17094
  sizeMinus() {
16984
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17095
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16985
17096
  if (isDisabled)
16986
17097
  return;
16987
17098
  const selection = this.range.getTextLikeSelectionElementList();
@@ -17021,7 +17132,7 @@ class CommandAdapt {
17021
17132
  }
17022
17133
  }
17023
17134
  bold() {
17024
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17135
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17025
17136
  if (isDisabled)
17026
17137
  return;
17027
17138
  const selection = this.range.getSelectionElementList();
@@ -17042,7 +17153,7 @@ class CommandAdapt {
17042
17153
  }
17043
17154
  }
17044
17155
  italic() {
17045
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17156
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17046
17157
  if (isDisabled)
17047
17158
  return;
17048
17159
  const selection = this.range.getSelectionElementList();
@@ -17063,7 +17174,7 @@ class CommandAdapt {
17063
17174
  }
17064
17175
  }
17065
17176
  underline(textDecoration) {
17066
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17177
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17067
17178
  if (isDisabled)
17068
17179
  return;
17069
17180
  const selection = this.range.getSelectionElementList();
@@ -17092,7 +17203,7 @@ class CommandAdapt {
17092
17203
  }
17093
17204
  }
17094
17205
  strikeout() {
17095
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17206
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17096
17207
  if (isDisabled)
17097
17208
  return;
17098
17209
  const selection = this.range.getSelectionElementList();
@@ -17116,7 +17227,7 @@ class CommandAdapt {
17116
17227
  }
17117
17228
  }
17118
17229
  superscript() {
17119
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17230
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17120
17231
  if (isDisabled)
17121
17232
  return;
17122
17233
  const selection = this.range.getSelectionElementList();
@@ -17138,7 +17249,7 @@ class CommandAdapt {
17138
17249
  this.draw.render({ isSetCursor: false });
17139
17250
  }
17140
17251
  subscript() {
17141
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17252
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17142
17253
  if (isDisabled)
17143
17254
  return;
17144
17255
  const selection = this.range.getSelectionElementList();
@@ -17160,7 +17271,7 @@ class CommandAdapt {
17160
17271
  this.draw.render({ isSetCursor: false });
17161
17272
  }
17162
17273
  color(payload) {
17163
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17274
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17164
17275
  if (isDisabled)
17165
17276
  return;
17166
17277
  const selection = this.range.getSelectionElementList();
@@ -17191,7 +17302,7 @@ class CommandAdapt {
17191
17302
  }
17192
17303
  }
17193
17304
  highlight(payload) {
17194
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17305
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17195
17306
  if (isDisabled)
17196
17307
  return;
17197
17308
  const selection = this.range.getSelectionElementList();
@@ -18240,7 +18351,7 @@ class CommandAdapt {
18240
18351
  }
18241
18352
  }
18242
18353
  image(payload) {
18243
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
18354
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
18244
18355
  if (isDisabled)
18245
18356
  return;
18246
18357
  const { startIndex, endIndex } = this.range.getRange();
@@ -18670,8 +18781,8 @@ class CommandAdapt {
18670
18781
  }
18671
18782
  }
18672
18783
  }
18673
- setValue(payload) {
18674
- this.draw.setValue(payload);
18784
+ setValue(payload, options) {
18785
+ this.draw.setValue(payload, options);
18675
18786
  }
18676
18787
  removeControl() {
18677
18788
  const { startIndex, endIndex } = this.range.getRange();
@@ -18801,21 +18912,12 @@ class CommandAdapt {
18801
18912
  return this.draw.getControl().getValueByConceptId(payload);
18802
18913
  }
18803
18914
  setControlValue(payload) {
18804
- const isReadonly = this.draw.isReadonly();
18805
- if (isReadonly)
18806
- return;
18807
18915
  this.draw.getControl().setValueByConceptId(payload);
18808
18916
  }
18809
18917
  setControlExtension(payload) {
18810
- const isReadonly = this.draw.isReadonly();
18811
- if (isReadonly)
18812
- return;
18813
18918
  this.draw.getControl().setExtensionByConceptId(payload);
18814
18919
  }
18815
18920
  setControlProperties(payload) {
18816
- const isReadonly = this.draw.isReadonly();
18817
- if (isReadonly)
18818
- return;
18819
18921
  this.draw.getControl().setPropertiesByConceptId(payload);
18820
18922
  }
18821
18923
  setControlHighlight(payload) {