@hufe921/canvas-editor 0.9.62 → 0.9.64

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,36 @@
1
+ ## [0.9.64](https://github.com/Hufe921/canvas-editor/compare/v0.9.63...v0.9.64) (2024-01-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * error inserting image within control #422 ([ea4ac33](https://github.com/Hufe921/canvas-editor/commit/ea4ac339c7de962845f639a1c5ac24d8e3640485)), closes [#422](https://github.com/Hufe921/canvas-editor/issues/422)
7
+ * render error when row element is empty #420 ([8999f28](https://github.com/Hufe921/canvas-editor/commit/8999f283bb87d92fe58b1aa8330bf4d9d75b9064)), closes [#420](https://github.com/Hufe921/canvas-editor/issues/420)
8
+ * zone tip position error in firefox browser #423 ([3cf911c](https://github.com/Hufe921/canvas-editor/commit/3cf911c501a0c0af85d994d5b50c657c6cd77692)), closes [#423](https://github.com/Hufe921/canvas-editor/issues/423)
9
+
10
+
11
+ ### Features
12
+
13
+ * add executeSetControlProperties api #391 ([3ffb6b9](https://github.com/Hufe921/canvas-editor/commit/3ffb6b94b57a0d0fe81cc778a26d4e2a234e24ab)), closes [#391](https://github.com/Hufe921/canvas-editor/issues/391)
14
+ * copy and paste original elements #397 (#426) ([2fc16de](https://github.com/Hufe921/canvas-editor/commit/2fc16de4e15578cdd181c4186b4cf978924b5207)), closes [#397](https://github.com/Hufe921/canvas-editor/issues/397) [#426](https://github.com/Hufe921/canvas-editor/issues/426)
15
+
16
+
17
+
18
+ ## [0.9.63](https://github.com/Hufe921/canvas-editor/compare/v0.9.62...v0.9.63) (2024-01-19)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * copy row properties on input #415 ([55a43e6](https://github.com/Hufe921/canvas-editor/commit/55a43e61bf6aded9f50644e86d3a1c276ee7a53a)), closes [#415](https://github.com/Hufe921/canvas-editor/issues/415)
24
+ * format list element boundary error ([094af57](https://github.com/Hufe921/canvas-editor/commit/094af57302a7db0c83cb3dd8a5eb9bbe5581b8f8))
25
+ * image render error within the control #406 ([d175f92](https://github.com/Hufe921/canvas-editor/commit/d175f920e8887cc3b1f5132e8ac7443b0d556204)), closes [#406](https://github.com/Hufe921/canvas-editor/issues/406)
26
+
27
+
28
+ ### Features
29
+
30
+ * keep aspect ratio when drag image #414 ([e8684da](https://github.com/Hufe921/canvas-editor/commit/e8684daffd40a8efda0342809846451afa0027a2)), closes [#414](https://github.com/Hufe921/canvas-editor/issues/414)
31
+
32
+
33
+
1
34
  ## [0.9.62](https://github.com/Hufe921/canvas-editor/compare/v0.9.61...v0.9.62) (2024-01-12)
2
35
 
3
36
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.62";
26
+ const version = "0.9.64";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -327,6 +327,7 @@ const defaultCursorOption = {
327
327
  };
328
328
  const EDITOR_COMPONENT = "editor-component";
329
329
  const EDITOR_PREFIX = "ce";
330
+ const EDITOR_CLIPBOARD = `${EDITOR_PREFIX}-clipboard`;
330
331
  var MoveDirection;
331
332
  (function(MoveDirection2) {
332
333
  MoveDirection2["UP"] = "top";
@@ -363,6 +364,7 @@ const EDITOR_ELEMENT_STYLE_ATTR = [
363
364
  "underline",
364
365
  "strikeout"
365
366
  ];
367
+ const EDITOR_ROW_ATTR = ["rowFlex", "rowMargin"];
366
368
  const EDITOR_ELEMENT_COPY_ATTR = [
367
369
  "type",
368
370
  "font",
@@ -378,7 +380,9 @@ const EDITOR_ELEMENT_COPY_ATTR = [
378
380
  "hyperlinkId",
379
381
  "dateId",
380
382
  "dateFormat",
381
- "groupIds"
383
+ "groupIds",
384
+ "rowFlex",
385
+ "rowMargin"
382
386
  ];
383
387
  const EDITOR_ELEMENT_ZIP_ATTR = [
384
388
  "type",
@@ -3668,7 +3672,9 @@ function formatElementList(elementList, options) {
3668
3672
  } else if (el.type === ElementType.LIST) {
3669
3673
  elementList.splice(i, 1);
3670
3674
  const valueList = el.valueList || [];
3671
- formatElementList(valueList, __spreadValues({}, options));
3675
+ formatElementList(valueList, __spreadProps(__spreadValues({}, options), {
3676
+ isHandleFirstElement: true
3677
+ }));
3672
3678
  if (valueList.length) {
3673
3679
  const listId = getUUID();
3674
3680
  for (let v = 0; v < valueList.length; v++) {
@@ -3742,6 +3748,10 @@ function formatElementList(elementList, options) {
3742
3748
  }
3743
3749
  i--;
3744
3750
  } else if (el.type === ElementType.CONTROL) {
3751
+ if (!el.control) {
3752
+ i++;
3753
+ continue;
3754
+ }
3745
3755
  const { prefix, postfix, value, placeholder, code, type, valueSets } = el.control;
3746
3756
  const { editorOptions: { control: controlOption, checkbox: checkboxOption } } = options;
3747
3757
  const controlId = getUUID();
@@ -3812,20 +3822,20 @@ function formatElementList(elementList, options) {
3812
3822
  }
3813
3823
  }
3814
3824
  }
3825
+ formatElementList(valueList, __spreadProps(__spreadValues({}, options), {
3826
+ isHandleFirstElement: false
3827
+ }));
3815
3828
  for (let v = 0; v < valueList.length; v++) {
3816
3829
  const element = valueList[v];
3817
- const valueStrList = splitText(element.value);
3818
- for (let e = 0; e < valueStrList.length; e++) {
3819
- const value2 = valueStrList[e];
3820
- elementList.splice(i, 0, __spreadProps(__spreadValues({}, element), {
3821
- controlId,
3822
- value: value2 === "\n" ? ZERO : value2,
3823
- type: element.type || ElementType.TEXT,
3824
- control: el.control,
3825
- controlComponent: ControlComponent.VALUE
3826
- }));
3827
- i++;
3828
- }
3830
+ const value2 = element.value;
3831
+ elementList.splice(i, 0, __spreadProps(__spreadValues({}, element), {
3832
+ controlId,
3833
+ value: value2 === "\n" ? ZERO : value2,
3834
+ type: element.type || ElementType.TEXT,
3835
+ control: el.control,
3836
+ controlComponent: ControlComponent.VALUE
3837
+ }));
3838
+ i++;
3829
3839
  }
3830
3840
  }
3831
3841
  } else if (placeholder) {
@@ -4544,35 +4554,81 @@ ${listIndex + 1}.${buildText(listElementList)}${isLast ? `
4544
4554
  }
4545
4555
  return buildText(zipElementList(elementList));
4546
4556
  }
4547
- function pastHTML(host, htmlText) {
4557
+ function setClipboardData(data2) {
4558
+ localStorage.setItem(EDITOR_CLIPBOARD, JSON.stringify({
4559
+ text: data2.text,
4560
+ elementList: data2.elementList
4561
+ }));
4562
+ }
4563
+ function getClipboardData() {
4564
+ const clipboardText = localStorage.getItem(EDITOR_CLIPBOARD);
4565
+ return clipboardText ? JSON.parse(clipboardText) : null;
4566
+ }
4567
+ function removeClipboardData() {
4568
+ localStorage.removeItem(EDITOR_CLIPBOARD);
4569
+ }
4570
+ function writeClipboardItem(text, html, elementList) {
4571
+ if (!text && !html && !elementList.length)
4572
+ return;
4573
+ const plainText = new Blob([text], { type: "text/plain" });
4574
+ const htmlText = new Blob([html], { type: "text/html" });
4575
+ if (window.ClipboardItem) {
4576
+ const item = new ClipboardItem({
4577
+ [plainText.type]: plainText,
4578
+ [htmlText.type]: htmlText
4579
+ });
4580
+ window.navigator.clipboard.write([item]);
4581
+ } else {
4582
+ const fakeElement = document.createElement("div");
4583
+ fakeElement.setAttribute("contenteditable", "true");
4584
+ fakeElement.innerHTML = html;
4585
+ document.body.append(fakeElement);
4586
+ const selection = window.getSelection();
4587
+ const range = document.createRange();
4588
+ range.selectNodeContents(fakeElement);
4589
+ selection == null ? void 0 : selection.removeAllRanges();
4590
+ selection == null ? void 0 : selection.addRange(range);
4591
+ document.execCommand("copy");
4592
+ fakeElement.remove();
4593
+ }
4594
+ setClipboardData({ text, elementList });
4595
+ }
4596
+ function writeElementList(elementList, options) {
4597
+ const clipboardDom = createDomFromElementList(elementList, options);
4598
+ document.body.append(clipboardDom);
4599
+ const text = clipboardDom.innerText;
4600
+ clipboardDom.remove();
4601
+ const html = clipboardDom.innerHTML;
4602
+ if (!text && !html && !elementList.length)
4603
+ return;
4604
+ writeClipboardItem(text, html, zipElementList(elementList));
4605
+ }
4606
+ function pasteElement(host, elementList) {
4548
4607
  const draw = host.getDraw();
4549
4608
  const isReadonly = draw.isReadonly();
4550
4609
  if (isReadonly)
4551
4610
  return;
4552
4611
  const rangeManager = draw.getRange();
4553
4612
  const { startIndex } = rangeManager.getRange();
4554
- const elementList = draw.getElementList();
4555
- const pasteElementList = getElementListByHTML(htmlText, {
4556
- innerWidth: draw.getOriginalInnerWidth()
4557
- });
4613
+ const originalElementList = draw.getElementList();
4558
4614
  if (~startIndex && !rangeManager.getIsSelectAll()) {
4559
- const anchorElement = elementList[startIndex];
4615
+ const anchorElement = originalElementList[startIndex];
4560
4616
  if ((anchorElement == null ? void 0 : anchorElement.titleId) || (anchorElement == null ? void 0 : anchorElement.listId)) {
4561
4617
  let start = 0;
4562
- while (start < pasteElementList.length) {
4563
- const pasteElement = pasteElementList[start];
4564
- if (anchorElement.titleId && /^\n/.test(pasteElement.value)) {
4618
+ while (start < elementList.length) {
4619
+ const pasteElement2 = elementList[start];
4620
+ if (anchorElement.titleId && /^\n/.test(pasteElement2.value)) {
4565
4621
  break;
4566
4622
  }
4567
- if (VIRTUAL_ELEMENT_TYPE.includes(pasteElement.type)) {
4568
- pasteElementList.splice(start, 1);
4569
- if (pasteElement.valueList) {
4570
- for (let v = 0; v < pasteElement.valueList.length; v++) {
4571
- const element = pasteElement.valueList[v];
4623
+ if (VIRTUAL_ELEMENT_TYPE.includes(pasteElement2.type)) {
4624
+ elementList.splice(start, 1);
4625
+ if (pasteElement2.valueList) {
4626
+ for (let v = 0; v < pasteElement2.valueList.length; v++) {
4627
+ const element = pasteElement2.valueList[v];
4572
4628
  if (element.value === ZERO || element.value === "\n") {
4573
4629
  continue;
4574
4630
  }
4575
- pasteElementList.splice(start, 0, element);
4631
+ elementList.splice(start, 0, element);
4576
4632
  start++;
4577
4633
  }
4578
4634
  }
@@ -4581,11 +4637,21 @@ function pastHTML(host, htmlText) {
4581
4637
  start++;
4582
4638
  }
4583
4639
  }
4584
- formatElementContext(elementList, pasteElementList, startIndex, {
4640
+ formatElementContext(originalElementList, elementList, startIndex, {
4585
4641
  isBreakWhenWrap: true
4586
4642
  });
4587
4643
  }
4588
- draw.insertElementList(pasteElementList);
4644
+ draw.insertElementList(elementList);
4645
+ }
4646
+ function pasteHTML(host, htmlText) {
4647
+ const draw = host.getDraw();
4648
+ const isReadonly = draw.isReadonly();
4649
+ if (isReadonly)
4650
+ return;
4651
+ const elementList = getElementListByHTML(htmlText, {
4652
+ innerWidth: draw.getOriginalInnerWidth()
4653
+ });
4654
+ pasteElement(host, elementList);
4589
4655
  }
4590
4656
  function pasteImage(host, file) {
4591
4657
  const draw = host.getDraw();
@@ -4628,6 +4694,13 @@ function pasteByEvent(host, evt) {
4628
4694
  paste(evt);
4629
4695
  return;
4630
4696
  }
4697
+ const clipboardText = clipboardData.getData("text");
4698
+ const editorClipboardData = getClipboardData();
4699
+ if (clipboardText === (editorClipboardData == null ? void 0 : editorClipboardData.text)) {
4700
+ pasteElement(host, editorClipboardData.elementList);
4701
+ return;
4702
+ }
4703
+ removeClipboardData();
4631
4704
  let isHTML = false;
4632
4705
  for (let i = 0; i < clipboardData.items.length; i++) {
4633
4706
  const item = clipboardData.items[i];
@@ -4647,7 +4720,7 @@ function pasteByEvent(host, evt) {
4647
4720
  }
4648
4721
  if (item.type === "text/html" && isHTML) {
4649
4722
  item.getAsString((htmlText) => {
4650
- pastHTML(host, htmlText);
4723
+ pasteHTML(host, htmlText);
4651
4724
  });
4652
4725
  break;
4653
4726
  }
@@ -4696,7 +4769,7 @@ async function pasteByApi(host, options) {
4696
4769
  const htmlTextBlob = await item.getType("text/html");
4697
4770
  const htmlText = await htmlTextBlob.text();
4698
4771
  if (htmlText) {
4699
- pastHTML(host, htmlText);
4772
+ pasteHTML(host, htmlText);
4700
4773
  }
4701
4774
  } else if (item.types.some((type) => type.startsWith("image/"))) {
4702
4775
  const type = item.types.find((type2) => type2.startsWith("image/"));
@@ -5467,7 +5540,8 @@ function enter(evt, host) {
5467
5540
  }
5468
5541
  const copyElement = getAnchorElement(elementList, endIndex);
5469
5542
  if (copyElement) {
5470
- EDITOR_ELEMENT_STYLE_ATTR.forEach((attr) => {
5543
+ const copyAttr = [...EDITOR_ELEMENT_STYLE_ATTR, ...EDITOR_ROW_ATTR];
5544
+ copyAttr.forEach((attr) => {
5471
5545
  const value = copyElement[attr];
5472
5546
  if (value !== void 0) {
5473
5547
  enterText[attr] = value;
@@ -5895,41 +5969,6 @@ function removeComposingInput(host) {
5895
5969
  rangeManager.setRange(startIndex, startIndex);
5896
5970
  host.compositionInfo = null;
5897
5971
  }
5898
- function writeClipboardItem(text, html) {
5899
- if (!text || !html)
5900
- return;
5901
- const plainText = new Blob([text], { type: "text/plain" });
5902
- const htmlText = new Blob([html], { type: "text/html" });
5903
- if (window.ClipboardItem) {
5904
- const item = new ClipboardItem({
5905
- [plainText.type]: plainText,
5906
- [htmlText.type]: htmlText
5907
- });
5908
- window.navigator.clipboard.write([item]);
5909
- } else {
5910
- const fakeElement = document.createElement("div");
5911
- fakeElement.setAttribute("contenteditable", "true");
5912
- fakeElement.innerHTML = html;
5913
- document.body.append(fakeElement);
5914
- const selection = window.getSelection();
5915
- const range = document.createRange();
5916
- range.selectNodeContents(fakeElement);
5917
- selection == null ? void 0 : selection.removeAllRanges();
5918
- selection == null ? void 0 : selection.addRange(range);
5919
- document.execCommand("copy");
5920
- fakeElement.remove();
5921
- }
5922
- }
5923
- function writeElementList(elementList, options) {
5924
- const clipboardDom = createDomFromElementList(elementList, options);
5925
- document.body.append(clipboardDom);
5926
- const text = clipboardDom.innerText;
5927
- clipboardDom.remove();
5928
- const html = clipboardDom.innerHTML;
5929
- if (!text || !html)
5930
- return;
5931
- writeClipboardItem(text, html);
5932
- }
5933
5972
  function cut(host) {
5934
5973
  const draw = host.getDraw();
5935
5974
  const rangeManager = draw.getRange();
@@ -6632,6 +6671,7 @@ class Position {
6632
6671
  return { x, y, index: index2 };
6633
6672
  }
6634
6673
  computePositionList() {
6674
+ var _a;
6635
6675
  this.positionList = [];
6636
6676
  const innerWidth = this.draw.getInnerWidth();
6637
6677
  const pageRowList = this.draw.getPageRowList();
@@ -6643,7 +6683,7 @@ class Position {
6643
6683
  let startRowIndex = 0;
6644
6684
  for (let i = 0; i < pageRowList.length; i++) {
6645
6685
  const rowList = pageRowList[i];
6646
- const startIndex = rowList[0].startIndex;
6686
+ const startIndex = (_a = rowList[0]) == null ? void 0 : _a.startIndex;
6647
6687
  this.computePageRowPosition({
6648
6688
  positionList: this.positionList,
6649
6689
  rowList,
@@ -9594,6 +9634,17 @@ class Control {
9594
9634
  }
9595
9635
  return false;
9596
9636
  }
9637
+ isRangeCanInput() {
9638
+ const { startIndex, endIndex } = this.getRange();
9639
+ if (!~startIndex && !~endIndex)
9640
+ return false;
9641
+ if (startIndex === endIndex)
9642
+ return true;
9643
+ const elementList = this.getElementList();
9644
+ const startElement = elementList[startIndex];
9645
+ const endElement = elementList[endIndex];
9646
+ return !startElement.controlId && !endElement.controlId || (!startElement.controlId || startElement.controlComponent === ControlComponent.POSTFIX) && endElement.controlComponent === ControlComponent.POSTFIX || !!startElement.controlId && endElement.controlId === startElement.controlId && endElement.controlComponent !== ControlComponent.POSTFIX;
9647
+ }
9597
9648
  isDisabledControl() {
9598
9649
  var _a, _b;
9599
9650
  return !!((_b = (_a = this.activeControl) == null ? void 0 : _a.getElement().control) == null ? void 0 : _b.disabled);
@@ -10060,6 +10111,55 @@ class Control {
10060
10111
  setExtension(elementList);
10061
10112
  }
10062
10113
  }
10114
+ setPropertiesByConceptId(payload) {
10115
+ var _a;
10116
+ const isReadonly = this.draw.isReadonly();
10117
+ if (isReadonly)
10118
+ return;
10119
+ const { conceptId, properties } = payload;
10120
+ let isExistUpdate = false;
10121
+ const pageComponentData = {
10122
+ header: this.draw.getHeaderElementList(),
10123
+ main: this.draw.getOriginalMainElementList(),
10124
+ footer: this.draw.getFooterElementList()
10125
+ };
10126
+ for (const key in pageComponentData) {
10127
+ const elementList = pageComponentData[key];
10128
+ let i = 0;
10129
+ while (i < elementList.length) {
10130
+ const element = elementList[i];
10131
+ i++;
10132
+ if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
10133
+ continue;
10134
+ isExistUpdate = true;
10135
+ element.control = __spreadProps(__spreadValues(__spreadValues({}, element.control), properties), {
10136
+ value: element.control.value
10137
+ });
10138
+ let newEndIndex = i;
10139
+ while (newEndIndex < elementList.length) {
10140
+ const nextElement = elementList[newEndIndex];
10141
+ if (nextElement.controlId !== element.controlId)
10142
+ break;
10143
+ newEndIndex++;
10144
+ }
10145
+ i = newEndIndex;
10146
+ }
10147
+ }
10148
+ if (!isExistUpdate)
10149
+ return;
10150
+ for (const key in pageComponentData) {
10151
+ const pageComponentKey = key;
10152
+ const elementList = zipElementList(pageComponentData[pageComponentKey]);
10153
+ pageComponentData[pageComponentKey] = elementList;
10154
+ formatElementList(elementList, {
10155
+ editorOptions: this.options
10156
+ });
10157
+ }
10158
+ this.draw.setEditorData(pageComponentData);
10159
+ this.draw.render({
10160
+ isSetCursor: false
10161
+ });
10162
+ }
10063
10163
  }
10064
10164
  class CheckboxParticle {
10065
10165
  constructor(draw) {
@@ -10330,15 +10430,31 @@ class Previewer {
10330
10430
  let dy = 0;
10331
10431
  switch (this.curHandleIndex) {
10332
10432
  case 0:
10333
- dx = this.mousedownX - evt.x;
10334
- dy = this.mousedownY - evt.y;
10433
+ {
10434
+ const offsetX = this.mousedownX - evt.x;
10435
+ const offsetY = this.mousedownY - evt.y;
10436
+ dx = Math.cbrt(offsetX ** 3 + offsetY ** 3);
10437
+ dy = this.curElement.height * dx / this.curElement.width;
10438
+ }
10335
10439
  break;
10336
10440
  case 1:
10337
10441
  dy = this.mousedownY - evt.y;
10338
10442
  break;
10339
10443
  case 2:
10340
- dx = evt.x - this.mousedownX;
10341
- dy = this.mousedownY - evt.y;
10444
+ {
10445
+ const offsetX = evt.x - this.mousedownX;
10446
+ const offsetY = this.mousedownY - evt.y;
10447
+ dx = Math.cbrt(offsetX ** 3 + offsetY ** 3);
10448
+ dy = this.curElement.height * dx / this.curElement.width;
10449
+ }
10450
+ break;
10451
+ case 4:
10452
+ {
10453
+ const offsetX = evt.x - this.mousedownX;
10454
+ const offsetY = evt.y - this.mousedownY;
10455
+ dx = Math.cbrt(offsetX ** 3 + offsetY ** 3);
10456
+ dy = this.curElement.height * dx / this.curElement.width;
10457
+ }
10342
10458
  break;
10343
10459
  case 3:
10344
10460
  dx = evt.x - this.mousedownX;
@@ -10347,16 +10463,16 @@ class Previewer {
10347
10463
  dy = evt.y - this.mousedownY;
10348
10464
  break;
10349
10465
  case 6:
10350
- dx = this.mousedownX - evt.x;
10351
- dy = evt.y - this.mousedownY;
10466
+ {
10467
+ const offsetX = this.mousedownX - evt.x;
10468
+ const offsetY = evt.y - this.mousedownY;
10469
+ dx = Math.cbrt(offsetX ** 3 + offsetY ** 3);
10470
+ dy = this.curElement.height * dx / this.curElement.width;
10471
+ }
10352
10472
  break;
10353
10473
  case 7:
10354
10474
  dx = this.mousedownX - evt.x;
10355
10475
  break;
10356
- default:
10357
- dx = evt.x - this.mousedownX;
10358
- dy = evt.y - this.mousedownY;
10359
- break;
10360
10476
  }
10361
10477
  const dw = this.curElement.width + dx / scale;
10362
10478
  const dh = this.curElement.height + dy / scale;
@@ -11497,6 +11613,8 @@ class ZoneTip {
11497
11613
  this.pageContainer.addEventListener("mousemove", throttle((evt) => {
11498
11614
  if (this.isDisableMouseMove)
11499
11615
  return;
11616
+ if (!evt.offsetY)
11617
+ return;
11500
11618
  if (evt.target instanceof HTMLCanvasElement) {
11501
11619
  const mousemoveZone = this.zone.getZoneByY(evt.offsetY);
11502
11620
  if (!watchZones.includes(mousemoveZone)) {
@@ -12542,8 +12660,8 @@ class Draw {
12542
12660
  insertElementList(payload) {
12543
12661
  if (!payload.length)
12544
12662
  return;
12545
- const isPartRangeInControlOutside = this.control.isPartRangeInControlOutside();
12546
- if (isPartRangeInControlOutside)
12663
+ const isRangeCanInput = this.control.isRangeCanInput();
12664
+ if (!isRangeCanInput)
12547
12665
  return;
12548
12666
  const { startIndex, endIndex } = this.range.getRange();
12549
12667
  if (!~startIndex && !~endIndex)
@@ -12553,7 +12671,11 @@ class Draw {
12553
12671
  editorOptions: this.options
12554
12672
  });
12555
12673
  let curIndex = -1;
12556
- const activeControl = this.control.getActiveControl();
12674
+ let activeControl = this.control.getActiveControl();
12675
+ if (!activeControl && this.control.isRangeWithinControl()) {
12676
+ this.control.initControl();
12677
+ activeControl = this.control.getActiveControl();
12678
+ }
12557
12679
  if (activeControl && !this.control.isRangInPostfix()) {
12558
12680
  curIndex = activeControl.setValue(payload, void 0, {
12559
12681
  isIgnoreDisabledRule: true
@@ -12960,7 +13082,7 @@ class Draw {
12960
13082
  return `${el.italic ? "italic " : ""}${el.bold ? "bold " : ""}${size * scale}px ${font}`;
12961
13083
  }
12962
13084
  computeRowList(innerWidth, elementList) {
12963
- var _a, _b, _c, _d, _e, _f;
13085
+ var _a, _b, _c, _d, _e, _f, _g, _h;
12964
13086
  const { defaultSize, defaultRowMargin, scale, tdPadding, defaultTabWidth } = this.options;
12965
13087
  const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight();
12966
13088
  const canvas = document.createElement("canvas");
@@ -12974,7 +13096,7 @@ class Draw {
12974
13096
  ascent: 0,
12975
13097
  elementList: [],
12976
13098
  startIndex: 0,
12977
- rowFlex: (_a = elementList == null ? void 0 : elementList[1]) == null ? void 0 : _a.rowFlex
13099
+ rowFlex: ((_a = elementList == null ? void 0 : elementList[0]) == null ? void 0 : _a.rowFlex) || ((_b = elementList == null ? void 0 : elementList[1]) == null ? void 0 : _b.rowFlex)
12978
13100
  });
12979
13101
  }
12980
13102
  let listId;
@@ -13083,7 +13205,7 @@ class Draw {
13083
13205
  let curPagePreHeight = marginHeight;
13084
13206
  for (let r = 0; r < rowList.length; r++) {
13085
13207
  const row = rowList[r];
13086
- if (row.height + curPagePreHeight > height2 || ((_b = rowList[r - 1]) == null ? void 0 : _b.isPageBreak)) {
13208
+ if (row.height + curPagePreHeight > height2 || ((_c = rowList[r - 1]) == null ? void 0 : _c.isPageBreak)) {
13087
13209
  curPagePreHeight = marginHeight + row.height;
13088
13210
  } else {
13089
13211
  curPagePreHeight += row.height;
@@ -13100,7 +13222,7 @@ class Draw {
13100
13222
  const tr = trList2[r];
13101
13223
  const trHeight = tr.height * scale;
13102
13224
  if (curPagePreHeight + rowMarginHeight + preTrHeight + trHeight > height2) {
13103
- if (((_c = element.colgroup) == null ? void 0 : _c.length) !== tr.tdList.length) {
13225
+ if (((_d = element.colgroup) == null ? void 0 : _d.length) !== tr.tdList.length) {
13104
13226
  deleteCount = 0;
13105
13227
  }
13106
13228
  break;
@@ -13186,7 +13308,7 @@ class Draw {
13186
13308
  metrics,
13187
13309
  style: this._getFont(element, scale)
13188
13310
  });
13189
- if ((_d = rowElement.control) == null ? void 0 : _d.minWidth) {
13311
+ if ((_e = rowElement.control) == null ? void 0 : _e.minWidth) {
13190
13312
  if (rowElement.controlComponent) {
13191
13313
  controlRealWidth += metrics.width;
13192
13314
  }
@@ -13243,10 +13365,10 @@ class Draw {
13243
13365
  startIndex: i,
13244
13366
  elementList: [rowElement],
13245
13367
  ascent,
13246
- rowFlex: (_e = elementList[i + 1]) == null ? void 0 : _e.rowFlex,
13368
+ rowFlex: ((_f = elementList[i]) == null ? void 0 : _f.rowFlex) || ((_g = elementList[i + 1]) == null ? void 0 : _g.rowFlex),
13247
13369
  isPageBreak: element.type === ElementType.PAGE_BREAK
13248
13370
  };
13249
- if (rowElement.controlComponent !== ControlComponent.PREFIX && ((_f = rowElement.control) == null ? void 0 : _f.indentation) === ControlIndentation.VALUE_START) {
13371
+ if (rowElement.controlComponent !== ControlComponent.PREFIX && ((_h = rowElement.control) == null ? void 0 : _h.indentation) === ControlIndentation.VALUE_START) {
13250
13372
  const preStartIndex = curRow.elementList.findIndex((el) => el.controlId === rowElement.controlId && el.controlComponent !== ControlComponent.PREFIX);
13251
13373
  if (~preStartIndex) {
13252
13374
  const preRowPositionList = this.position.computeRowPosition({
@@ -13495,7 +13617,7 @@ class Draw {
13495
13617
  this.blockParticle.clear();
13496
13618
  }
13497
13619
  _drawPage(payload) {
13498
- var _a;
13620
+ var _a, _b;
13499
13621
  const { elementList, positionList, rowList, pageNo } = payload;
13500
13622
  const { inactiveAlpha, pageMode, header, footer, pageNumber } = this.options;
13501
13623
  const innerWidth = this.getInnerWidth();
@@ -13507,7 +13629,7 @@ class Draw {
13507
13629
  this.margin.render(ctx, pageNo);
13508
13630
  }
13509
13631
  this.control.renderHighlightList(ctx, pageNo);
13510
- const index2 = rowList[0].startIndex;
13632
+ const index2 = (_a = rowList[0]) == null ? void 0 : _a.startIndex;
13511
13633
  this.drawRow(ctx, {
13512
13634
  elementList,
13513
13635
  positionList,
@@ -13534,7 +13656,7 @@ class Draw {
13534
13656
  if (pageMode !== PageMode.CONTINUITY && this.options.watermark.data) {
13535
13657
  this.waterMark.render(ctx);
13536
13658
  }
13537
- if (this.elementList.length <= 1 && !((_a = this.elementList[0]) == null ? void 0 : _a.listId)) {
13659
+ if (this.elementList.length <= 1 && !((_b = this.elementList[0]) == null ? void 0 : _b.listId)) {
13538
13660
  this.placeholder.render(ctx);
13539
13661
  }
13540
13662
  }
@@ -13778,6 +13900,7 @@ class Command {
13778
13900
  __publicField(this, "executeSetZone");
13779
13901
  __publicField(this, "executeSetControlValue");
13780
13902
  __publicField(this, "executeSetControlExtension");
13903
+ __publicField(this, "executeSetControlProperties");
13781
13904
  __publicField(this, "executeSetControlHighlight");
13782
13905
  __publicField(this, "getCatalog");
13783
13906
  __publicField(this, "getImage");
@@ -13900,6 +14023,7 @@ class Command {
13900
14023
  this.getContainer = adapt.getContainer.bind(adapt);
13901
14024
  this.executeSetControlValue = adapt.setControlValue.bind(adapt);
13902
14025
  this.executeSetControlExtension = adapt.setControlExtension.bind(adapt);
14026
+ this.executeSetControlProperties = adapt.setControlProperties.bind(adapt);
13903
14027
  this.executeSetControlHighlight = adapt.setControlHighlight.bind(adapt);
13904
14028
  this.getControlValue = adapt.getControlValue.bind(adapt);
13905
14029
  }
@@ -15451,26 +15575,19 @@ class CommandAdapt {
15451
15575
  const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
15452
15576
  if (isDisabled)
15453
15577
  return;
15454
- const activeControl = this.control.getActiveControl();
15455
- if (activeControl)
15456
- return;
15457
15578
  const { startIndex, endIndex } = this.range.getRange();
15458
15579
  if (!~startIndex && !~endIndex)
15459
15580
  return;
15460
- const elementList = this.draw.getElementList();
15461
15581
  const { value, width, height } = payload;
15462
- const element = {
15463
- value,
15464
- width,
15465
- height,
15466
- id: getUUID(),
15467
- type: ElementType.IMAGE
15468
- };
15469
- const curIndex = startIndex + 1;
15470
- formatElementContext(elementList, [element], startIndex);
15471
- this.draw.spliceElementList(elementList, curIndex, startIndex === endIndex ? 0 : endIndex - startIndex, element);
15472
- this.range.setRange(curIndex, curIndex);
15473
- this.draw.render({ curIndex });
15582
+ this.draw.insertElementList([
15583
+ {
15584
+ value,
15585
+ width,
15586
+ height,
15587
+ id: getUUID(),
15588
+ type: ElementType.IMAGE
15589
+ }
15590
+ ]);
15474
15591
  }
15475
15592
  search(payload) {
15476
15593
  this.searchManager.setSearchKeyword(payload);
@@ -15953,6 +16070,12 @@ class CommandAdapt {
15953
16070
  return;
15954
16071
  this.draw.getControl().setExtensionByConceptId(payload);
15955
16072
  }
16073
+ setControlProperties(payload) {
16074
+ const isReadonly = this.draw.isReadonly();
16075
+ if (isReadonly)
16076
+ return;
16077
+ this.draw.getControl().setPropertiesByConceptId(payload);
16078
+ }
15956
16079
  setControlHighlight(payload) {
15957
16080
  this.draw.getControl().setHighlightList(payload);
15958
16081
  }