@hufe921/canvas-editor 0.9.97 → 0.9.98

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.97";
26
+ const version = "0.9.98";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -387,6 +387,9 @@ function isRectIntersect(rect1, rect2) {
387
387
  function isNonValue(value) {
388
388
  return value === void 0 || value === null;
389
389
  }
390
+ function normalizeLineBreak(text) {
391
+ return text.replace(/\r\n|\r/g, "\n");
392
+ }
390
393
  const CURSOR_AGENT_OFFSET_HEIGHT = 12;
391
394
  const defaultCursorOption = {
392
395
  width: 1,
@@ -472,6 +475,7 @@ const EDITOR_ELEMENT_ZIP_ATTR = [
472
475
  "dashArray",
473
476
  "trList",
474
477
  "borderType",
478
+ "borderColor",
475
479
  "width",
476
480
  "height",
477
481
  "url",
@@ -3772,6 +3776,8 @@ var ControlComponent;
3772
3776
  (function(ControlComponent2) {
3773
3777
  ControlComponent2["PREFIX"] = "prefix";
3774
3778
  ControlComponent2["POSTFIX"] = "postfix";
3779
+ ControlComponent2["PRE_TEXT"] = "preText";
3780
+ ControlComponent2["POST_TEXT"] = "postText";
3775
3781
  ControlComponent2["PLACEHOLDER"] = "placeholder";
3776
3782
  ControlComponent2["VALUE"] = "value";
3777
3783
  ControlComponent2["CHECKBOX"] = "checkbox";
@@ -3899,7 +3905,8 @@ const defaultSeparatorOption = {
3899
3905
  const defaultTableOption = {
3900
3906
  tdPadding: [0, 5, 5, 5],
3901
3907
  defaultTrMinHeight: 42,
3902
- defaultColMinWidth: 40
3908
+ defaultColMinWidth: 40,
3909
+ defaultBorderColor: "#000000"
3903
3910
  };
3904
3911
  const defaultWatermarkOption = {
3905
3912
  data: "",
@@ -4238,7 +4245,7 @@ function formatElementList(elementList, options) {
4238
4245
  i++;
4239
4246
  continue;
4240
4247
  }
4241
- const { prefix, postfix, value, placeholder, code, type, valueSets } = el.control;
4248
+ const { prefix, postfix, preText, postText, value, placeholder, code, type, valueSets } = el.control;
4242
4249
  const { editorOptions: { control: controlOption, checkbox: checkboxOption, radio: radioOption } } = options;
4243
4250
  const controlId = el.controlId || getUUID();
4244
4251
  elementList.splice(i, 1);
@@ -4262,6 +4269,20 @@ function formatElementList(elementList, options) {
4262
4269
  }));
4263
4270
  i++;
4264
4271
  }
4272
+ if (preText) {
4273
+ const preTextStrList = splitText(preText);
4274
+ for (let p = 0; p < preTextStrList.length; p++) {
4275
+ const value2 = preTextStrList[p];
4276
+ elementList.splice(i, 0, __spreadProps(__spreadValues(__spreadValues({}, controlContext), controlDefaultStyle), {
4277
+ controlId,
4278
+ value: value2,
4279
+ type: el.type,
4280
+ control: el.control,
4281
+ controlComponent: ControlComponent.PRE_TEXT
4282
+ }));
4283
+ i++;
4284
+ }
4285
+ }
4265
4286
  if (value && value.length || type === ControlType.CHECKBOX || type === ControlType.RADIO || type === ControlType.SELECT && code && (!value || !value.length)) {
4266
4287
  let valueList = value || [];
4267
4288
  if (type === ControlType.CHECKBOX) {
@@ -4380,6 +4401,20 @@ function formatElementList(elementList, options) {
4380
4401
  i++;
4381
4402
  }
4382
4403
  }
4404
+ if (postText) {
4405
+ const postTextStrList = splitText(postText);
4406
+ for (let p = 0; p < postTextStrList.length; p++) {
4407
+ const value2 = postTextStrList[p];
4408
+ elementList.splice(i, 0, __spreadProps(__spreadValues(__spreadValues({}, controlContext), controlDefaultStyle), {
4409
+ controlId,
4410
+ value: value2,
4411
+ type: el.type,
4412
+ control: el.control,
4413
+ controlComponent: ControlComponent.POST_TEXT
4414
+ }));
4415
+ i++;
4416
+ }
4417
+ }
4383
4418
  const postfixStrList = splitText(postfix || controlOption.postfix);
4384
4419
  for (let p = 0; p < postfixStrList.length; p++) {
4385
4420
  const value2 = postfixStrList[p];
@@ -4634,31 +4669,45 @@ function zipElementList(payload, options = {}) {
4634
4669
  }
4635
4670
  } else if (element.controlId) {
4636
4671
  const controlId = element.controlId;
4637
- if (controlId) {
4638
- const controlDefaultStyle = pickObject(element, CONTROL_STYLE_ATTR);
4639
- const control = __spreadValues(__spreadValues({}, element.control), controlDefaultStyle);
4640
- const controlElement = __spreadProps(__spreadValues({}, pickObject(element, EDITOR_ROW_ATTR)), {
4641
- type: ElementType.CONTROL,
4642
- value: "",
4643
- control,
4644
- controlId
4645
- });
4672
+ if (element.controlComponent === ControlComponent.PREFIX) {
4646
4673
  const valueList = [];
4647
- while (e < elementList.length) {
4648
- const controlE = elementList[e];
4649
- if (controlId !== controlE.controlId) {
4650
- e--;
4674
+ let isFull = false;
4675
+ let start = e;
4676
+ while (start < elementList.length) {
4677
+ const controlE = elementList[start];
4678
+ if (controlId !== controlE.controlId)
4651
4679
  break;
4652
- }
4653
4680
  if (controlE.controlComponent === ControlComponent.VALUE) {
4654
4681
  delete controlE.control;
4655
4682
  delete controlE.controlId;
4656
4683
  valueList.push(controlE);
4657
4684
  }
4685
+ if (controlE.controlComponent === ControlComponent.POSTFIX) {
4686
+ isFull = true;
4687
+ }
4688
+ start++;
4689
+ }
4690
+ if (isFull) {
4691
+ const controlDefaultStyle = pickObject(element, CONTROL_STYLE_ATTR);
4692
+ const control = __spreadValues(__spreadValues({}, element.control), controlDefaultStyle);
4693
+ const controlElement = __spreadProps(__spreadValues({}, pickObject(element, EDITOR_ROW_ATTR)), {
4694
+ type: ElementType.CONTROL,
4695
+ value: "",
4696
+ control,
4697
+ controlId
4698
+ });
4699
+ controlElement.control.value = zipElementList(valueList, options);
4700
+ element = pickElementAttr(controlElement, { extraPickAttrs });
4701
+ e += start - e - 1;
4702
+ }
4703
+ }
4704
+ if (element.controlComponent) {
4705
+ delete element.control;
4706
+ delete element.controlId;
4707
+ if (element.controlComponent !== ControlComponent.VALUE && element.controlComponent !== ControlComponent.PRE_TEXT && element.controlComponent !== ControlComponent.POST_TEXT) {
4658
4708
  e++;
4709
+ continue;
4659
4710
  }
4660
- controlElement.control.value = zipElementList(valueList, options);
4661
- element = pickElementAttr(controlElement, { extraPickAttrs });
4662
4711
  }
4663
4712
  }
4664
4713
  const pickElement = pickElementAttr(element, { extraPickAttrs });
@@ -5237,7 +5286,7 @@ function getElementListByHTML(htmlText, options) {
5237
5286
  }
5238
5287
  function getTextFromElementList(elementList) {
5239
5288
  function buildText(payload) {
5240
- var _a, _b, _c, _d, _e;
5289
+ var _a, _b, _c, _d, _e, _f, _g;
5241
5290
  let text = "";
5242
5291
  for (let e = 0; e < payload.length; e++) {
5243
5292
  const element = payload[e];
@@ -5282,9 +5331,10 @@ ${ulListStyleText || `${listIndex + 1}.`}${buildText(listElementList)}${isLast ?
5282
5331
  } else if (!element.type || element.type === ElementType.LATEX || TEXTLIKE_ELEMENT_TYPE.includes(element.type)) {
5283
5332
  let textLike = "";
5284
5333
  if (element.type === ElementType.CONTROL) {
5285
- textLike = ((_d = (_c = element.control.value) == null ? void 0 : _c[0]) == null ? void 0 : _d.value) || "";
5334
+ const controlValue = ((_d = (_c = element.control.value) == null ? void 0 : _c[0]) == null ? void 0 : _d.value) || "";
5335
+ textLike = controlValue ? `${((_e = element.control) == null ? void 0 : _e.preText) || ""}${controlValue}${((_f = element.control) == null ? void 0 : _f.postText) || ""}` : "";
5286
5336
  } else if (element.type === ElementType.DATE) {
5287
- textLike = ((_e = element.valueList) == null ? void 0 : _e.map((v) => v.value).join("")) || "";
5337
+ textLike = ((_g = element.valueList) == null ? void 0 : _g.map((v) => v.value).join("")) || "";
5288
5338
  } else {
5289
5339
  textLike = element.value;
5290
5340
  }
@@ -5490,7 +5540,7 @@ function pasteByEvent(host, evt) {
5490
5540
  if (!getIsClipboardContainFile(clipboardData)) {
5491
5541
  const clipboardText = clipboardData.getData("text");
5492
5542
  const editorClipboardData = getClipboardData();
5493
- if (clipboardText === (editorClipboardData == null ? void 0 : editorClipboardData.text)) {
5543
+ if (editorClipboardData && normalizeLineBreak(clipboardText) === normalizeLineBreak(editorClipboardData.text)) {
5494
5544
  pasteElement(host, editorClipboardData.elementList);
5495
5545
  return;
5496
5546
  }
@@ -5897,7 +5947,7 @@ class CheckboxControl {
5897
5947
  let preIndex = startIndex;
5898
5948
  while (preIndex > 0) {
5899
5949
  const preElement = elementList[preIndex];
5900
- if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
5950
+ if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
5901
5951
  break;
5902
5952
  }
5903
5953
  if (preElement.controlComponent === ControlComponent.VALUE) {
@@ -5908,7 +5958,7 @@ class CheckboxControl {
5908
5958
  let nextIndex = startIndex + 1;
5909
5959
  while (nextIndex < elementList.length) {
5910
5960
  const nextElement = elementList[nextIndex];
5911
- if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX) {
5961
+ if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX || nextElement.controlComponent === ControlComponent.POST_TEXT) {
5912
5962
  break;
5913
5963
  }
5914
5964
  if (nextElement.controlComponent === ControlComponent.VALUE) {
@@ -5932,7 +5982,7 @@ class CheckboxControl {
5932
5982
  let preIndex = startIndex;
5933
5983
  while (preIndex > 0) {
5934
5984
  const preElement = elementList[preIndex];
5935
- if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
5985
+ if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
5936
5986
  break;
5937
5987
  }
5938
5988
  if (preElement.controlComponent === ControlComponent.CHECKBOX) {
@@ -5944,7 +5994,7 @@ class CheckboxControl {
5944
5994
  let nextIndex = startIndex + 1;
5945
5995
  while (nextIndex < elementList.length) {
5946
5996
  const nextElement = elementList[nextIndex];
5947
- if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX) {
5997
+ if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX || nextElement.controlComponent === ControlComponent.POST_TEXT) {
5948
5998
  break;
5949
5999
  }
5950
6000
  if (nextElement.controlComponent === ControlComponent.CHECKBOX) {
@@ -5987,7 +6037,7 @@ class RadioControl extends CheckboxControl {
5987
6037
  let preIndex = startIndex;
5988
6038
  while (preIndex > 0) {
5989
6039
  const preElement = elementList[preIndex];
5990
- if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
6040
+ if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
5991
6041
  break;
5992
6042
  }
5993
6043
  if (preElement.controlComponent === ControlComponent.RADIO) {
@@ -5999,7 +6049,7 @@ class RadioControl extends CheckboxControl {
5999
6049
  let nextIndex = startIndex + 1;
6000
6050
  while (nextIndex < elementList.length) {
6001
6051
  const nextElement = elementList[nextIndex];
6002
- if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX) {
6052
+ if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX || nextElement.controlComponent === ControlComponent.POST_TEXT) {
6003
6053
  break;
6004
6054
  }
6005
6055
  if (nextElement.controlComponent === ControlComponent.RADIO) {
@@ -6680,7 +6730,7 @@ function enter(evt, host) {
6680
6730
  evt.preventDefault();
6681
6731
  }
6682
6732
  function left(evt, host) {
6683
- var _a, _b;
6733
+ var _a, _b, _c;
6684
6734
  const draw = host.getDraw();
6685
6735
  const isReadonly = draw.isReadonly();
6686
6736
  if (isReadonly)
@@ -6698,7 +6748,7 @@ function left(evt, host) {
6698
6748
  const isCollapsed = rangeManager.getIsCollapsed();
6699
6749
  const elementList = draw.getElementList();
6700
6750
  const control = draw.getControl();
6701
- if (draw.getMode() === EditorMode.FORM && control.getActiveControl() && ((_a = elementList[index2]) == null ? void 0 : _a.controlComponent) === ControlComponent.PREFIX) {
6751
+ if (draw.getMode() === EditorMode.FORM && control.getActiveControl() && (((_a = elementList[index2]) == null ? void 0 : _a.controlComponent) === ControlComponent.PREFIX || ((_b = elementList[index2]) == null ? void 0 : _b.controlComponent) === ControlComponent.PRE_TEXT)) {
6702
6752
  control.initNextControl({
6703
6753
  direction: MoveDirection.UP
6704
6754
  });
@@ -6708,7 +6758,7 @@ function left(evt, host) {
6708
6758
  if (isMod(evt)) {
6709
6759
  const LETTER_REG = draw.getLetterReg();
6710
6760
  const moveStartIndex = evt.shiftKey && !isCollapsed && startIndex === (cursorPosition == null ? void 0 : cursorPosition.index) ? endIndex : startIndex;
6711
- if (LETTER_REG.test((_b = elementList[moveStartIndex]) == null ? void 0 : _b.value)) {
6761
+ if (LETTER_REG.test((_c = elementList[moveStartIndex]) == null ? void 0 : _c.value)) {
6712
6762
  let i = moveStartIndex - 1;
6713
6763
  while (i > 0) {
6714
6764
  const element = elementList[i];
@@ -6818,7 +6868,7 @@ function left(evt, host) {
6818
6868
  evt.preventDefault();
6819
6869
  }
6820
6870
  function right(evt, host) {
6821
- var _a, _b;
6871
+ var _a, _b, _c;
6822
6872
  const draw = host.getDraw();
6823
6873
  const isReadonly = draw.isReadonly();
6824
6874
  if (isReadonly)
@@ -6837,7 +6887,7 @@ function right(evt, host) {
6837
6887
  const isCollapsed = rangeManager.getIsCollapsed();
6838
6888
  let elementList = draw.getElementList();
6839
6889
  const control = draw.getControl();
6840
- if (draw.getMode() === EditorMode.FORM && control.getActiveControl() && ((_a = elementList[index2 + 1]) == null ? void 0 : _a.controlComponent) === ControlComponent.POSTFIX) {
6890
+ if (draw.getMode() === EditorMode.FORM && control.getActiveControl() && (((_a = elementList[index2 + 1]) == null ? void 0 : _a.controlComponent) === ControlComponent.POSTFIX || ((_b = elementList[index2 + 1]) == null ? void 0 : _b.controlComponent) === ControlComponent.POST_TEXT)) {
6841
6891
  control.initNextControl({
6842
6892
  direction: MoveDirection.DOWN
6843
6893
  });
@@ -6847,7 +6897,7 @@ function right(evt, host) {
6847
6897
  if (isMod(evt)) {
6848
6898
  const LETTER_REG = draw.getLetterReg();
6849
6899
  const moveStartIndex = evt.shiftKey && !isCollapsed && startIndex === (cursorPosition == null ? void 0 : cursorPosition.index) ? endIndex : startIndex;
6850
- if (LETTER_REG.test((_b = elementList[moveStartIndex + 1]) == null ? void 0 : _b.value)) {
6900
+ if (LETTER_REG.test((_c = elementList[moveStartIndex + 1]) == null ? void 0 : _c.value)) {
6851
6901
  let i = moveStartIndex + 2;
6852
6902
  while (i < elementList.length) {
6853
6903
  const element = elementList[i];
@@ -7463,7 +7513,7 @@ function cut(host) {
7463
7513
  rangeManager.setRange(curIndex, curIndex);
7464
7514
  draw.render({ curIndex });
7465
7515
  }
7466
- function copy(host) {
7516
+ function copy(host, options) {
7467
7517
  const draw = host.getDraw();
7468
7518
  const { copy: copy2 } = draw.getOverride();
7469
7519
  if (copy2) {
@@ -7511,6 +7561,13 @@ function copy(host) {
7511
7561
  } else {
7512
7562
  copyElementList = rangeManager.getIsCollapsed() ? rangeManager.getRangeRowElementList() : rangeManager.getSelectionElementList();
7513
7563
  }
7564
+ if ((options == null ? void 0 : options.isPlainText) && (copyElementList == null ? void 0 : copyElementList.length)) {
7565
+ copyElementList = [
7566
+ {
7567
+ value: getTextFromElementList(copyElementList)
7568
+ }
7569
+ ];
7570
+ }
7514
7571
  if (!(copyElementList == null ? void 0 : copyElementList.length))
7515
7572
  return;
7516
7573
  writeElementList(copyElementList, draw.getOptions());
@@ -7897,8 +7954,8 @@ class CanvasEvent {
7897
7954
  cut() {
7898
7955
  cut(this);
7899
7956
  }
7900
- copy() {
7901
- copy(this);
7957
+ copy(options) {
7958
+ copy(this, options);
7902
7959
  }
7903
7960
  compositionstart() {
7904
7961
  composition.compositionstart(this);
@@ -8959,15 +9016,17 @@ class RangeManager {
8959
9016
  return rangeList;
8960
9017
  }
8961
9018
  getIsCanInput() {
9019
+ var _a;
8962
9020
  const { startIndex, endIndex } = this.getRange();
8963
9021
  if (!~startIndex && !~endIndex)
8964
9022
  return false;
8965
- if (startIndex === endIndex)
8966
- return true;
8967
9023
  const elementList = this.draw.getElementList();
8968
9024
  const startElement = elementList[startIndex];
9025
+ if (startIndex === endIndex) {
9026
+ return (startElement.controlComponent !== ControlComponent.PRE_TEXT || ((_a = elementList[startIndex + 1]) == null ? void 0 : _a.controlComponent) !== ControlComponent.PRE_TEXT) && startElement.controlComponent !== ControlComponent.POST_TEXT;
9027
+ }
8969
9028
  const endElement = elementList[endIndex];
8970
- return !startElement.controlId && !endElement.controlId || (!startElement.controlId || startElement.controlComponent === ControlComponent.POSTFIX) && (!endElement.controlId || endElement.controlComponent === ControlComponent.POSTFIX) || !!startElement.controlId && endElement.controlId === startElement.controlId && endElement.controlComponent !== ControlComponent.POSTFIX;
9029
+ return !startElement.controlId && !endElement.controlId || (!startElement.controlId || startElement.controlComponent === ControlComponent.POSTFIX) && (!endElement.controlId || endElement.controlComponent === ControlComponent.POSTFIX) || !!startElement.controlId && endElement.controlId === startElement.controlId && endElement.controlComponent !== ControlComponent.PRE_TEXT && endElement.controlComponent !== ControlComponent.POST_TEXT && endElement.controlComponent !== ControlComponent.POSTFIX;
8971
9030
  }
8972
9031
  setRange(startIndex, endIndex, tableId, startTdIndex, endTdIndex, startTrIndex, endTrIndex) {
8973
9032
  this.range.startIndex = startIndex;
@@ -9124,7 +9183,7 @@ class RangeManager {
9124
9183
  let index2 = startIndex - 1;
9125
9184
  while (index2 > 0) {
9126
9185
  const preElement = elementList[index2];
9127
- if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
9186
+ if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
9128
9187
  range.startIndex = index2;
9129
9188
  range.endIndex = index2;
9130
9189
  break;
@@ -9137,7 +9196,7 @@ class RangeManager {
9137
9196
  let index2 = endIndex - 1;
9138
9197
  while (index2 > 0) {
9139
9198
  const preElement = elementList[index2];
9140
- if (preElement.controlId !== endElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
9199
+ if (preElement.controlId !== endElement.controlId || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
9141
9200
  range.startIndex = index2;
9142
9201
  range.endIndex = index2;
9143
9202
  return;
@@ -10160,10 +10219,10 @@ class TableParticle {
10160
10219
  }
10161
10220
  _drawBorder(ctx, element, startX, startY) {
10162
10221
  var _a, _b, _c, _d, _e, _f;
10163
- const { colgroup, trList, borderType } = element;
10222
+ const { colgroup, trList, borderType, borderColor } = element;
10164
10223
  if (!colgroup || !trList)
10165
10224
  return;
10166
- const { scale } = this.options;
10225
+ const { scale, table: { defaultBorderColor } } = this.options;
10167
10226
  const tableWidth = element.width * scale;
10168
10227
  const tableHeight = element.height * scale;
10169
10228
  const isEmptyBorderType = borderType === TableBorder.EMPTY;
@@ -10174,6 +10233,7 @@ class TableParticle {
10174
10233
  ctx.setLineDash([3, 3]);
10175
10234
  }
10176
10235
  ctx.lineWidth = scale;
10236
+ ctx.strokeStyle = borderColor || defaultBorderColor;
10177
10237
  if (!isEmptyBorderType && !isInternalBorderType) {
10178
10238
  this._drawOuterBorder({
10179
10239
  ctx,
@@ -11293,6 +11353,8 @@ class SelectControl {
11293
11353
  __publicField(this, "isPopup");
11294
11354
  __publicField(this, "selectDom");
11295
11355
  __publicField(this, "options");
11356
+ __publicField(this, "VALUE_DELIMITER", ",");
11357
+ __publicField(this, "DEFAULT_MULTI_SELECT_DELIMITER", ",");
11296
11358
  const draw = control.getDraw();
11297
11359
  this.options = draw.getOptions();
11298
11360
  this.element = element;
@@ -11309,9 +11371,27 @@ class SelectControl {
11309
11371
  getIsPopup() {
11310
11372
  return this.isPopup;
11311
11373
  }
11312
- getCode() {
11313
- var _a;
11314
- return ((_a = this.element.control) == null ? void 0 : _a.code) || null;
11374
+ getCodes() {
11375
+ var _a, _b;
11376
+ return ((_b = (_a = this.element) == null ? void 0 : _a.control) == null ? void 0 : _b.code) ? this.element.control.code.split(",") : [];
11377
+ }
11378
+ getText(codes) {
11379
+ var _a, _b;
11380
+ if (!((_a = this.element) == null ? void 0 : _a.control))
11381
+ return null;
11382
+ const control = this.element.control;
11383
+ if (!((_b = control.valueSets) == null ? void 0 : _b.length))
11384
+ return null;
11385
+ const multiSelectDelimiter = (control == null ? void 0 : control.multiSelectDelimiter) || this.DEFAULT_MULTI_SELECT_DELIMITER;
11386
+ const valueSets = control.valueSets;
11387
+ const valueList = [];
11388
+ codes.forEach((code) => {
11389
+ const valueSet = valueSets.find((v) => v.code === code);
11390
+ if (valueSet && !isNonValue(valueSet.value)) {
11391
+ valueList.push(valueSet.value);
11392
+ }
11393
+ });
11394
+ return valueList.join(multiSelectDelimiter) || null;
11315
11395
  }
11316
11396
  getValue(context = {}) {
11317
11397
  const elementList = context.elementList || this.control.getElementList();
@@ -11321,7 +11401,7 @@ class SelectControl {
11321
11401
  let preIndex = startIndex;
11322
11402
  while (preIndex > 0) {
11323
11403
  const preElement = elementList[preIndex];
11324
- if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
11404
+ if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
11325
11405
  break;
11326
11406
  }
11327
11407
  if (preElement.controlComponent === ControlComponent.VALUE) {
@@ -11332,7 +11412,7 @@ class SelectControl {
11332
11412
  let nextIndex = startIndex + 1;
11333
11413
  while (nextIndex < elementList.length) {
11334
11414
  const nextElement = elementList[nextIndex];
11335
- if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX) {
11415
+ if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX || nextElement.controlComponent === ControlComponent.POST_TEXT) {
11336
11416
  break;
11337
11417
  }
11338
11418
  if (nextElement.controlComponent === ControlComponent.VALUE) {
@@ -11342,8 +11422,38 @@ class SelectControl {
11342
11422
  }
11343
11423
  return data2;
11344
11424
  }
11345
- setValue() {
11346
- return -1;
11425
+ setValue(data2, context = {}, options = {}) {
11426
+ var _a, _b;
11427
+ if (!((_b = (_a = this.element.control) == null ? void 0 : _a.selectExclusiveOptions) == null ? void 0 : _b.inputAble) || !options.isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
11428
+ return -1;
11429
+ }
11430
+ const elementList = context.elementList || this.control.getElementList();
11431
+ const range = context.range || this.control.getRange();
11432
+ this.control.shrinkBoundary(context);
11433
+ const { startIndex, endIndex } = range;
11434
+ const draw = this.control.getDraw();
11435
+ if (startIndex !== endIndex) {
11436
+ draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
11437
+ } else {
11438
+ this.control.removePlaceholder(startIndex, context);
11439
+ }
11440
+ const startElement = elementList[startIndex];
11441
+ const anchorElement = startElement.type && !TEXTLIKE_ELEMENT_TYPE.includes(startElement.type) || startElement.controlComponent === ControlComponent.PREFIX || startElement.controlComponent === ControlComponent.PRE_TEXT ? pickObject(startElement, [
11442
+ "control",
11443
+ "controlId",
11444
+ ...CONTROL_STYLE_ATTR
11445
+ ]) : omitObject(startElement, ["type"]);
11446
+ const start = range.startIndex + 1;
11447
+ for (let i = 0; i < data2.length; i++) {
11448
+ const newElement = __spreadProps(__spreadValues(__spreadValues({}, anchorElement), data2[i]), {
11449
+ controlComponent: ControlComponent.VALUE
11450
+ });
11451
+ formatElementContext(elementList, [newElement], startIndex, {
11452
+ editorOptions: this.options
11453
+ });
11454
+ draw.spliceElementList(elementList, start + i, 0, newElement);
11455
+ }
11456
+ return start + data2.length - 1;
11347
11457
  }
11348
11458
  keydown(evt) {
11349
11459
  if (this.control.getIsDisabledControl()) {
@@ -11359,7 +11469,7 @@ class SelectControl {
11359
11469
  if (startIndex !== endIndex) {
11360
11470
  return this.clearSelect();
11361
11471
  } else {
11362
- if (startElement.controlComponent === ControlComponent.PREFIX || endElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
11472
+ if (startElement.controlComponent === ControlComponent.PREFIX || startElement.controlComponent === ControlComponent.PRE_TEXT || endElement.controlComponent === ControlComponent.POSTFIX || endElement.controlComponent === ControlComponent.POST_TEXT || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
11363
11473
  return this.control.removeControl(startIndex);
11364
11474
  } else {
11365
11475
  return this.clearSelect();
@@ -11370,7 +11480,7 @@ class SelectControl {
11370
11480
  return this.clearSelect();
11371
11481
  } else {
11372
11482
  const endNextElement = elementList[endIndex + 1];
11373
- if (startElement.controlComponent === ControlComponent.PREFIX && endNextElement.controlComponent === ControlComponent.PLACEHOLDER || endNextElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
11483
+ if ((startElement.controlComponent === ControlComponent.PREFIX || startElement.controlComponent === ControlComponent.PRE_TEXT) && endNextElement.controlComponent === ControlComponent.PLACEHOLDER || endNextElement.controlComponent === ControlComponent.POSTFIX || endNextElement.controlComponent === ControlComponent.POST_TEXT || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
11374
11484
  return this.control.removeControl(startIndex);
11375
11485
  } else {
11376
11486
  return this.clearSelect();
@@ -11403,7 +11513,7 @@ class SelectControl {
11403
11513
  let preIndex = startIndex;
11404
11514
  while (preIndex > 0) {
11405
11515
  const preElement = elementList[preIndex];
11406
- if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
11516
+ if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
11407
11517
  leftIndex = preIndex;
11408
11518
  break;
11409
11519
  }
@@ -11412,7 +11522,7 @@ class SelectControl {
11412
11522
  let nextIndex = startIndex + 1;
11413
11523
  while (nextIndex < elementList.length) {
11414
11524
  const nextElement = elementList[nextIndex];
11415
- if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX) {
11525
+ if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX || nextElement.controlComponent === ControlComponent.POST_TEXT) {
11416
11526
  rightIndex = nextIndex - 1;
11417
11527
  break;
11418
11528
  }
@@ -11425,18 +11535,27 @@ class SelectControl {
11425
11535
  if (isAddPlaceholder) {
11426
11536
  this.control.addPlaceholder(preIndex, context);
11427
11537
  }
11428
- this.element.control.code = null;
11538
+ this.control.setControlProperties({
11539
+ code: null
11540
+ }, {
11541
+ elementList,
11542
+ range: { startIndex: preIndex, endIndex: preIndex }
11543
+ });
11429
11544
  return preIndex;
11430
11545
  }
11431
11546
  setSelect(code, context = {}, options = {}) {
11547
+ var _a;
11432
11548
  if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
11433
11549
  return;
11434
11550
  }
11435
11551
  const elementList = context.elementList || this.control.getElementList();
11436
11552
  const range = context.range || this.control.getRange();
11437
11553
  const control = this.element.control;
11554
+ const newCodes = (code == null ? void 0 : code.split(this.VALUE_DELIMITER)) || [];
11438
11555
  const oldCode = control.code;
11439
- if (code === oldCode) {
11556
+ const oldCodes = ((_a = control.code) == null ? void 0 : _a.split(this.VALUE_DELIMITER)) || [];
11557
+ const isMultiSelect = control.isMultiSelect;
11558
+ if (!isMultiSelect && code === oldCode || isMultiSelect && isArrayEqual(oldCodes, newCodes)) {
11440
11559
  this.control.repaintControl({
11441
11560
  curIndex: range.startIndex,
11442
11561
  isCompute: false,
@@ -11448,9 +11567,18 @@ class SelectControl {
11448
11567
  const valueSets = control.valueSets;
11449
11568
  if (!Array.isArray(valueSets) || !valueSets.length)
11450
11569
  return;
11451
- const valueSet = valueSets.find((v) => v.code === code);
11452
- if (!valueSet)
11570
+ const text = this.getText(newCodes);
11571
+ if (!text) {
11572
+ if (oldCode) {
11573
+ const prefixIndex2 = this.clearSelect(context);
11574
+ if (~prefixIndex2) {
11575
+ this.control.repaintControl({
11576
+ curIndex: prefixIndex2
11577
+ });
11578
+ }
11579
+ }
11453
11580
  return;
11581
+ }
11454
11582
  const valueElement = this.getValue(context)[0];
11455
11583
  const styleElement = valueElement ? pickObject(valueElement, EDITOR_ELEMENT_STYLE_ATTR) : pickObject(elementList[range.startIndex], CONTROL_STYLE_ATTR);
11456
11584
  const prefixIndex = this.clearSelect(context, {
@@ -11463,7 +11591,7 @@ class SelectControl {
11463
11591
  }
11464
11592
  const propertyElement = omitObject(elementList[prefixIndex], EDITOR_ELEMENT_STYLE_ATTR);
11465
11593
  const start = prefixIndex + 1;
11466
- const data2 = splitText(valueSet.value);
11594
+ const data2 = splitText(text);
11467
11595
  const draw = this.control.getDraw();
11468
11596
  for (let i = 0; i < data2.length; i++) {
11469
11597
  const newElement = __spreadProps(__spreadValues(__spreadValues({}, styleElement), propertyElement), {
@@ -11476,13 +11604,20 @@ class SelectControl {
11476
11604
  });
11477
11605
  draw.spliceElementList(elementList, start + i, 0, newElement);
11478
11606
  }
11479
- control.code = code;
11607
+ this.control.setControlProperties({
11608
+ code
11609
+ }, {
11610
+ elementList,
11611
+ range: { startIndex: prefixIndex, endIndex: prefixIndex }
11612
+ });
11480
11613
  if (!context.range) {
11481
11614
  const newIndex = start + data2.length - 1;
11482
11615
  this.control.repaintControl({
11483
11616
  curIndex: newIndex
11484
11617
  });
11485
- this.destroy();
11618
+ if (!isMultiSelect) {
11619
+ this.destroy();
11620
+ }
11486
11621
  }
11487
11622
  }
11488
11623
  _createSelectPopupDom() {
@@ -11500,12 +11635,26 @@ class SelectControl {
11500
11635
  for (let v = 0; v < valueSets.length; v++) {
11501
11636
  const valueSet = valueSets[v];
11502
11637
  const li = document.createElement("li");
11503
- const code = this.getCode();
11504
- if (code === valueSet.code) {
11638
+ let codes = this.getCodes();
11639
+ if (codes.includes(valueSet.code)) {
11505
11640
  li.classList.add("active");
11506
11641
  }
11507
11642
  li.onclick = () => {
11508
- this.setSelect(valueSet.code);
11643
+ const codeIndex = codes.findIndex((code) => code === valueSet.code);
11644
+ if (control.isMultiSelect) {
11645
+ if (~codeIndex) {
11646
+ codes.splice(codeIndex, 1);
11647
+ } else {
11648
+ codes.push(valueSet.code);
11649
+ }
11650
+ } else {
11651
+ if (~codeIndex) {
11652
+ codes = [];
11653
+ } else {
11654
+ codes = [valueSet.code];
11655
+ }
11656
+ }
11657
+ this.setSelect(codes.join(this.VALUE_DELIMITER));
11509
11658
  };
11510
11659
  li.append(document.createTextNode(valueSet.value));
11511
11660
  ul.append(li);
@@ -11563,7 +11712,7 @@ class TextControl {
11563
11712
  let preIndex = startIndex;
11564
11713
  while (preIndex > 0) {
11565
11714
  const preElement = elementList[preIndex];
11566
- if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
11715
+ if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
11567
11716
  break;
11568
11717
  }
11569
11718
  if (preElement.controlComponent === ControlComponent.VALUE) {
@@ -11574,7 +11723,7 @@ class TextControl {
11574
11723
  let nextIndex = startIndex + 1;
11575
11724
  while (nextIndex < elementList.length) {
11576
11725
  const nextElement = elementList[nextIndex];
11577
- if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX) {
11726
+ if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX || nextElement.controlComponent === ControlComponent.POST_TEXT) {
11578
11727
  break;
11579
11728
  }
11580
11729
  if (nextElement.controlComponent === ControlComponent.VALUE) {
@@ -11599,7 +11748,7 @@ class TextControl {
11599
11748
  this.control.removePlaceholder(startIndex, context);
11600
11749
  }
11601
11750
  const startElement = elementList[startIndex];
11602
- const anchorElement = startElement.type && !TEXTLIKE_ELEMENT_TYPE.includes(startElement.type) || startElement.controlComponent === ControlComponent.PREFIX ? pickObject(startElement, [
11751
+ const anchorElement = startElement.type && !TEXTLIKE_ELEMENT_TYPE.includes(startElement.type) || startElement.controlComponent === ControlComponent.PREFIX || startElement.controlComponent === ControlComponent.PRE_TEXT ? pickObject(startElement, [
11603
11752
  "control",
11604
11753
  "controlId",
11605
11754
  ...CONTROL_STYLE_ATTR
@@ -11650,7 +11799,7 @@ class TextControl {
11650
11799
  }
11651
11800
  return startIndex;
11652
11801
  } else {
11653
- if (startElement.controlComponent === ControlComponent.PREFIX || endElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
11802
+ if (startElement.controlComponent === ControlComponent.PREFIX || startElement.controlComponent === ControlComponent.PRE_TEXT || endElement.controlComponent === ControlComponent.POSTFIX || endElement.controlComponent === ControlComponent.POST_TEXT || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
11654
11803
  return this.control.removeControl(startIndex);
11655
11804
  } else {
11656
11805
  draw.spliceElementList(elementList, startIndex, 1);
@@ -11671,7 +11820,7 @@ class TextControl {
11671
11820
  return startIndex;
11672
11821
  } else {
11673
11822
  const endNextElement = elementList[endIndex + 1];
11674
- if (startElement.controlComponent === ControlComponent.PREFIX && endNextElement.controlComponent === ControlComponent.PLACEHOLDER || endNextElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
11823
+ if ((startElement.controlComponent === ControlComponent.PREFIX || startElement.controlComponent === ControlComponent.PRE_TEXT) && endNextElement.controlComponent === ControlComponent.PLACEHOLDER || endNextElement.controlComponent === ControlComponent.POSTFIX || endNextElement.controlComponent === ControlComponent.POST_TEXT || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
11675
11824
  return this.control.removeControl(startIndex);
11676
11825
  } else {
11677
11826
  draw.spliceElementList(elementList, startIndex + 1, 1);
@@ -12194,7 +12343,7 @@ class DateControl {
12194
12343
  let preIndex = startIndex;
12195
12344
  while (preIndex > 0) {
12196
12345
  const preElement = elementList[preIndex];
12197
- if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
12346
+ if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
12198
12347
  break;
12199
12348
  }
12200
12349
  preIndex--;
@@ -12202,7 +12351,7 @@ class DateControl {
12202
12351
  let nextIndex = startIndex + 1;
12203
12352
  while (nextIndex < elementList.length) {
12204
12353
  const nextElement = elementList[nextIndex];
12205
- if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX) {
12354
+ if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX || nextElement.controlComponent === ControlComponent.POST_TEXT) {
12206
12355
  break;
12207
12356
  }
12208
12357
  nextIndex++;
@@ -12241,7 +12390,7 @@ class DateControl {
12241
12390
  this.control.removePlaceholder(startIndex, context);
12242
12391
  }
12243
12392
  const startElement = elementList[startIndex];
12244
- const anchorElement = startElement.type && !TEXTLIKE_ELEMENT_TYPE.includes(startElement.type) || startElement.controlComponent === ControlComponent.PREFIX ? pickObject(startElement, [
12393
+ const anchorElement = startElement.type && !TEXTLIKE_ELEMENT_TYPE.includes(startElement.type) || startElement.controlComponent === ControlComponent.PREFIX || startElement.controlComponent === ControlComponent.PRE_TEXT ? pickObject(startElement, [
12245
12394
  "control",
12246
12395
  "controlId",
12247
12396
  ...CONTROL_STYLE_ATTR
@@ -12332,7 +12481,7 @@ class DateControl {
12332
12481
  }
12333
12482
  return startIndex;
12334
12483
  } else {
12335
- if (startElement.controlComponent === ControlComponent.PREFIX || endElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
12484
+ if (startElement.controlComponent === ControlComponent.PREFIX || startElement.controlComponent === ControlComponent.PRE_TEXT || endElement.controlComponent === ControlComponent.POSTFIX || endElement.controlComponent === ControlComponent.POST_TEXT || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
12336
12485
  return this.control.removeControl(startIndex);
12337
12486
  } else {
12338
12487
  draw.spliceElementList(elementList, startIndex, 1);
@@ -12353,7 +12502,7 @@ class DateControl {
12353
12502
  return startIndex;
12354
12503
  } else {
12355
12504
  const endNextElement = elementList[endIndex + 1];
12356
- if (startElement.controlComponent === ControlComponent.PREFIX && endNextElement.controlComponent === ControlComponent.PLACEHOLDER || endNextElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
12505
+ if ((startElement.controlComponent === ControlComponent.PREFIX || startElement.controlComponent === ControlComponent.PRE_TEXT) && endNextElement.controlComponent === ControlComponent.PLACEHOLDER || endNextElement.controlComponent === ControlComponent.POSTFIX || endNextElement.controlComponent === ControlComponent.POST_TEXT || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
12357
12506
  return this.control.removeControl(startIndex);
12358
12507
  } else {
12359
12508
  draw.spliceElementList(elementList, startIndex + 1, 1);
@@ -12467,8 +12616,8 @@ class Control {
12467
12616
  return this.draw;
12468
12617
  }
12469
12618
  filterAssistElement(elementList) {
12470
- return elementList.filter((element) => {
12471
- var _a;
12619
+ return elementList.filter((element, index2) => {
12620
+ var _a, _b, _c;
12472
12621
  if (element.type === ElementType.TABLE) {
12473
12622
  const trList = element.trList;
12474
12623
  for (let r = 0; r < trList.length; r++) {
@@ -12486,6 +12635,37 @@ class Control {
12486
12635
  element.value = "";
12487
12636
  return true;
12488
12637
  }
12638
+ } else {
12639
+ if (((_b = element.control) == null ? void 0 : _b.preText) && element.controlComponent === ControlComponent.PRE_TEXT) {
12640
+ let isExistValue = false;
12641
+ let start = index2 + 1;
12642
+ while (start < elementList.length) {
12643
+ const nextElement = elementList[start];
12644
+ if (element.controlId !== nextElement.controlId)
12645
+ break;
12646
+ if (nextElement.controlComponent === ControlComponent.VALUE) {
12647
+ isExistValue = true;
12648
+ break;
12649
+ }
12650
+ start++;
12651
+ }
12652
+ return isExistValue;
12653
+ }
12654
+ if (((_c = element.control) == null ? void 0 : _c.postText) && element.controlComponent === ControlComponent.POST_TEXT) {
12655
+ let isExistValue = false;
12656
+ let start = index2 - 1;
12657
+ while (start < elementList.length) {
12658
+ const preElement = elementList[start];
12659
+ if (element.controlId !== preElement.controlId)
12660
+ break;
12661
+ if (preElement.controlComponent === ControlComponent.VALUE) {
12662
+ isExistValue = true;
12663
+ break;
12664
+ }
12665
+ start--;
12666
+ }
12667
+ return isExistValue;
12668
+ }
12489
12669
  }
12490
12670
  return element.controlComponent !== ControlComponent.PREFIX && element.controlComponent !== ControlComponent.POSTFIX && element.controlComponent !== ControlComponent.PLACEHOLDER;
12491
12671
  });
@@ -12760,11 +12940,11 @@ class Control {
12760
12940
  }
12761
12941
  startIndex++;
12762
12942
  }
12763
- } else if (element.controlComponent === ControlComponent.PREFIX) {
12943
+ } else if (element.controlComponent === ControlComponent.PREFIX || element.controlComponent === ControlComponent.PRE_TEXT) {
12764
12944
  let startIndex = newIndex + 1;
12765
12945
  while (startIndex < elementList.length) {
12766
12946
  const nextElement = elementList[startIndex];
12767
- if (nextElement.controlId !== element.controlId || nextElement.controlComponent !== ControlComponent.PREFIX) {
12947
+ if (nextElement.controlId !== element.controlId || nextElement.controlComponent !== ControlComponent.PREFIX && nextElement.controlComponent !== ControlComponent.PRE_TEXT) {
12768
12948
  return {
12769
12949
  newIndex: startIndex - 1,
12770
12950
  newElement: elementList[startIndex - 1]
@@ -12772,11 +12952,11 @@ class Control {
12772
12952
  }
12773
12953
  startIndex++;
12774
12954
  }
12775
- } else if (element.controlComponent === ControlComponent.PLACEHOLDER) {
12955
+ } else if (element.controlComponent === ControlComponent.PLACEHOLDER || element.controlComponent === ControlComponent.POST_TEXT) {
12776
12956
  let startIndex = newIndex - 1;
12777
12957
  while (startIndex > 0) {
12778
12958
  const preElement = elementList[startIndex];
12779
- if (preElement.controlId !== element.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
12959
+ if (preElement.controlId !== element.controlId || preElement.controlComponent === ControlComponent.VALUE || preElement.controlComponent === ControlComponent.PREFIX || preElement.controlComponent === ControlComponent.PRE_TEXT) {
12780
12960
  return {
12781
12961
  newIndex: startIndex,
12782
12962
  newElement: elementList[startIndex]
@@ -12881,6 +13061,27 @@ class Control {
12881
13061
  }
12882
13062
  return this.activeControl.setValue(data2);
12883
13063
  }
13064
+ setControlProperties(properties, context = {}) {
13065
+ const elementList = context.elementList || this.getElementList();
13066
+ const { startIndex } = context.range || this.getRange();
13067
+ const startElement = elementList[startIndex];
13068
+ let preIndex = startIndex;
13069
+ while (preIndex > 0) {
13070
+ const preElement = elementList[preIndex];
13071
+ if (preElement.controlId !== startElement.controlId)
13072
+ break;
13073
+ preElement.control = __spreadValues(__spreadValues({}, preElement.control), properties);
13074
+ preIndex--;
13075
+ }
13076
+ let nextIndex = startIndex + 1;
13077
+ while (nextIndex < elementList.length) {
13078
+ const nextElement = elementList[nextIndex];
13079
+ if (nextElement.controlId !== startElement.controlId)
13080
+ break;
13081
+ nextElement.control = __spreadValues(__spreadValues({}, nextElement.control), properties);
13082
+ nextIndex++;
13083
+ }
13084
+ }
12884
13085
  keydown(evt) {
12885
13086
  if (!this.activeControl) {
12886
13087
  throw new Error("active control is null");
@@ -13111,7 +13312,12 @@ class Control {
13111
13312
  if (!element.control || id && element.controlId !== id || conceptId && element.control.conceptId !== conceptId || areaId && element.areaId !== areaId) {
13112
13313
  continue;
13113
13314
  }
13114
- element.control.extension = extension;
13315
+ this.setControlProperties({
13316
+ extension
13317
+ }, {
13318
+ elementList,
13319
+ range: { startIndex: i, endIndex: i }
13320
+ });
13115
13321
  let newEndIndex = i;
13116
13322
  while (newEndIndex < elementList.length) {
13117
13323
  const nextElement = elementList[newEndIndex];
@@ -13136,7 +13342,7 @@ class Control {
13136
13342
  if (!id && !conceptId)
13137
13343
  return;
13138
13344
  let isExistUpdate = false;
13139
- function setProperties(elementList) {
13345
+ const setProperties = (elementList) => {
13140
13346
  let i = 0;
13141
13347
  while (i < elementList.length) {
13142
13348
  const element = elementList[i];
@@ -13155,8 +13361,11 @@ class Control {
13155
13361
  continue;
13156
13362
  }
13157
13363
  isExistUpdate = true;
13158
- element.control = __spreadProps(__spreadValues(__spreadValues({}, element.control), properties), {
13364
+ this.setControlProperties(__spreadProps(__spreadValues(__spreadValues({}, element.control), properties), {
13159
13365
  value: element.control.value
13366
+ }), {
13367
+ elementList,
13368
+ range: { startIndex: i, endIndex: i }
13160
13369
  });
13161
13370
  CONTROL_STYLE_ATTR.forEach((key) => {
13162
13371
  const controlStyleProperty = properties[key];
@@ -13173,7 +13382,7 @@ class Control {
13173
13382
  }
13174
13383
  i = newEndIndex;
13175
13384
  }
13176
- }
13385
+ };
13177
13386
  const pageComponentData = {
13178
13387
  header: this.draw.getHeaderElementList(),
13179
13388
  main: this.draw.getOriginalMainElementList(),
@@ -13286,7 +13495,7 @@ class Control {
13286
13495
  let nextIndex = e;
13287
13496
  while (nextIndex > 0) {
13288
13497
  const nextElement = elementList2[nextIndex];
13289
- if (nextElement.controlComponent === ControlComponent.VALUE || nextElement.controlComponent === ControlComponent.PREFIX) {
13498
+ if (nextElement.controlComponent === ControlComponent.VALUE || nextElement.controlComponent === ControlComponent.PREFIX || nextElement.controlComponent === ControlComponent.PRE_TEXT) {
13290
13499
  break;
13291
13500
  }
13292
13501
  nextIndex--;
@@ -13358,6 +13567,7 @@ class Control {
13358
13567
  return null;
13359
13568
  const controlElement = this.activeControl.getElement();
13360
13569
  function getNextContext(elementList2, start) {
13570
+ var _a, _b;
13361
13571
  for (let e = start; e < elementList2.length; e++) {
13362
13572
  const element = elementList2[e];
13363
13573
  if (element.type === ElementType.TABLE) {
@@ -13385,7 +13595,7 @@ class Control {
13385
13595
  }
13386
13596
  }
13387
13597
  }
13388
- if (!element.controlId || element.controlId === controlElement.controlId) {
13598
+ if (!element.controlId || element.controlId === controlElement.controlId || ((_a = elementList2[e + 1]) == null ? void 0 : _a.controlComponent) === ControlComponent.PREFIX || ((_b = elementList2[e + 1]) == null ? void 0 : _b.controlComponent) === ControlComponent.PRE_TEXT) {
13389
13599
  continue;
13390
13600
  }
13391
13601
  return {
@@ -16105,6 +16315,23 @@ class TableOperate {
16105
16315
  curIndex: endIndex
16106
16316
  });
16107
16317
  }
16318
+ tableBorderColor(payload) {
16319
+ const positionContext = this.position.getPositionContext();
16320
+ if (!positionContext.isTable)
16321
+ return;
16322
+ const { index: index2 } = positionContext;
16323
+ const originalElementList = this.draw.getOriginalElementList();
16324
+ const element = originalElementList[index2];
16325
+ if (!element.borderColor && payload === this.options.table.defaultBorderColor || element.borderColor === payload) {
16326
+ return;
16327
+ }
16328
+ element.borderColor = payload;
16329
+ const { endIndex } = this.range.getRange();
16330
+ this.draw.render({
16331
+ curIndex: endIndex,
16332
+ isCompute: false
16333
+ });
16334
+ }
16108
16335
  tableTdBorderType(payload) {
16109
16336
  const rowCol = this.tableParticle.getRangeRowCol();
16110
16337
  if (!rowCol)
@@ -16245,7 +16472,7 @@ class Area {
16245
16472
  }
16246
16473
  isReadonly() {
16247
16474
  const activeAreaInfo = this.getActiveAreaInfo();
16248
- if (!activeAreaInfo)
16475
+ if (!(activeAreaInfo == null ? void 0 : activeAreaInfo.area))
16249
16476
  return false;
16250
16477
  switch (activeAreaInfo.area.mode) {
16251
16478
  case AreaMode.EDIT:
@@ -16293,7 +16520,7 @@ class Area {
16293
16520
  const width = this.draw.getInnerWidth();
16294
16521
  for (const areaInfoItem of this.areaInfoMap) {
16295
16522
  const { area, positionList } = areaInfoItem[1];
16296
- if (!area.backgroundColor && !area.borderColor)
16523
+ if (!(area == null ? void 0 : area.backgroundColor) && !(area == null ? void 0 : area.borderColor))
16297
16524
  continue;
16298
16525
  const pagePositionList = positionList.filter((p) => p.pageNo === pageNo);
16299
16526
  if (!pagePositionList.length)
@@ -16360,6 +16587,9 @@ class Area {
16360
16587
  const areaInfo = this.areaInfoMap.get(areaId);
16361
16588
  if (!areaInfo)
16362
16589
  return;
16590
+ if (!areaInfo.area) {
16591
+ areaInfo.area = {};
16592
+ }
16363
16593
  let isCompute = false;
16364
16594
  if (payload.properties.mode) {
16365
16595
  areaInfo.area.mode = payload.properties.mode;
@@ -17307,7 +17537,7 @@ class Draw {
17307
17537
  computeRowList(payload) {
17308
17538
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
17309
17539
  const { innerWidth, elementList, isPagingMode = false, isFromTable = false, startX = 0, startY = 0, pageHeight = 0, mainOuterHeight = 0, surroundElementList = [] } = payload;
17310
- const { defaultSize, defaultRowMargin, scale, table: { tdPadding }, defaultTabWidth } = this.options;
17540
+ const { defaultSize, defaultRowMargin, scale, table: { tdPadding, defaultTrMinHeight }, defaultTabWidth } = this.options;
17311
17541
  const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight();
17312
17542
  const canvas = document.createElement("canvas");
17313
17543
  const ctx = canvas.getContext("2d");
@@ -17390,8 +17620,12 @@ class Draw {
17390
17620
  }
17391
17621
  }
17392
17622
  element.pagingIndex = (_d = element.pagingIndex) != null ? _d : 0;
17393
- this.tableParticle.computeRowColInfo(element);
17394
17623
  const trList = element.trList;
17624
+ for (let t = 0; t < trList.length; t++) {
17625
+ const tr = trList[t];
17626
+ tr.height = tr.minHeight || defaultTrMinHeight;
17627
+ }
17628
+ this.tableParticle.computeRowColInfo(element);
17395
17629
  for (let t = 0; t < trList.length; t++) {
17396
17630
  const tr = trList[t];
17397
17631
  for (let d = 0; d < tr.tdList.length; d++) {
@@ -17411,6 +17645,11 @@ class Draw {
17411
17645
  changeTr.height += extraHeight;
17412
17646
  changeTr.tdList.forEach((changeTd) => {
17413
17647
  changeTd.height += extraHeight;
17648
+ if (!changeTd.realHeight) {
17649
+ changeTd.realHeight = changeTd.height;
17650
+ } else {
17651
+ changeTd.realHeight += extraHeight;
17652
+ }
17414
17653
  });
17415
17654
  }
17416
17655
  let curTdMinHeight = 0;
@@ -17446,6 +17685,7 @@ class Draw {
17446
17685
  changeTr.height -= reduceHeight;
17447
17686
  changeTr.tdList.forEach((changeTd) => {
17448
17687
  changeTd.height -= reduceHeight;
17688
+ changeTd.realHeight -= reduceHeight;
17449
17689
  });
17450
17690
  }
17451
17691
  }
@@ -18371,6 +18611,7 @@ class Command {
18371
18611
  __publicField(this, "executeCancelMergeTableCell");
18372
18612
  __publicField(this, "executeTableTdVerticalAlign");
18373
18613
  __publicField(this, "executeTableBorderType");
18614
+ __publicField(this, "executeTableBorderColor");
18374
18615
  __publicField(this, "executeTableTdBorderType");
18375
18616
  __publicField(this, "executeTableTdSlashType");
18376
18617
  __publicField(this, "executeTableTdBackgroundColor");
@@ -18393,6 +18634,7 @@ class Command {
18393
18634
  __publicField(this, "executeSaveAsImageElement");
18394
18635
  __publicField(this, "executeChangeImageDisplay");
18395
18636
  __publicField(this, "executePageMode");
18637
+ __publicField(this, "executePageScale");
18396
18638
  __publicField(this, "executePageScaleRecovery");
18397
18639
  __publicField(this, "executePageScaleMinus");
18398
18640
  __publicField(this, "executePageScaleAdd");
@@ -18493,6 +18735,7 @@ class Command {
18493
18735
  this.executeCancelMergeTableCell = adapt.cancelMergeTableCell.bind(adapt);
18494
18736
  this.executeTableTdVerticalAlign = adapt.tableTdVerticalAlign.bind(adapt);
18495
18737
  this.executeTableBorderType = adapt.tableBorderType.bind(adapt);
18738
+ this.executeTableBorderColor = adapt.tableBorderColor.bind(adapt);
18496
18739
  this.executeTableTdBorderType = adapt.tableTdBorderType.bind(adapt);
18497
18740
  this.executeTableTdSlashType = adapt.tableTdSlashType.bind(adapt);
18498
18741
  this.executeTableTdBackgroundColor = adapt.tableTdBackgroundColor.bind(adapt);
@@ -18515,6 +18758,7 @@ class Command {
18515
18758
  this.executeSaveAsImageElement = adapt.saveAsImageElement.bind(adapt);
18516
18759
  this.executeChangeImageDisplay = adapt.changeImageDisplay.bind(adapt);
18517
18760
  this.executePageMode = adapt.pageMode.bind(adapt);
18761
+ this.executePageScale = adapt.pageScale.bind(adapt);
18518
18762
  this.executePageScaleRecovery = adapt.pageScaleRecovery.bind(adapt);
18519
18763
  this.executePageScaleMinus = adapt.pageScaleMinus.bind(adapt);
18520
18764
  this.executePageScaleAdd = adapt.pageScaleAdd.bind(adapt);
@@ -18682,8 +18926,8 @@ class CommandAdapt {
18682
18926
  return;
18683
18927
  this.canvasEvent.cut();
18684
18928
  }
18685
- copy() {
18686
- this.canvasEvent.copy();
18929
+ copy(payload) {
18930
+ this.canvasEvent.copy(payload);
18687
18931
  }
18688
18932
  paste(payload) {
18689
18933
  const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
@@ -19425,6 +19669,12 @@ class CommandAdapt {
19425
19669
  return;
19426
19670
  this.tableOperate.tableBorderType(payload);
19427
19671
  }
19672
+ tableBorderColor(payload) {
19673
+ const isReadonly = this.draw.isReadonly();
19674
+ if (isReadonly)
19675
+ return;
19676
+ this.tableOperate.tableBorderColor(payload);
19677
+ }
19428
19678
  tableTdBorderType(payload) {
19429
19679
  const isReadonly = this.draw.isReadonly();
19430
19680
  if (isReadonly)
@@ -20051,6 +20301,11 @@ class CommandAdapt {
20051
20301
  pageMode(payload) {
20052
20302
  this.draw.setPageMode(payload);
20053
20303
  }
20304
+ pageScale(scale) {
20305
+ if (scale === this.options.scale)
20306
+ return;
20307
+ this.draw.setPageScale(scale);
20308
+ }
20054
20309
  pageScaleRecovery() {
20055
20310
  const { scale } = this.options;
20056
20311
  if (scale !== 1) {
@@ -20326,6 +20581,7 @@ class CommandAdapt {
20326
20581
  locationControl(controlId, options) {
20327
20582
  const isLocationAfter = (options == null ? void 0 : options.position) === LocationPosition.AFTER;
20328
20583
  function location(elementList, zone2) {
20584
+ var _a, _b;
20329
20585
  let i = 0;
20330
20586
  while (i < elementList.length) {
20331
20587
  const element = elementList[i];
@@ -20358,7 +20614,11 @@ class CommandAdapt {
20358
20614
  let curIndex = i - 1;
20359
20615
  if (isLocationAfter) {
20360
20616
  curIndex -= 1;
20361
- if (element.controlComponent !== ControlComponent.PLACEHOLDER && element.controlComponent !== ControlComponent.POSTFIX) {
20617
+ if (element.controlComponent !== ControlComponent.PLACEHOLDER && element.controlComponent !== ControlComponent.POSTFIX && element.controlComponent !== ControlComponent.POST_TEXT) {
20618
+ continue;
20619
+ }
20620
+ } else {
20621
+ if (element.controlComponent !== ControlComponent.PREFIX && element.controlComponent !== ControlComponent.PRE_TEXT || ((_a = elementList[i]) == null ? void 0 : _a.controlComponent) === ControlComponent.PREFIX || ((_b = elementList[i]) == null ? void 0 : _b.controlComponent) === ControlComponent.PRE_TEXT) {
20362
20622
  continue;
20363
20623
  }
20364
20624
  }
@@ -20417,7 +20677,8 @@ class CommandAdapt {
20417
20677
  const cloneAttr = [
20418
20678
  ...TABLE_CONTEXT_ATTR,
20419
20679
  ...EDITOR_ROW_ATTR,
20420
- ...LIST_CONTEXT_ATTR
20680
+ ...LIST_CONTEXT_ATTR,
20681
+ ...AREA_CONTEXT_ATTR
20421
20682
  ];
20422
20683
  cloneProperty(cloneAttr, copyElement, cloneElement);
20423
20684
  this.draw.insertElementList([cloneElement]);
@@ -20543,7 +20804,8 @@ class CommandAdapt {
20543
20804
  const cloneAttr = [
20544
20805
  ...TABLE_CONTEXT_ATTR,
20545
20806
  ...EDITOR_ROW_ATTR,
20546
- ...LIST_CONTEXT_ATTR
20807
+ ...LIST_CONTEXT_ATTR,
20808
+ ...AREA_CONTEXT_ATTR
20547
20809
  ];
20548
20810
  (_a = cloneElement.valueList) == null ? void 0 : _a.forEach((valueItem) => {
20549
20811
  cloneProperty(cloneAttr, copyElement, valueItem);