@hufe921/canvas-editor 0.9.85 → 0.9.87

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,43 @@
1
+ ## [0.9.87](https://github.com/Hufe921/canvas-editor/compare/v0.9.86...v0.9.87) (2024-07-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * format of checkbox and radio control value ([72686fd](https://github.com/Hufe921/canvas-editor/commit/72686fda1bf12353699fd57273493d8a9b4caee4))
7
+ * highlight checkbox and radio control #707 ([d939aa3](https://github.com/Hufe921/canvas-editor/commit/d939aa35ba7b19e5d1b5c4121fb873b2c579cc55)), closes [#707](https://github.com/Hufe921/canvas-editor/issues/707)
8
+ * set control highlight limit component type ([e14fbd6](https://github.com/Hufe921/canvas-editor/commit/e14fbd622d1076cba5f34bd4fa29530af4f70261))
9
+ * update punctuation width when scaling the page #712 ([83cb479](https://github.com/Hufe921/canvas-editor/commit/83cb47913195c43cde2b3ae344ff1d89a223e6a6)), closes [#712](https://github.com/Hufe921/canvas-editor/issues/712)
10
+ * word breaking when scaling the page #666 ([2bd1f34](https://github.com/Hufe921/canvas-editor/commit/2bd1f34c15196968f69d4711613f1c81f1dade68)), closes [#666](https://github.com/Hufe921/canvas-editor/issues/666)
11
+
12
+
13
+ ### Features
14
+
15
+ * add custom field to getValue api #699 ([67c63f8](https://github.com/Hufe921/canvas-editor/commit/67c63f856f2c0e3e8c0644e39694357639c18d7e)), closes [#699](https://github.com/Hufe921/canvas-editor/issues/699)
16
+ * delete cell contents when selecting rows and columns #706 ([ccd0627](https://github.com/Hufe921/canvas-editor/commit/ccd0627a6fad975acb43e9f16dda3fa13972c908)), closes [#706](https://github.com/Hufe921/canvas-editor/issues/706)
17
+ * optimize text selection at the beginning of a line #695 ([97ac2da](https://github.com/Hufe921/canvas-editor/commit/97ac2daaf8f0688b181cb8baea9ba74ae1664361)), closes [#695](https://github.com/Hufe921/canvas-editor/issues/695)
18
+ * set control properties in read-only mode #679 ([26a3468](https://github.com/Hufe921/canvas-editor/commit/26a3468f66d67bf8249cdc1a679c740d7cf1a9c9)), closes [#679](https://github.com/Hufe921/canvas-editor/issues/679)
19
+ * set the container scrollbar to automatically scroll #711 ([b226566](https://github.com/Hufe921/canvas-editor/commit/b226566e2bf6f1b4bc3ae11577c7a96ae3cbf2d0)), closes [#711](https://github.com/Hufe921/canvas-editor/issues/711)
20
+
21
+
22
+
23
+ ## [0.9.86](https://github.com/Hufe921/canvas-editor/compare/v0.9.85...v0.9.86) (2024-07-13)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * add control placeholder boundary error #686 ([fac5c5c](https://github.com/Hufe921/canvas-editor/commit/fac5c5c045a30cb5e0c46ef027c83f21e07bcaa8)), closes [#686](https://github.com/Hufe921/canvas-editor/issues/686)
29
+ * add control placeholder using default style #691 ([eb3ea5e](https://github.com/Hufe921/canvas-editor/commit/eb3ea5ed55cdedea0e281d45177c8661f674a280)), closes [#691](https://github.com/Hufe921/canvas-editor/issues/691)
30
+ * delete table col boundary error #688 ([3f0a49f](https://github.com/Hufe921/canvas-editor/commit/3f0a49f56be7060d328a63c994f571b0a35a3521)), closes [#688](https://github.com/Hufe921/canvas-editor/issues/688)
31
+ * refocus when cursor is not focused #685 ([0ac8ae7](https://github.com/Hufe921/canvas-editor/commit/0ac8ae7c4b0b47ee84a9c0f8c37ffde612849957)), closes [#685](https://github.com/Hufe921/canvas-editor/issues/685)
32
+ * remove title and list properties from getControlList return value #683 ([b024050](https://github.com/Hufe921/canvas-editor/commit/b024050b3ef7f787079a74b062e5d83085be1a5f)), closes [#683](https://github.com/Hufe921/canvas-editor/issues/683)
33
+
34
+
35
+ ### Features
36
+
37
+ * add executeInsertControl api ([e5b3d05](https://github.com/Hufe921/canvas-editor/commit/e5b3d05991a26dc186cdf63962ca3c7b50a32572))
38
+
39
+
40
+
1
41
  ## [0.9.85](https://github.com/Hufe921/canvas-editor/compare/v0.9.84...v0.9.85) (2024-07-07)
2
42
 
3
43
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.85";
26
+ const version = "0.9.87";
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,
@@ -5290,8 +5290,10 @@ class Cursor {
5290
5290
  const agentCursorDom = this.cursorAgent.getAgentCursorDom();
5291
5291
  if (isFocus) {
5292
5292
  setTimeout(() => {
5293
- agentCursorDom.focus();
5294
- agentCursorDom.setSelectionRange(0, 0);
5293
+ if (document.activeElement !== agentCursorDom) {
5294
+ agentCursorDom.focus();
5295
+ agentCursorDom.setSelectionRange(0, 0);
5296
+ }
5295
5297
  });
5296
5298
  }
5297
5299
  const descent = metrics.boundingBoxDescent < 0 ? 0 : metrics.boundingBoxDescent;
@@ -5648,7 +5650,6 @@ function setRangeCache(host) {
5648
5650
  host.cachePositionContext = position.getPositionContext();
5649
5651
  }
5650
5652
  function mousedown(evt, host) {
5651
- var _a;
5652
5653
  if (evt.button === MouseEventButton.RIGHT)
5653
5654
  return;
5654
5655
  const draw = host.getDraw();
@@ -5700,7 +5701,7 @@ function mousedown(evt, host) {
5700
5701
  if (!control) {
5701
5702
  draw.getCheckboxParticle().setSelect(curElement);
5702
5703
  } else {
5703
- const codes = ((_a = control == null ? void 0 : control.code) == null ? void 0 : _a.split(",")) || [];
5704
+ const codes = (control == null ? void 0 : control.code) ? control.code.split(",") : [];
5704
5705
  if (checkbox == null ? void 0 : checkbox.value) {
5705
5706
  const codeIndex = codes.findIndex((c) => c === checkbox.code);
5706
5707
  codes.splice(codeIndex, 1);
@@ -6054,9 +6055,26 @@ function backspace(evt, host) {
6054
6055
  const rangeManager = draw.getRange();
6055
6056
  if (!rangeManager.getIsCanInput())
6056
6057
  return;
6058
+ const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
6057
6059
  const control = draw.getControl();
6058
6060
  let curIndex;
6059
- 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()) {
6060
6078
  curIndex = control.keydown(evt);
6061
6079
  } else {
6062
6080
  const position = draw.getPosition();
@@ -6064,7 +6082,6 @@ function backspace(evt, host) {
6064
6082
  if (!cursorPosition)
6065
6083
  return;
6066
6084
  const { index: index2 } = cursorPosition;
6067
- const { startIndex, endIndex } = rangeManager.getRange();
6068
6085
  const isCollapsed = rangeManager.getIsCollapsed();
6069
6086
  const elementList = draw.getElementList();
6070
6087
  if (isCollapsed && index2 === 0) {
@@ -6094,11 +6111,19 @@ function backspace(evt, host) {
6094
6111
  }
6095
6112
  curIndex = isCollapsed ? index2 - 1 : startIndex;
6096
6113
  }
6097
- if (curIndex === null)
6098
- return;
6099
6114
  draw.getGlobalEvent().setCanvasEventAbility();
6100
- rangeManager.setRange(curIndex, curIndex);
6101
- 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
+ }
6102
6127
  }
6103
6128
  function del(evt, host) {
6104
6129
  var _a;
@@ -6108,11 +6133,27 @@ function del(evt, host) {
6108
6133
  const rangeManager = draw.getRange();
6109
6134
  if (!rangeManager.getIsCanInput())
6110
6135
  return;
6111
- const { startIndex, endIndex } = rangeManager.getRange();
6136
+ const { startIndex, endIndex, isCrossRowCol } = rangeManager.getRange();
6112
6137
  const elementList = draw.getElementList();
6113
6138
  const control = draw.getControl();
6114
6139
  let curIndex;
6115
- 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()) {
6116
6157
  curIndex = control.keydown(evt);
6117
6158
  } else if ((_a = elementList[endIndex + 1]) == null ? void 0 : _a.controlId) {
6118
6159
  curIndex = control.removeControl(endIndex + 1);
@@ -6138,11 +6179,19 @@ function del(evt, host) {
6138
6179
  curIndex = isCollapsed ? index2 : startIndex;
6139
6180
  }
6140
6181
  }
6141
- if (curIndex === null)
6142
- return;
6143
6182
  draw.getGlobalEvent().setCanvasEventAbility();
6144
- rangeManager.setRange(curIndex, curIndex);
6145
- 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
+ }
6146
6195
  }
6147
6196
  function enter(evt, host) {
6148
6197
  var _a, _b;
@@ -7978,9 +8027,12 @@ class Position {
7978
8027
  const { index: index2, rowNo, coordinate: { leftTop, leftBottom } } = lastLetterList[j];
7979
8028
  if (y > leftTop[1] && y <= leftBottom[1]) {
7980
8029
  const headIndex = positionList.findIndex((p) => p.pageNo === positionNo && p.rowNo === rowNo);
7981
- if (x < this.options.margins[3]) {
8030
+ const headElement = elementList[headIndex];
8031
+ const headPosition = positionList[headIndex];
8032
+ const headStartX = headElement.listStyle === ListStyle.CHECKBOX ? this.options.margins[3] : headPosition.coordinate.leftTop[0];
8033
+ if (x < headStartX) {
7982
8034
  if (~headIndex) {
7983
- if (positionList[headIndex].value === ZERO) {
8035
+ if (headPosition.value === ZERO) {
7984
8036
  curPositionIndex = headIndex;
7985
8037
  } else {
7986
8038
  curPositionIndex = headIndex - 1;
@@ -7990,7 +8042,7 @@ class Position {
7990
8042
  curPositionIndex = index2;
7991
8043
  }
7992
8044
  } else {
7993
- if (elementList[headIndex].listStyle === ListStyle.CHECKBOX && x < leftTop[0]) {
8045
+ if (headElement.listStyle === ListStyle.CHECKBOX && x < leftTop[0]) {
7994
8046
  return {
7995
8047
  index: headIndex,
7996
8048
  isDirectHit: true,
@@ -9413,12 +9465,22 @@ class SelectionObserver {
9413
9465
  constructor(draw) {
9414
9466
  __publicField(this, "step", 5);
9415
9467
  __publicField(this, "thresholdPoints", [70, 40, 10, 20]);
9468
+ __publicField(this, "selectionContainer");
9416
9469
  __publicField(this, "rangeManager");
9417
9470
  __publicField(this, "requestAnimationFrameId");
9418
9471
  __publicField(this, "isMousedown");
9419
9472
  __publicField(this, "isMoving");
9473
+ __publicField(this, "clientWidth");
9474
+ __publicField(this, "clientHeight");
9475
+ __publicField(this, "containerRect");
9420
9476
  __publicField(this, "_mousedown", () => {
9421
9477
  this.isMousedown = true;
9478
+ this.clientWidth = this.selectionContainer instanceof Document ? document.documentElement.clientWidth : this.selectionContainer.clientWidth;
9479
+ this.clientHeight = this.selectionContainer instanceof Document ? document.documentElement.clientHeight : this.selectionContainer.clientHeight;
9480
+ if (!(this.selectionContainer instanceof Document)) {
9481
+ const rect = this.selectionContainer.getBoundingClientRect();
9482
+ this.containerRect = rect;
9483
+ }
9422
9484
  });
9423
9485
  __publicField(this, "_mouseup", () => {
9424
9486
  this.isMousedown = false;
@@ -9427,48 +9489,60 @@ class SelectionObserver {
9427
9489
  __publicField(this, "_mousemove", (evt) => {
9428
9490
  if (!this.isMousedown || this.rangeManager.getIsCollapsed())
9429
9491
  return;
9430
- const { x, y } = evt;
9431
- const clientWidth = document.documentElement.clientWidth;
9432
- const clientHeight = document.documentElement.clientHeight;
9492
+ let { x, y } = evt;
9493
+ if (this.containerRect) {
9494
+ x = x - this.containerRect.x;
9495
+ y = y - this.containerRect.y;
9496
+ }
9433
9497
  if (y < this.thresholdPoints[0]) {
9434
9498
  this._startMove(MoveDirection.UP);
9435
- } else if (clientHeight - y <= this.thresholdPoints[1]) {
9499
+ } else if (this.clientHeight - y <= this.thresholdPoints[1]) {
9436
9500
  this._startMove(MoveDirection.DOWN);
9437
9501
  } else if (x < this.thresholdPoints[2]) {
9438
9502
  this._startMove(MoveDirection.LEFT);
9439
- } else if (clientWidth - x < this.thresholdPoints[3]) {
9503
+ } else if (this.clientWidth - x < this.thresholdPoints[3]) {
9440
9504
  this._startMove(MoveDirection.RIGHT);
9441
9505
  } else {
9442
9506
  this._stopMove();
9443
9507
  }
9444
9508
  });
9509
+ this.rangeManager = draw.getRange();
9510
+ const { scrollContainerSelector } = draw.getOptions();
9511
+ this.selectionContainer = scrollContainerSelector ? document.querySelector(scrollContainerSelector) || document : document;
9445
9512
  this.requestAnimationFrameId = null;
9446
9513
  this.isMousedown = false;
9447
9514
  this.isMoving = false;
9448
- this.rangeManager = draw.getRange();
9515
+ this.clientWidth = 0;
9516
+ this.clientHeight = 0;
9517
+ this.containerRect = null;
9449
9518
  this._addEvent();
9450
9519
  }
9451
9520
  _addEvent() {
9452
- document.addEventListener("mousedown", this._mousedown);
9453
- document.addEventListener("mousemove", this._mousemove);
9454
- document.addEventListener("mouseup", this._mouseup);
9521
+ const container = this.selectionContainer;
9522
+ container.addEventListener("mousedown", this._mousedown);
9523
+ container.addEventListener("mousemove", this._mousemove);
9524
+ container.addEventListener("mouseup", this._mouseup);
9525
+ document.addEventListener("mouseleave", this._mouseup);
9455
9526
  }
9456
9527
  removeEvent() {
9457
- document.removeEventListener("mousedown", this._mousedown);
9458
- document.removeEventListener("mousemove", this._mousemove);
9459
- document.removeEventListener("mouseup", this._mouseup);
9528
+ const container = this.selectionContainer;
9529
+ container.removeEventListener("mousedown", this._mousedown);
9530
+ container.removeEventListener("mousemove", this._mousemove);
9531
+ container.removeEventListener("mouseup", this._mouseup);
9532
+ document.removeEventListener("mouseleave", this._mouseup);
9460
9533
  }
9461
9534
  _move(direction) {
9462
- const x = window.scrollX;
9463
- const y = window.scrollY;
9535
+ const container = this.selectionContainer instanceof Document ? window : this.selectionContainer;
9536
+ const x = this.selectionContainer instanceof Document ? window.scrollX : container.scrollLeft;
9537
+ const y = this.selectionContainer instanceof Document ? window.scrollY : container.scrollTop;
9464
9538
  if (direction === MoveDirection.DOWN) {
9465
- window.scrollTo(x, y + this.step);
9539
+ container.scrollTo(x, y + this.step);
9466
9540
  } else if (direction === MoveDirection.UP) {
9467
- window.scrollTo(x, y - this.step);
9541
+ container.scrollTo(x, y - this.step);
9468
9542
  } else if (direction === MoveDirection.LEFT) {
9469
- window.scrollTo(x - this.step, y);
9543
+ container.scrollTo(x - this.step, y);
9470
9544
  } else {
9471
- window.scrollTo(x + this.step, y);
9545
+ container.scrollTo(x + this.step, y);
9472
9546
  }
9473
9547
  this.requestAnimationFrameId = window.requestAnimationFrame(this._move.bind(this, direction));
9474
9548
  }
@@ -10474,7 +10548,7 @@ class ControlSearch {
10474
10548
  newEndIndex++;
10475
10549
  }
10476
10550
  i = newEndIndex;
10477
- const controlElementList = elementList.slice(startIndex, newEndIndex);
10551
+ const controlElementList = elementList.slice(startIndex, newEndIndex).map((element2) => element2.controlComponent === ControlComponent.VALUE ? element2 : { value: ZERO });
10478
10552
  const highlight = this.highlightList[highlightIndex];
10479
10553
  const { ruleList } = highlight;
10480
10554
  for (let r = 0; r < ruleList.length; r++) {
@@ -10893,7 +10967,7 @@ class TextControl {
10893
10967
  this.control.getDraw().spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
10894
10968
  const value = this.getValue(context);
10895
10969
  if (!value.length) {
10896
- this.control.addPlaceholder(startIndex);
10970
+ this.control.addPlaceholder(startIndex, context);
10897
10971
  }
10898
10972
  return startIndex;
10899
10973
  }
@@ -12067,16 +12141,17 @@ class Control {
12067
12141
  if (!control.placeholder)
12068
12142
  return;
12069
12143
  const placeholderStrList = splitText(control.placeholder);
12144
+ const anchorElementStyleAttr = pickObject(startElement, CONTROL_STYLE_ATTR);
12070
12145
  for (let p = 0; p < placeholderStrList.length; p++) {
12071
12146
  const value = placeholderStrList[p];
12072
- const newElement = {
12147
+ const newElement = __spreadProps(__spreadValues({}, anchorElementStyleAttr), {
12073
12148
  value,
12074
12149
  controlId: startElement.controlId,
12075
12150
  type: ElementType.CONTROL,
12076
12151
  control: startElement.control,
12077
12152
  controlComponent: ControlComponent.PLACEHOLDER,
12078
12153
  color: this.controlOptions.placeholderColor
12079
- };
12154
+ });
12080
12155
  formatElementContext(elementList, [newElement], startIndex);
12081
12156
  this.draw.spliceElementList(elementList, startIndex + p + 1, 0, newElement);
12082
12157
  }
@@ -12172,9 +12247,6 @@ class Control {
12172
12247
  return result;
12173
12248
  }
12174
12249
  setValueByConceptId(payload) {
12175
- const isReadonly = this.draw.isReadonly();
12176
- if (isReadonly)
12177
- return;
12178
12250
  let isExistSet = false;
12179
12251
  const { conceptId, value } = payload;
12180
12252
  const setValue = (elementList) => {
@@ -12239,7 +12311,7 @@ class Control {
12239
12311
  } else if (type === ControlType.CHECKBOX) {
12240
12312
  const checkbox = new CheckboxControl(element, this);
12241
12313
  this.activeControl = checkbox;
12242
- const codes = (value == null ? void 0 : value.split(",")) || [];
12314
+ const codes = value ? value.split(",") : [];
12243
12315
  checkbox.setSelect(codes, controlContext, controlRule);
12244
12316
  } else if (type === ControlType.RADIO) {
12245
12317
  const radio = new RadioControl(element, this);
@@ -12282,9 +12354,6 @@ class Control {
12282
12354
  }
12283
12355
  }
12284
12356
  setExtensionByConceptId(payload) {
12285
- const isReadonly = this.draw.isReadonly();
12286
- if (isReadonly)
12287
- return;
12288
12357
  const { conceptId, extension } = payload;
12289
12358
  const setExtension = (elementList) => {
12290
12359
  var _a;
@@ -12325,9 +12394,6 @@ class Control {
12325
12394
  }
12326
12395
  }
12327
12396
  setPropertiesByConceptId(payload) {
12328
- const isReadonly = this.draw.isReadonly();
12329
- if (isReadonly)
12330
- return;
12331
12397
  const { conceptId, properties } = payload;
12332
12398
  let isExistUpdate = false;
12333
12399
  function setProperties(elementList) {
@@ -12409,7 +12475,11 @@ class Control {
12409
12475
  }
12410
12476
  }
12411
12477
  if (element.controlId) {
12412
- controlElementList.push(element);
12478
+ const controlElement = omitObject(element, [
12479
+ ...TITLE_CONTEXT_ATTR,
12480
+ ...LIST_CONTEXT_ATTR
12481
+ ]);
12482
+ controlElementList.push(controlElement);
12413
12483
  }
12414
12484
  }
12415
12485
  }
@@ -15227,15 +15297,21 @@ class Draw {
15227
15297
  });
15228
15298
  }
15229
15299
  getValue(options = {}) {
15230
- const { pageNo } = options;
15300
+ const { pageNo, extraPickAttrs } = options;
15231
15301
  let mainElementList = this.elementList;
15232
15302
  if (Number.isInteger(pageNo) && pageNo >= 0 && pageNo < this.pageRowList.length) {
15233
15303
  mainElementList = this.pageRowList[pageNo].flatMap((row) => row.elementList);
15234
15304
  }
15235
15305
  const data2 = {
15236
- header: zipElementList(this.getHeaderElementList()),
15237
- main: zipElementList(mainElementList),
15238
- footer: zipElementList(this.getFooterElementList())
15306
+ header: zipElementList(this.getHeaderElementList(), {
15307
+ extraPickAttrs
15308
+ }),
15309
+ main: zipElementList(mainElementList, {
15310
+ extraPickAttrs
15311
+ }),
15312
+ footer: zipElementList(this.getFooterElementList(), {
15313
+ extraPickAttrs
15314
+ })
15239
15315
  };
15240
15316
  return {
15241
15317
  version,
@@ -15657,12 +15733,14 @@ class Draw {
15657
15733
  const word = `${(preElement == null ? void 0 : preElement.value) || ""}${element.value}`;
15658
15734
  if (this.WORD_LIKE_REG.test(word)) {
15659
15735
  const { width, endElement } = this.textParticle.measureWord(ctx, elementList, i);
15660
- if (width <= availableWidth) {
15661
- curRowWidth += width;
15736
+ const wordWidth = width * scale;
15737
+ if (wordWidth <= availableWidth) {
15738
+ curRowWidth += wordWidth;
15662
15739
  nextElement = endElement;
15663
15740
  }
15664
15741
  }
15665
- curRowWidth += this.textParticle.measurePunctuationWidth(ctx, nextElement);
15742
+ const punctuationWidth = this.textParticle.measurePunctuationWidth(ctx, nextElement);
15743
+ curRowWidth += punctuationWidth * scale;
15666
15744
  }
15667
15745
  }
15668
15746
  if (element.listId) {
@@ -16338,6 +16416,7 @@ class Command {
16338
16416
  __publicField(this, "executeSetControlProperties");
16339
16417
  __publicField(this, "executeSetControlHighlight");
16340
16418
  __publicField(this, "executeLocationControl");
16419
+ __publicField(this, "executeInsertControl");
16341
16420
  __publicField(this, "executeUpdateOptions");
16342
16421
  __publicField(this, "executeInsertTitle");
16343
16422
  __publicField(this, "getCatalog");
@@ -16476,6 +16555,7 @@ class Command {
16476
16555
  this.getControlValue = adapt.getControlValue.bind(adapt);
16477
16556
  this.getControlList = adapt.getControlList.bind(adapt);
16478
16557
  this.executeLocationControl = adapt.locationControl.bind(adapt);
16558
+ this.executeInsertControl = adapt.insertControl.bind(adapt);
16479
16559
  }
16480
16560
  }
16481
16561
  const defaultWatermarkOption = {
@@ -17667,27 +17747,15 @@ class CommandAdapt {
17667
17747
  const tr = curTrList[t];
17668
17748
  for (let d = 0; d < tr.tdList.length; d++) {
17669
17749
  const td = tr.tdList[d];
17670
- if (td.colspan > 1) {
17671
- const tdColIndex = td.colIndex;
17672
- if (tdColIndex <= curColIndex && tdColIndex + td.colspan - 1 >= curColIndex) {
17673
- td.colspan -= 1;
17750
+ if (td.colIndex <= curColIndex && td.colIndex + td.colspan > curColIndex) {
17751
+ if (td.colspan > 1) {
17752
+ td.colspan--;
17753
+ } else {
17754
+ tr.tdList.splice(d, 1);
17674
17755
  }
17675
17756
  }
17676
17757
  }
17677
17758
  }
17678
- for (let t = 0; t < curTrList.length; t++) {
17679
- const tr = curTrList[t];
17680
- let start = -1;
17681
- for (let d = 0; d < tr.tdList.length; d++) {
17682
- const td = tr.tdList[d];
17683
- if (td.colIndex === curColIndex) {
17684
- start = d;
17685
- }
17686
- }
17687
- if (~start) {
17688
- tr.tdList.splice(start, 1);
17689
- }
17690
- }
17691
17759
  (_a = element.colgroup) == null ? void 0 : _a.splice(curColIndex, 1);
17692
17760
  this.position.setPositionContext({
17693
17761
  isTable: false
@@ -18804,21 +18872,12 @@ class CommandAdapt {
18804
18872
  return this.draw.getControl().getValueByConceptId(payload);
18805
18873
  }
18806
18874
  setControlValue(payload) {
18807
- const isReadonly = this.draw.isReadonly();
18808
- if (isReadonly)
18809
- return;
18810
18875
  this.draw.getControl().setValueByConceptId(payload);
18811
18876
  }
18812
18877
  setControlExtension(payload) {
18813
- const isReadonly = this.draw.isReadonly();
18814
- if (isReadonly)
18815
- return;
18816
18878
  this.draw.getControl().setExtensionByConceptId(payload);
18817
18879
  }
18818
18880
  setControlProperties(payload) {
18819
- const isReadonly = this.draw.isReadonly();
18820
- if (isReadonly)
18821
- return;
18822
18881
  this.draw.getControl().setPropertiesByConceptId(payload);
18823
18882
  }
18824
18883
  setControlHighlight(payload) {
@@ -18911,6 +18970,24 @@ class CommandAdapt {
18911
18970
  }
18912
18971
  }
18913
18972
  }
18973
+ insertControl(payload) {
18974
+ const isReadonly = this.draw.isReadonly();
18975
+ if (isReadonly)
18976
+ return;
18977
+ const cloneElement = deepClone(payload);
18978
+ const { startIndex } = this.range.getRange();
18979
+ const elementList = this.draw.getElementList();
18980
+ const copyElement = getAnchorElement(elementList, startIndex);
18981
+ if (!copyElement)
18982
+ return;
18983
+ const cloneAttr = [
18984
+ ...TABLE_CONTEXT_ATTR,
18985
+ ...EDITOR_ROW_ATTR,
18986
+ ...LIST_CONTEXT_ATTR
18987
+ ];
18988
+ cloneProperty(cloneAttr, copyElement, cloneElement);
18989
+ this.draw.insertElementList([cloneElement]);
18990
+ }
18914
18991
  getContainer() {
18915
18992
  return this.draw.getContainer();
18916
18993
  }