@hufe921/canvas-editor 0.9.60 → 0.9.61

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,21 @@
1
+ ## [0.9.61](https://github.com/Hufe921/canvas-editor/compare/v0.9.60...v0.9.61) (2023-12-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * checkbox cannot be selected #382 ([3fb8435](https://github.com/Hufe921/canvas-editor/commit/3fb843570680d1607834b47c5ad86781ea4f5f14)), closes [#382](https://github.com/Hufe921/canvas-editor/issues/382)
7
+ * double-click to expand selection boundary error ([0bd4c5c](https://github.com/Hufe921/canvas-editor/commit/0bd4c5cc51eb400e985d77911c37fd02bf574f07))
8
+ * elements in the table cannot be selected #378 ([1477bd0](https://github.com/Hufe921/canvas-editor/commit/1477bd0e3f2685753ec66f868d5664ce5c4c85c2)), closes [#378](https://github.com/Hufe921/canvas-editor/issues/378)
9
+ * line break error before separator element #379 ([bdb981d](https://github.com/Hufe921/canvas-editor/commit/bdb981d242821d80d3d45f8569badaaa6f3a8a1d)), closes [#379](https://github.com/Hufe921/canvas-editor/issues/379)
10
+ * three click selection paragraph boundary error ([56ea7d8](https://github.com/Hufe921/canvas-editor/commit/56ea7d8bb13d6f57e24e15550a81f6e2c947f653))
11
+
12
+
13
+ ### Features
14
+
15
+ * enter to delete list #376 ([f542739](https://github.com/Hufe921/canvas-editor/commit/f542739d3eb1be273e1f77c3a908dab329f8c619)), closes [#376](https://github.com/Hufe921/canvas-editor/issues/376)
16
+
17
+
18
+
1
19
  ## [0.9.60](https://github.com/Hufe921/canvas-editor/compare/v0.9.59...v0.9.60) (2023-12-23)
2
20
 
3
21
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.60";
26
+ const version = "0.9.61";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -4111,12 +4111,14 @@ function formatElementContext(sourceElementList, formatElementList2, anchorIndex
4111
4111
  if (!copyElement)
4112
4112
  return;
4113
4113
  const { isBreakWhenWrap = false } = options || {};
4114
+ let isBreakWarped = false;
4114
4115
  for (let e = 0; e < formatElementList2.length; e++) {
4115
4116
  const targetElement = formatElementList2[e];
4116
4117
  if (isBreakWhenWrap && !copyElement.listId && /^\n/.test(targetElement.value)) {
4117
- break;
4118
+ isBreakWarped = true;
4118
4119
  }
4119
- if (!copyElement.listId && targetElement.type === ElementType.LIST) {
4120
+ if (isBreakWarped || !copyElement.listId && targetElement.type === ElementType.LIST) {
4121
+ cloneProperty(TABLE_CONTEXT_ATTR, copyElement, targetElement);
4120
4122
  (_a = targetElement.valueList) == null ? void 0 : _a.forEach((valueItem) => {
4121
4123
  cloneProperty(TABLE_CONTEXT_ATTR, copyElement, valueItem);
4122
4124
  });
@@ -5133,18 +5135,22 @@ function mousedown(evt, host) {
5133
5135
  const isSetCheckbox = isDirectHitCheckbox && !isReadonly;
5134
5136
  if (isSetCheckbox) {
5135
5137
  const { checkbox, control } = curElement;
5136
- const codes = ((_a = control == null ? void 0 : control.code) == null ? void 0 : _a.split(",")) || [];
5137
- if (checkbox == null ? void 0 : checkbox.value) {
5138
- const codeIndex = codes.findIndex((c) => c === checkbox.code);
5139
- codes.splice(codeIndex, 1);
5138
+ if (!control) {
5139
+ draw.getCheckboxParticle().setSelect(curElement);
5140
5140
  } else {
5141
- if (checkbox == null ? void 0 : checkbox.code) {
5142
- codes.push(checkbox.code);
5141
+ const codes = ((_a = control == null ? void 0 : control.code) == null ? void 0 : _a.split(",")) || [];
5142
+ if (checkbox == null ? void 0 : checkbox.value) {
5143
+ const codeIndex = codes.findIndex((c) => c === checkbox.code);
5144
+ codes.splice(codeIndex, 1);
5145
+ } else {
5146
+ if (checkbox == null ? void 0 : checkbox.code) {
5147
+ codes.push(checkbox.code);
5148
+ }
5149
+ }
5150
+ const activeControl = draw.getControl().getActiveControl();
5151
+ if (activeControl instanceof CheckboxControl) {
5152
+ activeControl.setSelect(codes);
5143
5153
  }
5144
- }
5145
- const activeControl = draw.getControl().getActiveControl();
5146
- if (activeControl instanceof CheckboxControl) {
5147
- activeControl.setSelect(codes);
5148
5154
  }
5149
5155
  } else {
5150
5156
  draw.render({
@@ -5388,8 +5394,102 @@ function mousemove(evt, host) {
5388
5394
  isCompute: false
5389
5395
  });
5390
5396
  }
5397
+ var EditorComponent;
5398
+ (function(EditorComponent2) {
5399
+ EditorComponent2["COMPONENT"] = "component";
5400
+ EditorComponent2["MENU"] = "menu";
5401
+ EditorComponent2["MAIN"] = "main";
5402
+ EditorComponent2["FOOTER"] = "footer";
5403
+ EditorComponent2["CONTEXTMENU"] = "contextmenu";
5404
+ EditorComponent2["POPUP"] = "popup";
5405
+ EditorComponent2["CATALOG"] = "catalog";
5406
+ EditorComponent2["COMMENT"] = "comment";
5407
+ })(EditorComponent || (EditorComponent = {}));
5408
+ var EditorContext;
5409
+ (function(EditorContext2) {
5410
+ EditorContext2["PAGE"] = "page";
5411
+ EditorContext2["TABLE"] = "table";
5412
+ })(EditorContext || (EditorContext = {}));
5413
+ var EditorMode;
5414
+ (function(EditorMode2) {
5415
+ EditorMode2["EDIT"] = "edit";
5416
+ EditorMode2["CLEAN"] = "clean";
5417
+ EditorMode2["READONLY"] = "readonly";
5418
+ EditorMode2["FORM"] = "form";
5419
+ EditorMode2["PRINT"] = "print";
5420
+ })(EditorMode || (EditorMode = {}));
5421
+ var EditorZone;
5422
+ (function(EditorZone2) {
5423
+ EditorZone2["HEADER"] = "header";
5424
+ EditorZone2["MAIN"] = "main";
5425
+ EditorZone2["FOOTER"] = "footer";
5426
+ })(EditorZone || (EditorZone = {}));
5427
+ var PageMode;
5428
+ (function(PageMode2) {
5429
+ PageMode2["PAGING"] = "paging";
5430
+ PageMode2["CONTINUITY"] = "continuity";
5431
+ })(PageMode || (PageMode = {}));
5432
+ var PaperDirection;
5433
+ (function(PaperDirection2) {
5434
+ PaperDirection2["VERTICAL"] = "vertical";
5435
+ PaperDirection2["HORIZONTAL"] = "horizontal";
5436
+ })(PaperDirection || (PaperDirection = {}));
5437
+ var WordBreak;
5438
+ (function(WordBreak2) {
5439
+ WordBreak2["BREAK_ALL"] = "break-all";
5440
+ WordBreak2["BREAK_WORD"] = "break-word";
5441
+ })(WordBreak || (WordBreak = {}));
5442
+ function enter(evt, host) {
5443
+ var _a, _b;
5444
+ const draw = host.getDraw();
5445
+ const isReadonly = draw.isReadonly();
5446
+ const control = draw.getControl();
5447
+ if (isReadonly || control.isPartRangeInControlOutside())
5448
+ return;
5449
+ const rangeManager = draw.getRange();
5450
+ const { startIndex, endIndex } = rangeManager.getRange();
5451
+ const isCollapsed = rangeManager.getIsCollapsed();
5452
+ const elementList = draw.getElementList();
5453
+ const startElement = elementList[startIndex];
5454
+ const endElement = elementList[endIndex];
5455
+ if (isCollapsed && endElement.listId && endElement.value === ZERO && ((_a = elementList[endIndex + 1]) == null ? void 0 : _a.listId) !== endElement.listId) {
5456
+ draw.getListParticle().unsetList();
5457
+ return;
5458
+ }
5459
+ const enterText = {
5460
+ value: ZERO
5461
+ };
5462
+ if (evt.shiftKey && startElement.listId) {
5463
+ enterText.listWrap = true;
5464
+ }
5465
+ if (!(endElement.titleId && endElement.titleId !== ((_b = elementList[endIndex + 1]) == null ? void 0 : _b.titleId))) {
5466
+ formatElementContext(elementList, [enterText], startIndex);
5467
+ }
5468
+ const activeControl = control.getActiveControl();
5469
+ let curIndex;
5470
+ if (activeControl && !control.isRangInPostfix()) {
5471
+ curIndex = control.setValue([enterText]);
5472
+ } else {
5473
+ const position = draw.getPosition();
5474
+ const cursorPosition = position.getCursorPosition();
5475
+ if (!cursorPosition)
5476
+ return;
5477
+ const { index: index2 } = cursorPosition;
5478
+ if (isCollapsed) {
5479
+ draw.spliceElementList(elementList, index2 + 1, 0, enterText);
5480
+ } else {
5481
+ draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex, enterText);
5482
+ }
5483
+ curIndex = index2 + 1;
5484
+ }
5485
+ if (~curIndex) {
5486
+ rangeManager.setRange(curIndex, curIndex);
5487
+ draw.render({ curIndex });
5488
+ }
5489
+ evt.preventDefault();
5490
+ }
5391
5491
  function keydown(evt, host) {
5392
- var _a, _b, _c, _d;
5492
+ var _a, _b, _c;
5393
5493
  if (host.isComposing)
5394
5494
  return;
5395
5495
  const draw = host.getDraw();
@@ -5461,35 +5561,7 @@ function keydown(evt, host) {
5461
5561
  rangeManager.setRange(curIndex, curIndex);
5462
5562
  draw.render({ curIndex });
5463
5563
  } else if (evt.key === KeyMap.Enter) {
5464
- if (isReadonly || control.isPartRangeInControlOutside())
5465
- return;
5466
- const enterText = {
5467
- value: ZERO
5468
- };
5469
- const startElement = elementList[startIndex];
5470
- const endElement = elementList[endIndex];
5471
- if (evt.shiftKey && startElement.listId) {
5472
- enterText.listWrap = true;
5473
- }
5474
- if (!(endElement.titleId && endElement.titleId !== ((_b = elementList[endIndex + 1]) == null ? void 0 : _b.titleId))) {
5475
- formatElementContext(elementList, [enterText], startIndex);
5476
- }
5477
- let curIndex;
5478
- if (activeControl && !control.isRangInPostfix()) {
5479
- curIndex = control.setValue([enterText]);
5480
- } else {
5481
- if (isCollapsed) {
5482
- draw.spliceElementList(elementList, index2 + 1, 0, enterText);
5483
- } else {
5484
- draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex, enterText);
5485
- }
5486
- curIndex = index2 + 1;
5487
- }
5488
- if (~curIndex) {
5489
- rangeManager.setRange(curIndex, curIndex);
5490
- draw.render({ curIndex });
5491
- }
5492
- evt.preventDefault();
5564
+ enter(evt, host);
5493
5565
  } else if (evt.key === KeyMap.Left) {
5494
5566
  if (isReadonly)
5495
5567
  return;
@@ -5499,7 +5571,7 @@ function keydown(evt, host) {
5499
5571
  if (isMod(evt)) {
5500
5572
  const LETTER_REG = draw.getLetterReg();
5501
5573
  const moveStartIndex = evt.shiftKey && !isCollapsed && startIndex === (cursorPosition2 == null ? void 0 : cursorPosition2.index) ? endIndex : startIndex;
5502
- if (LETTER_REG.test((_c = elementList[moveStartIndex]) == null ? void 0 : _c.value)) {
5574
+ if (LETTER_REG.test((_b = elementList[moveStartIndex]) == null ? void 0 : _b.value)) {
5503
5575
  let i = moveStartIndex - 1;
5504
5576
  while (i > 0) {
5505
5577
  const element = elementList[i];
@@ -5548,7 +5620,7 @@ function keydown(evt, host) {
5548
5620
  if (isMod(evt)) {
5549
5621
  const LETTER_REG = draw.getLetterReg();
5550
5622
  const moveStartIndex = evt.shiftKey && !isCollapsed && startIndex === (cursorPosition2 == null ? void 0 : cursorPosition2.index) ? endIndex : startIndex;
5551
- if (LETTER_REG.test((_d = elementList[moveStartIndex + 1]) == null ? void 0 : _d.value)) {
5623
+ if (LETTER_REG.test((_c = elementList[moveStartIndex + 1]) == null ? void 0 : _c.value)) {
5552
5624
  let i = moveStartIndex + 2;
5553
5625
  while (i < elementList.length) {
5554
5626
  const element = elementList[i];
@@ -5962,8 +6034,11 @@ function dblclick(host, evt) {
5962
6034
  }
5963
6035
  }
5964
6036
  }
6037
+ const startIndex = index2 - upCount - 1;
6038
+ if (startIndex < 0)
6039
+ return;
5965
6040
  const rangeManager = draw.getRange();
5966
- rangeManager.setRange(index2 - upCount - 1, index2 + downCount);
6041
+ rangeManager.setRange(startIndex, index2 + downCount);
5967
6042
  draw.render({
5968
6043
  isSubmitHistory: false,
5969
6044
  isSetCursor: false,
@@ -5972,6 +6047,7 @@ function dblclick(host, evt) {
5972
6047
  rangeManager.setRangeStyle();
5973
6048
  }
5974
6049
  function threeClick(host) {
6050
+ var _a, _b;
5975
6051
  const draw = host.getDraw();
5976
6052
  const position = draw.getPosition();
5977
6053
  const cursorPosition = position.getCursorPosition();
@@ -5983,26 +6059,36 @@ function threeClick(host) {
5983
6059
  let downCount = 0;
5984
6060
  let upStartIndex = index2 - 1;
5985
6061
  while (upStartIndex > 0) {
5986
- const value = elementList[upStartIndex].value;
5987
- if (value !== ZERO) {
5988
- upCount++;
5989
- upStartIndex--;
5990
- } else {
6062
+ const element = elementList[upStartIndex];
6063
+ const preElement = elementList[upStartIndex - 1];
6064
+ if (element.value === ZERO && !element.listWrap || element.listId !== (preElement == null ? void 0 : preElement.listId) || element.titleId !== (preElement == null ? void 0 : preElement.titleId)) {
5991
6065
  break;
5992
6066
  }
6067
+ upCount++;
6068
+ upStartIndex--;
5993
6069
  }
5994
6070
  let downStartIndex = index2 + 1;
5995
6071
  while (downStartIndex < elementList.length) {
5996
- const value = elementList[downStartIndex].value;
5997
- if (value !== ZERO) {
5998
- downCount++;
5999
- downStartIndex++;
6000
- } else {
6072
+ const element = elementList[downStartIndex];
6073
+ const nextElement = elementList[downStartIndex + 1];
6074
+ if (element.value === ZERO && !element.listWrap || element.listId !== (nextElement == null ? void 0 : nextElement.listId) || element.titleId !== (nextElement == null ? void 0 : nextElement.titleId)) {
6001
6075
  break;
6002
6076
  }
6077
+ downCount++;
6078
+ downStartIndex++;
6003
6079
  }
6004
6080
  const rangeManager = draw.getRange();
6005
- rangeManager.setRange(index2 - upCount - 1, index2 + downCount);
6081
+ let newStartIndex = index2 - upCount - 1;
6082
+ if (((_a = elementList[newStartIndex]) == null ? void 0 : _a.value) !== ZERO) {
6083
+ newStartIndex -= 1;
6084
+ }
6085
+ if (newStartIndex < 0)
6086
+ return;
6087
+ let newEndIndex = index2 + downCount + 1;
6088
+ if (((_b = elementList[newEndIndex]) == null ? void 0 : _b.value) === ZERO) {
6089
+ newEndIndex -= 1;
6090
+ }
6091
+ rangeManager.setRange(newStartIndex, newEndIndex);
6006
6092
  draw.render({
6007
6093
  isSubmitHistory: false,
6008
6094
  isSetCursor: false,
@@ -6384,51 +6470,6 @@ class HistoryManager {
6384
6470
  this.redoStack = [];
6385
6471
  }
6386
6472
  }
6387
- var EditorComponent;
6388
- (function(EditorComponent2) {
6389
- EditorComponent2["COMPONENT"] = "component";
6390
- EditorComponent2["MENU"] = "menu";
6391
- EditorComponent2["MAIN"] = "main";
6392
- EditorComponent2["FOOTER"] = "footer";
6393
- EditorComponent2["CONTEXTMENU"] = "contextmenu";
6394
- EditorComponent2["POPUP"] = "popup";
6395
- EditorComponent2["CATALOG"] = "catalog";
6396
- EditorComponent2["COMMENT"] = "comment";
6397
- })(EditorComponent || (EditorComponent = {}));
6398
- var EditorContext;
6399
- (function(EditorContext2) {
6400
- EditorContext2["PAGE"] = "page";
6401
- EditorContext2["TABLE"] = "table";
6402
- })(EditorContext || (EditorContext = {}));
6403
- var EditorMode;
6404
- (function(EditorMode2) {
6405
- EditorMode2["EDIT"] = "edit";
6406
- EditorMode2["CLEAN"] = "clean";
6407
- EditorMode2["READONLY"] = "readonly";
6408
- EditorMode2["FORM"] = "form";
6409
- EditorMode2["PRINT"] = "print";
6410
- })(EditorMode || (EditorMode = {}));
6411
- var EditorZone;
6412
- (function(EditorZone2) {
6413
- EditorZone2["HEADER"] = "header";
6414
- EditorZone2["MAIN"] = "main";
6415
- EditorZone2["FOOTER"] = "footer";
6416
- })(EditorZone || (EditorZone = {}));
6417
- var PageMode;
6418
- (function(PageMode2) {
6419
- PageMode2["PAGING"] = "paging";
6420
- PageMode2["CONTINUITY"] = "continuity";
6421
- })(PageMode || (PageMode = {}));
6422
- var PaperDirection;
6423
- (function(PaperDirection2) {
6424
- PaperDirection2["VERTICAL"] = "vertical";
6425
- PaperDirection2["HORIZONTAL"] = "horizontal";
6426
- })(PaperDirection || (PaperDirection = {}));
6427
- var WordBreak;
6428
- (function(WordBreak2) {
6429
- WordBreak2["BREAK_ALL"] = "break-all";
6430
- WordBreak2["BREAK_WORD"] = "break-word";
6431
- })(WordBreak || (WordBreak = {}));
6432
6473
  class Position {
6433
6474
  constructor(draw) {
6434
6475
  __publicField(this, "cursorPosition");
@@ -6939,7 +6980,6 @@ class RangeManager {
6939
6980
  return rowElementList;
6940
6981
  }
6941
6982
  getRangeParagraph() {
6942
- var _a, _b, _c;
6943
6983
  const { startIndex, endIndex } = this.range;
6944
6984
  if (!~startIndex && !~endIndex)
6945
6985
  return null;
@@ -6957,7 +6997,9 @@ class RangeManager {
6957
6997
  if (!rowArray.includes(rowNo)) {
6958
6998
  rowArray.unshift(rowNo);
6959
6999
  }
6960
- if (((_a = positionList[start]) == null ? void 0 : _a.value) === ZERO || elementList[start].titleId !== ((_b = elementList[start - 1]) == null ? void 0 : _b.titleId)) {
7000
+ const element = elementList[start];
7001
+ const preElement = elementList[start - 1];
7002
+ if (element.value === ZERO && !element.listWrap || element.listId !== (preElement == null ? void 0 : preElement.listId) || element.titleId !== (preElement == null ? void 0 : preElement.titleId)) {
6961
7003
  break;
6962
7004
  }
6963
7005
  start--;
@@ -6979,7 +7021,9 @@ class RangeManager {
6979
7021
  }
6980
7022
  let end = endIndex;
6981
7023
  while (end < positionList.length) {
6982
- if (positionList[end].value === ZERO || elementList[end].titleId !== ((_c = elementList[end + 1]) == null ? void 0 : _c.titleId)) {
7024
+ const element = elementList[end];
7025
+ const nextElement = elementList[end + 1];
7026
+ if (element.value === ZERO && !element.listWrap || element.listId !== (nextElement == null ? void 0 : nextElement.listId) || element.titleId !== (nextElement == null ? void 0 : nextElement.titleId)) {
6983
7027
  break;
6984
7028
  }
6985
7029
  const { pageNo, rowNo } = positionList[end];
@@ -7019,12 +7063,15 @@ class RangeManager {
7019
7063
  getIsSelectAll() {
7020
7064
  const elementList = this.draw.getElementList();
7021
7065
  const { startIndex, endIndex } = this.range;
7022
- return startIndex === 0 && elementList.length - 1 === endIndex;
7066
+ return startIndex === 0 && elementList.length - 1 === endIndex && !this.position.getPositionContext().isTable;
7023
7067
  }
7024
7068
  getIsPointInRange(x, y) {
7025
7069
  const { startIndex, endIndex } = this.range;
7026
7070
  const positionList = this.position.getPositionList();
7027
7071
  for (let p = startIndex + 1; p <= endIndex; p++) {
7072
+ const position = positionList[p];
7073
+ if (!position)
7074
+ break;
7028
7075
  const { coordinate: { leftTop, rightBottom } } = positionList[p];
7029
7076
  if (x >= leftTop[0] && x <= rightBottom[0] && y >= leftTop[1] && y <= rightBottom[1]) {
7030
7077
  return true;
@@ -9909,9 +9956,25 @@ class Control {
9909
9956
  }
9910
9957
  class CheckboxParticle {
9911
9958
  constructor(draw) {
9959
+ __publicField(this, "draw");
9912
9960
  __publicField(this, "options");
9961
+ this.draw = draw;
9913
9962
  this.options = draw.getOptions();
9914
9963
  }
9964
+ setSelect(element) {
9965
+ const { checkbox } = element;
9966
+ if (checkbox) {
9967
+ checkbox.value = !checkbox.value;
9968
+ } else {
9969
+ element.checkbox = {
9970
+ value: true
9971
+ };
9972
+ }
9973
+ this.draw.render({
9974
+ isCompute: false,
9975
+ isSetCursor: false
9976
+ });
9977
+ }
9915
9978
  render(ctx, element, x, y) {
9916
9979
  const { checkbox: { gap, lineWidth, fillStyle, fontStyle }, scale } = this.options;
9917
9980
  const { metrics, checkbox } = element;
@@ -11590,12 +11653,79 @@ class Footer {
11590
11653
  }
11591
11654
  class ListParticle {
11592
11655
  constructor(draw) {
11656
+ __publicField(this, "draw");
11657
+ __publicField(this, "range");
11593
11658
  __publicField(this, "options");
11594
11659
  __publicField(this, "UN_COUNT_STYLE_WIDTH", 20);
11595
11660
  __publicField(this, "MEASURE_BASE_TEXT", "0");
11596
11661
  __publicField(this, "LIST_GAP", 10);
11662
+ this.draw = draw;
11663
+ this.range = draw.getRange();
11597
11664
  this.options = draw.getOptions();
11598
11665
  }
11666
+ setList(listType, listStyle) {
11667
+ const isReadonly = this.draw.isReadonly();
11668
+ if (isReadonly)
11669
+ return;
11670
+ const { startIndex, endIndex } = this.range.getRange();
11671
+ if (!~startIndex && !~endIndex)
11672
+ return;
11673
+ const changeElementList = this.range.getRangeParagraphElementList();
11674
+ if (!changeElementList || !changeElementList.length)
11675
+ return;
11676
+ const isUnsetList = changeElementList.find((el) => el.listType === listType && el.listStyle === listStyle);
11677
+ if (isUnsetList || !listType) {
11678
+ this.unsetList();
11679
+ return;
11680
+ }
11681
+ const listId = getUUID();
11682
+ changeElementList.forEach((el) => {
11683
+ el.listId = listId;
11684
+ el.listType = listType;
11685
+ el.listStyle = listStyle;
11686
+ });
11687
+ const isSetCursor = startIndex === endIndex;
11688
+ const curIndex = isSetCursor ? endIndex : startIndex;
11689
+ this.draw.render({ curIndex, isSetCursor });
11690
+ }
11691
+ unsetList() {
11692
+ var _a;
11693
+ const isReadonly = this.draw.isReadonly();
11694
+ if (isReadonly)
11695
+ return;
11696
+ const { startIndex, endIndex } = this.range.getRange();
11697
+ if (!~startIndex && !~endIndex)
11698
+ return;
11699
+ const changeElementList = (_a = this.range.getRangeParagraphElementList()) == null ? void 0 : _a.filter((el) => el.listId);
11700
+ if (!changeElementList || !changeElementList.length)
11701
+ return;
11702
+ const elementList = this.draw.getElementList();
11703
+ const endElement = elementList[endIndex];
11704
+ if (endElement.listId) {
11705
+ let start = endIndex + 1;
11706
+ while (start < elementList.length) {
11707
+ const element = elementList[start];
11708
+ if (element.value === ZERO && !element.listWrap)
11709
+ break;
11710
+ if (element.listId !== endElement.listId) {
11711
+ this.draw.spliceElementList(elementList, start, 0, {
11712
+ value: ZERO
11713
+ });
11714
+ break;
11715
+ }
11716
+ start++;
11717
+ }
11718
+ }
11719
+ changeElementList.forEach((el) => {
11720
+ delete el.listId;
11721
+ delete el.listType;
11722
+ delete el.listStyle;
11723
+ delete el.listWrap;
11724
+ });
11725
+ const isSetCursor = startIndex === endIndex;
11726
+ const curIndex = isSetCursor ? endIndex : startIndex;
11727
+ this.draw.render({ curIndex, isSetCursor });
11728
+ }
11599
11729
  computeListStyle(ctx, elementList) {
11600
11730
  const listStyleMap = new Map();
11601
11731
  let start = 0;
@@ -12406,6 +12536,9 @@ class Draw {
12406
12536
  getListParticle() {
12407
12537
  return this.listParticle;
12408
12538
  }
12539
+ getCheckboxParticle() {
12540
+ return this.checkboxParticle;
12541
+ }
12409
12542
  getControl() {
12410
12543
  return this.control;
12411
12544
  }
@@ -12965,7 +13098,7 @@ class Draw {
12965
13098
  }
12966
13099
  }
12967
13100
  listId = element.listId;
12968
- if (element.type === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.BLOCK || element.type === ElementType.BLOCK || (preElement == null ? void 0 : preElement.imgDisplay) === ImageDisplay.INLINE || element.imgDisplay === ImageDisplay.INLINE || curRowWidth > availableWidth || i !== 0 && element.value === ZERO || (preElement == null ? void 0 : preElement.listId) !== element.listId) {
13101
+ if (element.type === ElementType.SEPARATOR || element.type === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.BLOCK || element.type === ElementType.BLOCK || (preElement == null ? void 0 : preElement.imgDisplay) === ImageDisplay.INLINE || element.imgDisplay === ImageDisplay.INLINE || curRowWidth > availableWidth || i !== 0 && element.value === ZERO || (preElement == null ? void 0 : preElement.listId) !== element.listId) {
12969
13102
  if (curRow.startIndex === 0 && curRow.elementList.length === 1 && INLINE_ELEMENT_TYPE.includes(element.type)) {
12970
13103
  curRow.height = defaultBasicRowMarginHeight;
12971
13104
  }
@@ -14115,30 +14248,7 @@ class CommandAdapt {
14115
14248
  const isReadonly = this.draw.isReadonly();
14116
14249
  if (isReadonly)
14117
14250
  return;
14118
- const { startIndex, endIndex } = this.range.getRange();
14119
- if (!~startIndex && !~endIndex)
14120
- return;
14121
- const changeElementList = this.range.getRangeParagraphElementList();
14122
- if (!changeElementList || !changeElementList.length)
14123
- return;
14124
- const isUnsetList = changeElementList.find((el) => el.listType === listType && el.listStyle === listStyle);
14125
- const listId = getUUID();
14126
- changeElementList.forEach((el) => {
14127
- if (!isUnsetList && listType) {
14128
- el.listId = listId;
14129
- el.listType = listType;
14130
- el.listStyle = listStyle;
14131
- } else {
14132
- if (el.listId) {
14133
- delete el.listId;
14134
- delete el.listType;
14135
- delete el.listStyle;
14136
- }
14137
- }
14138
- });
14139
- const isSetCursor = startIndex === endIndex;
14140
- const curIndex = isSetCursor ? endIndex : startIndex;
14141
- this.draw.render({ curIndex, isSetCursor });
14251
+ this.draw.getListParticle().setList(listType, listStyle);
14142
14252
  }
14143
14253
  rowFlex(payload) {
14144
14254
  const isReadonly = this.draw.isReadonly();