@hufe921/canvas-editor 0.9.76 → 0.9.78

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.
Files changed (27) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/canvas-editor.es.js +418 -270
  3. package/dist/canvas-editor.es.js.map +1 -1
  4. package/dist/canvas-editor.umd.js +31 -31
  5. package/dist/canvas-editor.umd.js.map +1 -1
  6. package/dist/src/editor/core/command/Command.d.ts +1 -0
  7. package/dist/src/editor/core/command/CommandAdapt.d.ts +2 -1
  8. package/dist/src/editor/core/draw/Draw.d.ts +2 -0
  9. package/dist/src/editor/core/draw/control/Control.d.ts +3 -2
  10. package/dist/src/editor/core/draw/control/checkbox/CheckboxControl.d.ts +1 -0
  11. package/dist/src/editor/core/draw/control/select/SelectControl.d.ts +2 -0
  12. package/dist/src/editor/core/draw/control/text/TextControl.d.ts +1 -0
  13. package/dist/src/editor/core/draw/particle/previewer/Previewer.d.ts +1 -0
  14. package/dist/src/editor/core/history/HistoryManager.d.ts +1 -0
  15. package/dist/src/editor/dataset/constant/Element.d.ts +1 -0
  16. package/dist/src/editor/dataset/constant/Table.d.ts +2 -0
  17. package/dist/src/editor/interface/Control.d.ts +4 -0
  18. package/dist/src/editor/interface/Editor.d.ts +3 -4
  19. package/dist/src/editor/interface/Element.d.ts +1 -0
  20. package/dist/src/editor/interface/Position.d.ts +2 -0
  21. package/dist/src/editor/interface/Range.d.ts +3 -0
  22. package/dist/src/editor/interface/contextmenu/ContextMenu.d.ts +3 -0
  23. package/dist/src/editor/interface/table/Table.d.ts +6 -0
  24. package/dist/src/editor/interface/table/Tr.d.ts +1 -0
  25. package/dist/src/editor/utils/element.d.ts +1 -0
  26. package/dist/src/editor/utils/option.d.ts +3 -0
  27. package/package.json +1 -1
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.76";
26
+ const version = "0.9.78";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -509,6 +509,10 @@ const TEXTLIKE_ELEMENT_TYPE = [
509
509
  ElementType.CONTROL,
510
510
  ElementType.DATE
511
511
  ];
512
+ const IMAGE_ELEMENT_TYPE = [
513
+ ElementType.IMAGE,
514
+ ElementType.LATEX
515
+ ];
512
516
  const INLINE_ELEMENT_TYPE = [
513
517
  ElementType.BLOCK,
514
518
  ElementType.PAGE_BREAK,
@@ -3812,12 +3816,13 @@ function formatElementList(elementList, options) {
3812
3816
  const tableId = getUUID();
3813
3817
  el.id = tableId;
3814
3818
  if (el.trList) {
3819
+ const { defaultTrMinHeight } = editorOptions.table;
3815
3820
  for (let t = 0; t < el.trList.length; t++) {
3816
3821
  const tr = el.trList[t];
3817
3822
  const trId = getUUID();
3818
3823
  tr.id = trId;
3819
- if (!tr.minHeight || tr.minHeight < editorOptions.defaultTrMinHeight) {
3820
- tr.minHeight = editorOptions.defaultTrMinHeight;
3824
+ if (!tr.minHeight || tr.minHeight < defaultTrMinHeight) {
3825
+ tr.minHeight = defaultTrMinHeight;
3821
3826
  }
3822
3827
  if (tr.height < tr.minHeight) {
3823
3828
  tr.height = tr.minHeight;
@@ -4815,6 +4820,9 @@ function getSlimCloneElementList(elementList) {
4815
4820
  "style"
4816
4821
  ]);
4817
4822
  }
4823
+ function getIsInlineElement(element) {
4824
+ return !!(element == null ? void 0 : element.type) && (INLINE_ELEMENT_TYPE.includes(element.type) || element.imgDisplay === ImageDisplay.INLINE);
4825
+ }
4818
4826
  function setClipboardData(data2) {
4819
4827
  localStorage.setItem(EDITOR_CLIPBOARD, JSON.stringify({
4820
4828
  text: data2.text,
@@ -5352,6 +5360,9 @@ class CheckboxControl {
5352
5360
  this.element = element;
5353
5361
  this.control = control;
5354
5362
  }
5363
+ setElement(element) {
5364
+ this.element = element;
5365
+ }
5355
5366
  getElement() {
5356
5367
  return this.element;
5357
5368
  }
@@ -6354,11 +6365,11 @@ function tab(evt, host) {
6354
6365
  }
6355
6366
  function getNextPositionIndex(payload) {
6356
6367
  const { positionList, index: index2, isUp, rowNo, cursorX } = payload;
6357
- let nextIndex = 0;
6368
+ let nextIndex = -1;
6358
6369
  const probablePosition = [];
6359
6370
  if (isUp) {
6360
6371
  let p = index2 - 1;
6361
- while (p > 0) {
6372
+ while (p >= 0) {
6362
6373
  const position = positionList[p];
6363
6374
  p--;
6364
6375
  if (position.rowNo === rowNo)
@@ -6521,7 +6532,7 @@ function updown(evt, host) {
6521
6532
  isUp,
6522
6533
  cursorX: curRightX
6523
6534
  });
6524
- if (!nextIndex)
6535
+ if (nextIndex < 0)
6525
6536
  return;
6526
6537
  anchorStartIndex = nextIndex;
6527
6538
  anchorEndIndex = nextIndex;
@@ -7288,11 +7299,15 @@ class GlobalEvent {
7288
7299
  }
7289
7300
  });
7290
7301
  __publicField(this, "_handleVisibilityChange", () => {
7291
- var _a;
7292
- if (document.visibilityState) {
7293
- const isCollapsed = this.range.getIsCollapsed();
7294
- (_a = this.cursor) == null ? void 0 : _a.drawCursor({
7295
- isShow: isCollapsed
7302
+ if (document.visibilityState === "visible") {
7303
+ const range = this.range.getRange();
7304
+ const isSetCursor = !!~range.startIndex && !!~range.endIndex && range.startIndex === range.endIndex;
7305
+ this.range.replaceRange(range);
7306
+ this.draw.render({
7307
+ isSetCursor,
7308
+ isCompute: false,
7309
+ isSubmitHistory: false,
7310
+ curIndex: range.startIndex
7296
7311
  });
7297
7312
  }
7298
7313
  });
@@ -7392,6 +7407,9 @@ class HistoryManager {
7392
7407
  this.undoStack = [];
7393
7408
  this.redoStack = [];
7394
7409
  }
7410
+ popUndo() {
7411
+ return this.undoStack.pop();
7412
+ }
7395
7413
  }
7396
7414
  class Position {
7397
7415
  constructor(draw) {
@@ -7454,7 +7472,7 @@ class Position {
7454
7472
  }
7455
7473
  computePageRowPosition(payload) {
7456
7474
  const { positionList, rowList, pageNo, startX, startY, startRowIndex, startIndex, innerWidth, zone: zone2 } = payload;
7457
- const { scale, tdPadding } = this.options;
7475
+ const { scale, table: { tdPadding } } = this.options;
7458
7476
  let x = startX;
7459
7477
  let y = startY;
7460
7478
  let index2 = startIndex;
@@ -7876,12 +7894,14 @@ class Position {
7876
7894
  positionResult.index = newIndex;
7877
7895
  }
7878
7896
  }
7879
- const { index: index2, isCheckbox, isRadio, isControl, isTable, trIndex, tdIndex, tdId, trId, tableId } = positionResult;
7897
+ const { index: index2, isCheckbox, isRadio, isControl, isImage, isDirectHit, isTable, trIndex, tdIndex, tdId, trId, tableId } = positionResult;
7880
7898
  this.setPositionContext({
7881
7899
  isTable: isTable || false,
7882
7900
  isCheckbox: isCheckbox || false,
7883
7901
  isRadio: isRadio || false,
7884
7902
  isControl: isControl || false,
7903
+ isImage: isImage || false,
7904
+ isDirectHit: isDirectHit || false,
7885
7905
  index: index2,
7886
7906
  trIndex,
7887
7907
  tdIndex,
@@ -9787,7 +9807,7 @@ class TableTool {
9787
9807
  if (order === TableOrder.ROW) {
9788
9808
  const trList = element.trList;
9789
9809
  const tr = trList[index2] || trList[index2 - 1];
9790
- const { defaultTrMinHeight } = this.options;
9810
+ const { defaultTrMinHeight } = this.options.table;
9791
9811
  if (dy < 0 && tr.height + dy < defaultTrMinHeight) {
9792
9812
  dy = defaultTrMinHeight - tr.height;
9793
9813
  }
@@ -9809,23 +9829,25 @@ class TableTool {
9809
9829
  dx = nextColWidth - this.MIN_TD_WIDTH;
9810
9830
  }
9811
9831
  const moveColWidth = curColWidth + dx;
9812
- let moveTableWidth = 0;
9813
- for (let c = 0; c < colgroup.length; c++) {
9814
- const group2 = colgroup[c];
9815
- if (c === index2 + 1) {
9816
- moveTableWidth -= dx;
9817
- }
9818
- if (c === index2) {
9819
- moveTableWidth += moveColWidth;
9832
+ if (index2 === colgroup.length - 1) {
9833
+ let moveTableWidth = 0;
9834
+ for (let c = 0; c < colgroup.length; c++) {
9835
+ const group2 = colgroup[c];
9836
+ if (c === index2 + 1) {
9837
+ moveTableWidth -= dx;
9838
+ }
9839
+ if (c === index2) {
9840
+ moveTableWidth += moveColWidth;
9841
+ }
9842
+ if (c !== index2) {
9843
+ moveTableWidth += group2.width;
9844
+ }
9820
9845
  }
9821
- if (c !== index2) {
9822
- moveTableWidth += group2.width;
9846
+ if (moveTableWidth > innerWidth) {
9847
+ const tableWidth = element.width;
9848
+ dx = innerWidth - tableWidth;
9823
9849
  }
9824
9850
  }
9825
- if (moveTableWidth > innerWidth) {
9826
- const tableWidth = element.width;
9827
- dx = innerWidth - tableWidth;
9828
- }
9829
9851
  if (dx) {
9830
9852
  if (colgroup.length - 1 !== index2) {
9831
9853
  colgroup[index2 + 1].width -= dx / scale;
@@ -10300,9 +10322,15 @@ class SelectControl {
10300
10322
  this.isPopup = false;
10301
10323
  this.selectDom = null;
10302
10324
  }
10325
+ setElement(element) {
10326
+ this.element = element;
10327
+ }
10303
10328
  getElement() {
10304
10329
  return this.element;
10305
10330
  }
10331
+ getIsPopup() {
10332
+ return this.isPopup;
10333
+ }
10306
10334
  getCode() {
10307
10335
  var _a;
10308
10336
  return ((_a = this.element.control) == null ? void 0 : _a.code) || null;
@@ -10385,7 +10413,8 @@ class SelectControl {
10385
10413
  return this.clearSelect();
10386
10414
  }
10387
10415
  clearSelect(context = {}, options = {}) {
10388
- if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
10416
+ const { isIgnoreDisabledRule = false, isAddPlaceholder = true } = options;
10417
+ if (!isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
10389
10418
  return -1;
10390
10419
  }
10391
10420
  const elementList = context.elementList || this.control.getElementList();
@@ -10415,7 +10444,9 @@ class SelectControl {
10415
10444
  return -1;
10416
10445
  const draw = this.control.getDraw();
10417
10446
  draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex);
10418
- this.control.addPlaceholder(preIndex, context);
10447
+ if (isAddPlaceholder) {
10448
+ this.control.addPlaceholder(preIndex, context);
10449
+ }
10419
10450
  this.element.control.code = null;
10420
10451
  return preIndex;
10421
10452
  }
@@ -10423,21 +10454,35 @@ class SelectControl {
10423
10454
  if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
10424
10455
  return;
10425
10456
  }
10457
+ const elementList = context.elementList || this.control.getElementList();
10458
+ const range = context.range || this.control.getRange();
10426
10459
  const control = this.element.control;
10460
+ const oldCode = control.code;
10461
+ if (code === oldCode) {
10462
+ this.control.repaintControl({
10463
+ curIndex: range.startIndex,
10464
+ isCompute: false,
10465
+ isSubmitHistory: false
10466
+ });
10467
+ this.destroy();
10468
+ return;
10469
+ }
10427
10470
  const valueSets = control.valueSets;
10428
10471
  if (!Array.isArray(valueSets) || !valueSets.length)
10429
10472
  return;
10430
10473
  const valueSet = valueSets.find((v) => v.code === code);
10431
10474
  if (!valueSet)
10432
10475
  return;
10433
- const elementList = context.elementList || this.control.getElementList();
10434
- const range = context.range || this.control.getRange();
10435
10476
  const valueElement = this.getValue(context)[0];
10436
10477
  const styleElement = valueElement ? pickObject(valueElement, EDITOR_ELEMENT_STYLE_ATTR) : pickObject(elementList[range.startIndex], CONTROL_STYLE_ATTR);
10437
- const prefixIndex = this.clearSelect(context);
10478
+ const prefixIndex = this.clearSelect(context, {
10479
+ isAddPlaceholder: false
10480
+ });
10438
10481
  if (!~prefixIndex)
10439
10482
  return;
10440
- this.control.removePlaceholder(prefixIndex, context);
10483
+ if (!oldCode) {
10484
+ this.control.removePlaceholder(prefixIndex, context);
10485
+ }
10441
10486
  const propertyElement = omitObject(elementList[prefixIndex], EDITOR_ELEMENT_STYLE_ATTR);
10442
10487
  const start = prefixIndex + 1;
10443
10488
  const data2 = splitText(valueSet.value);
@@ -10451,10 +10496,12 @@ class SelectControl {
10451
10496
  formatElementContext(elementList, [newElement], prefixIndex);
10452
10497
  draw.spliceElementList(elementList, start + i, 0, newElement);
10453
10498
  }
10454
- this.element.control.code = code;
10499
+ control.code = code;
10455
10500
  if (!context.range) {
10456
10501
  const newIndex = start + data2.length - 1;
10457
- this.control.repaintControl(newIndex);
10502
+ this.control.repaintControl({
10503
+ curIndex: newIndex
10504
+ });
10458
10505
  this.destroy();
10459
10506
  }
10460
10507
  }
@@ -10519,6 +10566,9 @@ class TextControl {
10519
10566
  this.element = element;
10520
10567
  this.control = control;
10521
10568
  }
10569
+ setElement(element) {
10570
+ this.element = element;
10571
+ }
10522
10572
  getElement() {
10523
10573
  return this.element;
10524
10574
  }
@@ -10869,19 +10919,36 @@ class Control {
10869
10919
  });
10870
10920
  }
10871
10921
  }
10872
- repaintControl(curIndex) {
10922
+ repaintControl(options = {}) {
10923
+ const { curIndex, isCompute = true, isSubmitHistory = true } = options;
10873
10924
  if (curIndex === void 0) {
10874
10925
  this.range.clearRange();
10875
10926
  this.draw.render({
10927
+ isCompute,
10928
+ isSubmitHistory,
10876
10929
  isSetCursor: false
10877
10930
  });
10878
10931
  } else {
10879
10932
  this.range.setRange(curIndex, curIndex);
10880
10933
  this.draw.render({
10881
- curIndex
10934
+ curIndex,
10935
+ isCompute,
10936
+ isSubmitHistory
10882
10937
  });
10883
10938
  }
10884
10939
  }
10940
+ reAwakeControl() {
10941
+ if (!this.activeControl)
10942
+ return;
10943
+ const elementList = this.getElementList();
10944
+ const range = this.getRange();
10945
+ const element = elementList[range.startIndex];
10946
+ this.activeControl.setElement(element);
10947
+ if (this.activeControl instanceof SelectControl && this.activeControl.getIsPopup()) {
10948
+ this.activeControl.destroy();
10949
+ this.activeControl.awake();
10950
+ }
10951
+ }
10885
10952
  moveCursor(position) {
10886
10953
  const { index: index2, trIndex, tdIndex, tdValueIndex } = position;
10887
10954
  let elementList = this.draw.getOriginalElementList();
@@ -10980,13 +11047,19 @@ class Control {
10980
11047
  const startElement = elementList[startIndex];
10981
11048
  const nextElement = elementList[startIndex + 1];
10982
11049
  if (startElement.controlComponent === ControlComponent.PLACEHOLDER || nextElement.controlComponent === ControlComponent.PLACEHOLDER) {
11050
+ let isHasSubmitHistory = false;
10983
11051
  let index2 = startIndex;
10984
11052
  while (index2 < elementList.length) {
10985
11053
  const curElement = elementList[index2];
10986
11054
  if (curElement.controlId !== startElement.controlId)
10987
11055
  break;
10988
11056
  if (curElement.controlComponent === ControlComponent.PLACEHOLDER) {
10989
- this.draw.spliceElementList(elementList, index2, 1);
11057
+ if (!isHasSubmitHistory) {
11058
+ isHasSubmitHistory = true;
11059
+ this.draw.getHistoryManager().popUndo();
11060
+ this.draw.submitHistory(startIndex);
11061
+ }
11062
+ elementList.splice(index2, 1);
10990
11063
  } else {
10991
11064
  index2++;
10992
11065
  }
@@ -11618,11 +11691,14 @@ class Previewer {
11618
11691
  const mousemoveFn = this._mousemove.bind(this);
11619
11692
  document.addEventListener("mousemove", mousemoveFn);
11620
11693
  document.addEventListener("mouseup", () => {
11694
+ var _a;
11621
11695
  if (this.curElement) {
11622
11696
  this.curElement.width = this.width;
11623
11697
  this.curElement.height = this.height;
11624
- this.draw.render({ isSetCursor: false });
11625
- this.drawResizer(this.curElement, this.curPosition, this.previewerDrawOption);
11698
+ this.draw.render({
11699
+ isSetCursor: true,
11700
+ curIndex: (_a = this.curPosition) == null ? void 0 : _a.index
11701
+ });
11626
11702
  }
11627
11703
  this.resizerImageContainer.style.display = "none";
11628
11704
  document.removeEventListener("mousemove", mousemoveFn);
@@ -11833,6 +11909,11 @@ class Previewer {
11833
11909
  }
11834
11910
  drawResizer(element, position = null, options = {}) {
11835
11911
  this.previewerDrawOption = options;
11912
+ this.curElementSrc = element[options.srcKey || "value"] || "";
11913
+ this.updateResizer(element, position);
11914
+ document.addEventListener("keydown", this._keydown);
11915
+ }
11916
+ updateResizer(element, position = null) {
11836
11917
  const { scale } = this.options;
11837
11918
  const elementWidth = element.width * scale;
11838
11919
  const elementHeight = element.height * scale;
@@ -11843,11 +11924,9 @@ class Previewer {
11843
11924
  this._updateResizerRect(elementWidth, elementHeight);
11844
11925
  this.resizerSelection.style.display = "block";
11845
11926
  this.curElement = element;
11846
- this.curElementSrc = element[options.srcKey || "value"] || "";
11847
11927
  this.curPosition = position;
11848
- this.width = this.curElement.width * scale;
11849
- this.height = this.curElement.height * scale;
11850
- document.addEventListener("keydown", this._keydown);
11928
+ this.width = elementWidth;
11929
+ this.height = elementHeight;
11851
11930
  }
11852
11931
  clearResizer() {
11853
11932
  this.resizerSelection.style.display = "none";
@@ -13814,7 +13893,7 @@ class Draw {
13814
13893
  return this.options.defaultBasicRowMarginHeight * this.options.scale;
13815
13894
  }
13816
13895
  getTdPadding() {
13817
- const { tdPadding, scale } = this.options;
13896
+ const { table: { tdPadding }, scale } = this.options;
13818
13897
  return tdPadding.map((m) => m * scale);
13819
13898
  }
13820
13899
  getContainer() {
@@ -14398,9 +14477,9 @@ class Draw {
14398
14477
  return defaultBasicRowMarginHeight * (el.rowMargin || defaultRowMargin) * scale;
14399
14478
  }
14400
14479
  computeRowList(payload) {
14401
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
14480
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
14402
14481
  const { innerWidth, elementList, isPagingMode = false } = payload;
14403
- const { defaultSize, defaultRowMargin, scale, tdPadding, defaultTabWidth } = this.options;
14482
+ const { defaultSize, defaultRowMargin, scale, table: { tdPadding }, defaultTabWidth } = this.options;
14404
14483
  const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight();
14405
14484
  const canvas = document.createElement("canvas");
14406
14485
  const ctx = canvas.getContext("2d");
@@ -14465,7 +14544,8 @@ class Draw {
14465
14544
  while (tableIndex < elementList.length) {
14466
14545
  const nextElement2 = elementList[tableIndex];
14467
14546
  if (nextElement2.pagingId === element.pagingId) {
14468
- element.trList.push(...nextElement2.trList);
14547
+ const nexTrList = nextElement2.trList.filter((tr) => !tr.pagingRepeat);
14548
+ element.trList.push(...nexTrList);
14469
14549
  element.height += nextElement2.height;
14470
14550
  tableIndex++;
14471
14551
  combineCount++;
@@ -14477,6 +14557,7 @@ class Draw {
14477
14557
  elementList.splice(i + 1, combineCount);
14478
14558
  }
14479
14559
  }
14560
+ element.pagingIndex = (_c = element.pagingIndex) != null ? _c : 0;
14480
14561
  this.tableParticle.computeRowColInfo(element);
14481
14562
  const trList = element.trList;
14482
14563
  for (let t = 0; t < trList.length; t++) {
@@ -14552,14 +14633,14 @@ class Draw {
14552
14633
  let curPagePreHeight = marginHeight;
14553
14634
  for (let r = 0; r < rowList.length; r++) {
14554
14635
  const row = rowList[r];
14555
- if (row.height + curPagePreHeight > height2 || ((_c = rowList[r - 1]) == null ? void 0 : _c.isPageBreak)) {
14636
+ if (row.height + curPagePreHeight > height2 || ((_d = rowList[r - 1]) == null ? void 0 : _d.isPageBreak)) {
14556
14637
  curPagePreHeight = marginHeight + row.height;
14557
14638
  } else {
14558
14639
  curPagePreHeight += row.height;
14559
14640
  }
14560
14641
  }
14561
14642
  const rowMarginHeight = rowMargin * 2 * scale;
14562
- if (curPagePreHeight + element.trList[0].height + rowMarginHeight > height2) {
14643
+ if (curPagePreHeight + element.trList[0].height + rowMarginHeight > height2 || element.pagingIndex !== 0 && element.trList[0].pagingRepeat) {
14563
14644
  curPagePreHeight = marginHeight;
14564
14645
  }
14565
14646
  if (curPagePreHeight + rowMarginHeight + elementHeight > height2) {
@@ -14573,7 +14654,7 @@ class Draw {
14573
14654
  const trHeight = tr.height * scale;
14574
14655
  if (curPagePreHeight + rowMarginHeight + preTrHeight + trHeight > height2) {
14575
14656
  const rowColCount = tr.tdList.reduce((pre, cur) => pre + cur.colspan, 0);
14576
- if (((_d = element.colgroup) == null ? void 0 : _d.length) !== rowColCount) {
14657
+ if (((_e = element.colgroup) == null ? void 0 : _e.length) !== rowColCount) {
14577
14658
  deleteCount = 0;
14578
14659
  }
14579
14660
  break;
@@ -14594,6 +14675,13 @@ class Draw {
14594
14675
  metrics.boundingBoxDescent -= cloneTrHeight;
14595
14676
  const cloneElement = deepClone(element);
14596
14677
  cloneElement.pagingId = pagingId;
14678
+ cloneElement.pagingIndex = element.pagingIndex + 1;
14679
+ const repeatTrList = trList2.filter((tr) => tr.pagingRepeat);
14680
+ if (repeatTrList.length) {
14681
+ const cloneRepeatTrList = deepClone(repeatTrList);
14682
+ cloneRepeatTrList.forEach((tr) => tr.id = getUUID());
14683
+ cloneTrList.unshift(...cloneRepeatTrList);
14684
+ }
14597
14685
  cloneElement.trList = cloneTrList;
14598
14686
  cloneElement.id = getUUID();
14599
14687
  this.spliceElementList(elementList, i + 1, 0, cloneElement);
@@ -14689,7 +14777,7 @@ class Draw {
14689
14777
  metrics,
14690
14778
  style: this.getElementFont(element, scale)
14691
14779
  });
14692
- if ((_e = rowElement.control) == null ? void 0 : _e.minWidth) {
14780
+ if ((_f = rowElement.control) == null ? void 0 : _f.minWidth) {
14693
14781
  if (rowElement.controlComponent) {
14694
14782
  controlRealWidth += metrics.width;
14695
14783
  }
@@ -14733,19 +14821,6 @@ class Draw {
14733
14821
  const isForceBreak = 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 || (preElement == null ? void 0 : preElement.listId) !== element.listId || i !== 0 && element.value === ZERO;
14734
14822
  const isWidthNotEnough = curRowWidth > availableWidth;
14735
14823
  if (isForceBreak || isWidthNotEnough) {
14736
- curRow.isWidthNotEnough = isWidthNotEnough && !isForceBreak;
14737
- if (curRow.startIndex === 0 && curRow.elementList.length === 1 && INLINE_ELEMENT_TYPE.includes(element.type)) {
14738
- curRow.height = defaultBasicRowMarginHeight;
14739
- }
14740
- if ((preElement == null ? void 0 : preElement.rowFlex) === RowFlex.JUSTIFY || (preElement == null ? void 0 : preElement.rowFlex) === RowFlex.ALIGNMENT && isWidthNotEnough) {
14741
- const rowElementList = ((_f = curRow.elementList[0]) == null ? void 0 : _f.value) === ZERO ? curRow.elementList.slice(1) : curRow.elementList;
14742
- const gap = (availableWidth - curRow.width) / (rowElementList.length - 1);
14743
- for (let e = 0; e < rowElementList.length - 1; e++) {
14744
- const el = rowElementList[e];
14745
- el.metrics.width += gap;
14746
- }
14747
- curRow.width = availableWidth;
14748
- }
14749
14824
  const row = {
14750
14825
  width: metrics.width,
14751
14826
  height,
@@ -14776,12 +14851,27 @@ class Draw {
14776
14851
  rowList.push(row);
14777
14852
  } else {
14778
14853
  curRow.width += metrics.width;
14779
- if (curRow.height < height) {
14854
+ if (i === 0 && getIsInlineElement(elementList[1])) {
14855
+ curRow.height = defaultBasicRowMarginHeight;
14856
+ curRow.ascent = defaultBasicRowMarginHeight;
14857
+ } else if (curRow.height < height) {
14780
14858
  curRow.height = height;
14781
14859
  curRow.ascent = ascent;
14782
14860
  }
14783
14861
  curRow.elementList.push(rowElement);
14784
14862
  }
14863
+ if (isForceBreak || isWidthNotEnough || i === elementList.length - 1) {
14864
+ curRow.isWidthNotEnough = isWidthNotEnough && !isForceBreak;
14865
+ if ((preElement == null ? void 0 : preElement.rowFlex) === RowFlex.JUSTIFY || (preElement == null ? void 0 : preElement.rowFlex) === RowFlex.ALIGNMENT && isWidthNotEnough) {
14866
+ const rowElementList = ((_j = curRow.elementList[0]) == null ? void 0 : _j.value) === ZERO ? curRow.elementList.slice(1) : curRow.elementList;
14867
+ const gap = (availableWidth - curRow.width) / (rowElementList.length - 1);
14868
+ for (let e = 0; e < rowElementList.length - 1; e++) {
14869
+ const el = rowElementList[e];
14870
+ el.metrics.width += gap;
14871
+ }
14872
+ curRow.width = availableWidth;
14873
+ }
14874
+ }
14785
14875
  }
14786
14876
  return rowList;
14787
14877
  }
@@ -14846,7 +14936,7 @@ class Draw {
14846
14936
  drawRow(ctx, payload) {
14847
14937
  var _a, _b, _c, _d, _e, _f;
14848
14938
  this._drawHighlight(ctx, payload);
14849
- const { scale, tdPadding, group: group2, lineBreak } = this.options;
14939
+ const { scale, table: { tdPadding }, group: group2, lineBreak } = this.options;
14850
14940
  const { rowList, pageNo, elementList, positionList, startIndex, zone: zone2, isDrawLineBreak = !lineBreak.disabled } = payload;
14851
14941
  const isPrintMode = this.mode === EditorMode.PRINT;
14852
14942
  const { isCrossRowCol, tableId } = this.range.getRange();
@@ -14893,7 +14983,6 @@ class Draw {
14893
14983
  this.textParticle.complete();
14894
14984
  }
14895
14985
  } else if (element.type === ElementType.SUPERSCRIPT) {
14896
- this.underline.render(ctx);
14897
14986
  this.textParticle.complete();
14898
14987
  this.superscriptParticle.render(ctx, element, x, y + offsetY);
14899
14988
  } else if (element.type === ElementType.SUBSCRIPT) {
@@ -14929,7 +15018,7 @@ class Draw {
14929
15018
  this.textParticle.complete();
14930
15019
  }
14931
15020
  }
14932
- if (isDrawLineBreak && !curRow.isWidthNotEnough && j === curRow.elementList.length - 1) {
15021
+ if (isDrawLineBreak && !isPrintMode && this.mode !== EditorMode.CLEAN && !curRow.isWidthNotEnough && j === curRow.elementList.length - 1) {
14933
15022
  this.lineBreakParticle.render(ctx, element, x, y + curRow.height / 2);
14934
15023
  }
14935
15024
  if ((_a = element.control) == null ? void 0 : _a.border) {
@@ -14942,7 +15031,7 @@ class Draw {
14942
15031
  this.control.drawBorder(ctx);
14943
15032
  }
14944
15033
  if (element.underline || ((_d = element.control) == null ? void 0 : _d.underline)) {
14945
- if ((preElement == null ? void 0 : preElement.type) === ElementType.SUPERSCRIPT && element.type !== ElementType.SUPERSCRIPT || (preElement == null ? void 0 : preElement.type) === ElementType.SUBSCRIPT && element.type !== ElementType.SUBSCRIPT) {
15034
+ if ((preElement == null ? void 0 : preElement.type) === ElementType.SUBSCRIPT && element.type !== ElementType.SUBSCRIPT) {
14946
15035
  this.underline.render(ctx);
14947
15036
  }
14948
15037
  const rowMargin = this.getElementRowMargin(element);
@@ -14950,8 +15039,6 @@ class Draw {
14950
15039
  let offsetY2 = 0;
14951
15040
  if (element.type === ElementType.SUBSCRIPT) {
14952
15041
  offsetY2 = this.subscriptParticle.getOffsetY(element);
14953
- } else if (element.type === ElementType.SUPERSCRIPT) {
14954
- offsetY2 = this.superscriptParticle.getOffsetY(element);
14955
15042
  }
14956
15043
  const color = element.controlComponent === ControlComponent.PLACEHOLDER ? void 0 : element.color;
14957
15044
  this.underline.recordFillInfo(ctx, x - offsetX, y + curRow.height - rowMargin + offsetY2, metrics.width + offsetX, 0, color, (_e = element.textDecoration) == null ? void 0 : _e.style);
@@ -14960,7 +15047,7 @@ class Draw {
14960
15047
  }
14961
15048
  if (element.strikeout) {
14962
15049
  if (!element.type || TEXTLIKE_ELEMENT_TYPE.includes(element.type)) {
14963
- if (preElement && this.getElementSize(preElement) !== this.getElementSize(element)) {
15050
+ if (preElement && (preElement.type === ElementType.SUBSCRIPT && element.type !== ElementType.SUBSCRIPT || preElement.type === ElementType.SUPERSCRIPT && element.type !== ElementType.SUPERSCRIPT || this.getElementSize(preElement) !== this.getElementSize(element))) {
14964
15051
  this.strikeout.render(ctx);
14965
15052
  }
14966
15053
  const standardMetrics = this.textParticle.measureBasisWord(ctx, this.getElementFont(element));
@@ -15153,7 +15240,6 @@ class Draw {
15153
15240
  }
15154
15241
  }
15155
15242
  render(payload) {
15156
- var _a;
15157
15243
  const { header, footer } = this.options;
15158
15244
  const { isSubmitHistory = true, isSetCursor = true, isCompute = true, isLazy = true, isInit = false, isSourceHistory = false, isFirstRender = false } = payload || {};
15159
15245
  let { curIndex } = payload || {};
@@ -15201,48 +15287,17 @@ class Draw {
15201
15287
  } else {
15202
15288
  this._immediateRender();
15203
15289
  }
15204
- const positionContext = this.position.getPositionContext();
15205
15290
  if (isSetCursor) {
15206
- const positionList = this.position.getPositionList();
15207
- if (positionContext.isTable) {
15208
- const { index: index2, trIndex, tdIndex } = positionContext;
15209
- const elementList = this.getOriginalElementList();
15210
- const tablePositionList = (_a = elementList[index2].trList) == null ? void 0 : _a[trIndex].tdList[tdIndex].positionList;
15211
- if (curIndex === void 0 && tablePositionList) {
15212
- curIndex = tablePositionList.length - 1;
15213
- }
15214
- const tablePosition = tablePositionList == null ? void 0 : tablePositionList[curIndex];
15215
- this.position.setCursorPosition(tablePosition || null);
15216
- } else {
15217
- this.position.setCursorPosition(curIndex !== void 0 ? positionList[curIndex] : null);
15218
- }
15219
- this.cursor.drawCursor();
15291
+ curIndex = this.setCursor(curIndex);
15220
15292
  }
15221
15293
  if (isSubmitHistory && !isFirstRender || curIndex !== void 0 && this.historyManager.isStackEmpty()) {
15222
- const oldElementList = getSlimCloneElementList(this.elementList);
15223
- const oldHeaderElementList = getSlimCloneElementList(this.header.getElementList());
15224
- const oldFooterElementList = getSlimCloneElementList(this.footer.getElementList());
15225
- const oldRange = deepClone(this.range.getRange());
15226
- const pageNo = this.pageNo;
15227
- const oldPositionContext = deepClone(positionContext);
15228
- const zone2 = this.zone.getZone();
15229
- this.historyManager.execute(() => {
15230
- this.zone.setZone(zone2);
15231
- this.setPageNo(pageNo);
15232
- this.position.setPositionContext(deepClone(oldPositionContext));
15233
- this.header.setElementList(deepClone(oldHeaderElementList));
15234
- this.footer.setElementList(deepClone(oldFooterElementList));
15235
- this.elementList = deepClone(oldElementList);
15236
- this.range.replaceRange(deepClone(oldRange));
15237
- this.render({
15238
- curIndex,
15239
- isSubmitHistory: false,
15240
- isSourceHistory: true
15241
- });
15242
- });
15294
+ this.submitHistory(curIndex);
15243
15295
  }
15244
15296
  nextTick(() => {
15245
- if (isCompute && !this.isReadonly() && positionContext.isTable) {
15297
+ if (isCompute && this.control.getActiveControl()) {
15298
+ this.control.reAwakeControl();
15299
+ }
15300
+ if (isCompute && !this.isReadonly() && this.position.getPositionContext().isTable) {
15246
15301
  this.tableTool.render();
15247
15302
  }
15248
15303
  if (isCompute && !this.zone.isMainActive()) {
@@ -15264,6 +15319,61 @@ class Draw {
15264
15319
  }
15265
15320
  });
15266
15321
  }
15322
+ setCursor(curIndex) {
15323
+ var _a;
15324
+ const positionContext = this.position.getPositionContext();
15325
+ const positionList = this.position.getPositionList();
15326
+ if (positionContext.isTable) {
15327
+ const { index: index2, trIndex, tdIndex } = positionContext;
15328
+ const elementList = this.getOriginalElementList();
15329
+ const tablePositionList = (_a = elementList[index2].trList) == null ? void 0 : _a[trIndex].tdList[tdIndex].positionList;
15330
+ if (curIndex === void 0 && tablePositionList) {
15331
+ curIndex = tablePositionList.length - 1;
15332
+ }
15333
+ const tablePosition = tablePositionList == null ? void 0 : tablePositionList[curIndex];
15334
+ this.position.setCursorPosition(tablePosition || null);
15335
+ } else {
15336
+ this.position.setCursorPosition(curIndex !== void 0 ? positionList[curIndex] : null);
15337
+ }
15338
+ let isShowCursor = true;
15339
+ if (curIndex !== void 0 && positionContext.isImage && positionContext.isDirectHit) {
15340
+ const elementList = this.getElementList();
15341
+ const element = elementList[curIndex];
15342
+ if (IMAGE_ELEMENT_TYPE.includes(element.type)) {
15343
+ isShowCursor = false;
15344
+ const position = this.position.getCursorPosition();
15345
+ this.previewer.updateResizer(element, position);
15346
+ }
15347
+ }
15348
+ this.cursor.drawCursor({
15349
+ isShow: isShowCursor
15350
+ });
15351
+ return curIndex;
15352
+ }
15353
+ submitHistory(curIndex) {
15354
+ const positionContext = this.position.getPositionContext();
15355
+ const oldElementList = getSlimCloneElementList(this.elementList);
15356
+ const oldHeaderElementList = getSlimCloneElementList(this.header.getElementList());
15357
+ const oldFooterElementList = getSlimCloneElementList(this.footer.getElementList());
15358
+ const oldRange = deepClone(this.range.getRange());
15359
+ const pageNo = this.pageNo;
15360
+ const oldPositionContext = deepClone(positionContext);
15361
+ const zone2 = this.zone.getZone();
15362
+ this.historyManager.execute(() => {
15363
+ this.zone.setZone(zone2);
15364
+ this.setPageNo(pageNo);
15365
+ this.position.setPositionContext(deepClone(oldPositionContext));
15366
+ this.header.setElementList(deepClone(oldHeaderElementList));
15367
+ this.footer.setElementList(deepClone(oldFooterElementList));
15368
+ this.elementList = deepClone(oldElementList);
15369
+ this.range.replaceRange(deepClone(oldRange));
15370
+ this.render({
15371
+ curIndex,
15372
+ isSubmitHistory: false,
15373
+ isSourceHistory: true
15374
+ });
15375
+ });
15376
+ }
15267
15377
  destroy() {
15268
15378
  this.container.remove();
15269
15379
  this.globalEvent.removeEvent();
@@ -15367,6 +15477,7 @@ class Command {
15367
15477
  __publicField(this, "executeSetControlExtension");
15368
15478
  __publicField(this, "executeSetControlProperties");
15369
15479
  __publicField(this, "executeSetControlHighlight");
15480
+ __publicField(this, "executeUpdateOptions");
15370
15481
  __publicField(this, "getCatalog");
15371
15482
  __publicField(this, "getImage");
15372
15483
  __publicField(this, "getOptions");
@@ -15472,6 +15583,7 @@ class Command {
15472
15583
  this.executeDeleteGroup = adapt.deleteGroup.bind(adapt);
15473
15584
  this.executeLocationGroup = adapt.locationGroup.bind(adapt);
15474
15585
  this.executeSetZone = adapt.setZone.bind(adapt);
15586
+ this.executeUpdateOptions = adapt.updateOptions.bind(adapt);
15475
15587
  this.getImage = adapt.getImage.bind(adapt);
15476
15588
  this.getOptions = adapt.getOptions.bind(adapt);
15477
15589
  this.getValue = adapt.getValue.bind(adapt);
@@ -15512,6 +15624,160 @@ var VerticalAlign;
15512
15624
  VerticalAlign2["MIDDLE"] = "middle";
15513
15625
  VerticalAlign2["BOTTOM"] = "bottom";
15514
15626
  })(VerticalAlign || (VerticalAlign = {}));
15627
+ const defaultBackground = {
15628
+ color: "#FFFFFF",
15629
+ image: "",
15630
+ size: BackgroundSize.COVER,
15631
+ repeat: BackgroundRepeat.NO_REPEAT
15632
+ };
15633
+ const defaultCheckboxOption = {
15634
+ width: 14,
15635
+ height: 14,
15636
+ gap: 5,
15637
+ lineWidth: 1,
15638
+ fillStyle: "#5175f4",
15639
+ strokeStyle: "#ffffff"
15640
+ };
15641
+ const defaultControlOption = {
15642
+ placeholderColor: "#9c9b9b",
15643
+ bracketColor: "#000000",
15644
+ prefix: "{",
15645
+ postfix: "}",
15646
+ borderWidth: 1,
15647
+ borderColor: "#000000"
15648
+ };
15649
+ const defaultFooterOption = {
15650
+ bottom: 30,
15651
+ maxHeightRadio: MaxHeightRatio.HALF,
15652
+ disabled: false
15653
+ };
15654
+ const defaultGroupOption = {
15655
+ opacity: 0.1,
15656
+ backgroundColor: "#E99D00",
15657
+ activeOpacity: 0.5,
15658
+ activeBackgroundColor: "#E99D00",
15659
+ disabled: false
15660
+ };
15661
+ const defaultHeaderOption = {
15662
+ top: 30,
15663
+ maxHeightRadio: MaxHeightRatio.HALF,
15664
+ disabled: false
15665
+ };
15666
+ const defaultLineBreak = {
15667
+ disabled: true,
15668
+ color: "#CCCCCC",
15669
+ lineWidth: 1.5
15670
+ };
15671
+ const defaultPageBreakOption = {
15672
+ font: "Microsoft YaHei",
15673
+ fontSize: 12,
15674
+ lineDash: [3, 1]
15675
+ };
15676
+ const defaultPlaceholderOption = {
15677
+ data: "",
15678
+ color: "#DCDFE6",
15679
+ opacity: 1,
15680
+ size: 16,
15681
+ font: "Microsoft YaHei"
15682
+ };
15683
+ const defaultRadioOption = {
15684
+ width: 14,
15685
+ height: 14,
15686
+ gap: 5,
15687
+ lineWidth: 1,
15688
+ fillStyle: "#5175f4",
15689
+ strokeStyle: "#000000"
15690
+ };
15691
+ const defaultSeparatorOption = {
15692
+ lineWidth: 1,
15693
+ strokeStyle: "#000000"
15694
+ };
15695
+ const defaultTableOption = {
15696
+ tdPadding: [0, 5, 5, 5],
15697
+ defaultTrMinHeight: 42,
15698
+ defaultColMinWidth: 40
15699
+ };
15700
+ const defaultZoneOption = {
15701
+ tipDisabled: true
15702
+ };
15703
+ function mergeOption(options = {}) {
15704
+ const tableOptions = __spreadValues(__spreadValues({}, defaultTableOption), options.table);
15705
+ const headerOptions = __spreadValues(__spreadValues({}, defaultHeaderOption), options.header);
15706
+ const footerOptions = __spreadValues(__spreadValues({}, defaultFooterOption), options.footer);
15707
+ const pageNumberOptions = __spreadValues(__spreadValues({}, defaultPageNumberOption), options.pageNumber);
15708
+ const waterMarkOptions = __spreadValues(__spreadValues({}, defaultWatermarkOption), options.watermark);
15709
+ const controlOptions = __spreadValues(__spreadValues({}, defaultControlOption), options.control);
15710
+ const checkboxOptions = __spreadValues(__spreadValues({}, defaultCheckboxOption), options.checkbox);
15711
+ const radioOptions = __spreadValues(__spreadValues({}, defaultRadioOption), options.radio);
15712
+ const cursorOptions = __spreadValues(__spreadValues({}, defaultCursorOption), options.cursor);
15713
+ const titleOptions = __spreadValues(__spreadValues({}, defaultTitleOption), options.title);
15714
+ const placeholderOptions = __spreadValues(__spreadValues({}, defaultPlaceholderOption), options.placeholder);
15715
+ const groupOptions = __spreadValues(__spreadValues({}, defaultGroupOption), options.group);
15716
+ const pageBreakOptions = __spreadValues(__spreadValues({}, defaultPageBreakOption), options.pageBreak);
15717
+ const zoneOptions = __spreadValues(__spreadValues({}, defaultZoneOption), options.zone);
15718
+ const backgroundOptions = __spreadValues(__spreadValues({}, defaultBackground), options.background);
15719
+ const lineBreakOptions = __spreadValues(__spreadValues({}, defaultLineBreak), options.lineBreak);
15720
+ const separatorOptions = __spreadValues(__spreadValues({}, defaultSeparatorOption), options.separator);
15721
+ return __spreadProps(__spreadValues({
15722
+ mode: EditorMode.EDIT,
15723
+ defaultType: "TEXT",
15724
+ defaultColor: "#000000",
15725
+ defaultFont: "Microsoft YaHei",
15726
+ defaultSize: 16,
15727
+ minSize: 5,
15728
+ maxSize: 72,
15729
+ defaultRowMargin: 1,
15730
+ defaultBasicRowMarginHeight: 8,
15731
+ defaultTabWidth: 32,
15732
+ width: 794,
15733
+ height: 1123,
15734
+ scale: 1,
15735
+ pageGap: 20,
15736
+ underlineColor: "#000000",
15737
+ strikeoutColor: "#FF0000",
15738
+ rangeAlpha: 0.6,
15739
+ rangeColor: "#AECBFA",
15740
+ rangeMinWidth: 5,
15741
+ searchMatchAlpha: 0.6,
15742
+ searchMatchColor: "#FFFF00",
15743
+ searchNavigateMatchColor: "#AAD280",
15744
+ highlightAlpha: 0.6,
15745
+ resizerColor: "#4182D9",
15746
+ resizerSize: 5,
15747
+ marginIndicatorSize: 35,
15748
+ marginIndicatorColor: "#BABABA",
15749
+ margins: [100, 120, 100, 120],
15750
+ pageMode: PageMode.PAGING,
15751
+ defaultHyperlinkColor: "#0000FF",
15752
+ paperDirection: PaperDirection.VERTICAL,
15753
+ inactiveAlpha: 0.6,
15754
+ historyMaxRecordCount: 100,
15755
+ wordBreak: WordBreak.BREAK_WORD,
15756
+ printPixelRatio: 3,
15757
+ maskMargin: [0, 0, 0, 0],
15758
+ letterClass: [LETTER_CLASS.ENGLISH],
15759
+ contextMenuDisableKeys: [],
15760
+ scrollContainerSelector: ""
15761
+ }, options), {
15762
+ table: tableOptions,
15763
+ header: headerOptions,
15764
+ footer: footerOptions,
15765
+ pageNumber: pageNumberOptions,
15766
+ watermark: waterMarkOptions,
15767
+ control: controlOptions,
15768
+ checkbox: checkboxOptions,
15769
+ radio: radioOptions,
15770
+ cursor: cursorOptions,
15771
+ title: titleOptions,
15772
+ placeholder: placeholderOptions,
15773
+ group: groupOptions,
15774
+ pageBreak: pageBreakOptions,
15775
+ zone: zoneOptions,
15776
+ background: backgroundOptions,
15777
+ lineBreak: lineBreakOptions,
15778
+ separator: separatorOptions
15779
+ });
15780
+ }
15515
15781
  function printImageBase64(base64List, options) {
15516
15782
  const { width, height, direction = PaperDirection.VERTICAL } = options;
15517
15783
  const iframe = document.createElement("iframe");
@@ -16167,6 +16433,7 @@ class CommandAdapt {
16167
16433
  const { startIndex, endIndex } = this.range.getRange();
16168
16434
  if (!~startIndex && !~endIndex)
16169
16435
  return;
16436
+ const { defaultTrMinHeight } = this.options.table;
16170
16437
  const elementList = this.draw.getElementList();
16171
16438
  let offsetX = 0;
16172
16439
  if ((_a = elementList[startIndex]) == null ? void 0 : _a.listId) {
@@ -16188,7 +16455,7 @@ class CommandAdapt {
16188
16455
  for (let r = 0; r < row; r++) {
16189
16456
  const tdList = [];
16190
16457
  const tr = {
16191
- height: this.options.defaultTrMinHeight,
16458
+ height: defaultTrMinHeight,
16192
16459
  tdList
16193
16460
  };
16194
16461
  for (let c = 0; c < col; c++) {
@@ -16372,7 +16639,7 @@ class CommandAdapt {
16372
16639
  }
16373
16640
  const colgroup = element.colgroup;
16374
16641
  colgroup.splice(curTdIndex, 0, {
16375
- width: this.options.defaultColMinWidth
16642
+ width: this.options.table.defaultColMinWidth
16376
16643
  });
16377
16644
  const colgroupWidth = colgroup.reduce((pre, cur) => pre + cur.width, 0);
16378
16645
  const width = this.draw.getOriginalInnerWidth();
@@ -16428,7 +16695,7 @@ class CommandAdapt {
16428
16695
  }
16429
16696
  const colgroup = element.colgroup;
16430
16697
  colgroup.splice(curTdIndex, 0, {
16431
- width: this.options.defaultColMinWidth
16698
+ width: this.options.table.defaultColMinWidth
16432
16699
  });
16433
16700
  const colgroupWidth = colgroup.reduce((pre, cur) => pre + cur.width, 0);
16434
16701
  const width = this.draw.getOriginalInnerWidth();
@@ -17403,7 +17670,15 @@ class CommandAdapt {
17403
17670
  });
17404
17671
  }
17405
17672
  const zone2 = this.draw.getZone().getZone();
17406
- const isTable = this.position.getPositionContext().isTable;
17673
+ const { isTable, trIndex, tdIndex, index: index2 } = this.position.getPositionContext();
17674
+ let tableElement = null;
17675
+ if (isTable) {
17676
+ const originalElementList = this.draw.getOriginalElementList();
17677
+ const originTableElement = originalElementList[index2] || null;
17678
+ if (originTableElement) {
17679
+ tableElement = zipElementList([originTableElement])[0];
17680
+ }
17681
+ }
17407
17682
  return deepClone({
17408
17683
  isCollapsed,
17409
17684
  startElement,
@@ -17412,7 +17687,10 @@ class CommandAdapt {
17412
17687
  endPageNo,
17413
17688
  rangeRects,
17414
17689
  zone: zone2,
17415
- isTable
17690
+ isTable,
17691
+ trIndex: trIndex != null ? trIndex : null,
17692
+ tdIndex: tdIndex != null ? tdIndex : null,
17693
+ tableElement
17416
17694
  });
17417
17695
  }
17418
17696
  getRangeRow() {
@@ -17632,6 +17910,13 @@ class CommandAdapt {
17632
17910
  setControlHighlight(payload) {
17633
17911
  this.draw.getControl().setHighlightList(payload);
17634
17912
  }
17913
+ updateOptions(payload) {
17914
+ const newOption = mergeOption(payload);
17915
+ Object.entries(newOption).forEach(([key, value]) => {
17916
+ Reflect.set(this.options, key, value);
17917
+ });
17918
+ this.forceUpdate();
17919
+ }
17635
17920
  getControlList() {
17636
17921
  return this.draw.getControl().getList();
17637
17922
  }
@@ -18324,9 +18609,16 @@ class ContextMenu {
18324
18609
  const { isCrossRowCol: crossRowCol, startIndex, endIndex } = this.range.getRange();
18325
18610
  const editorTextFocus = !!(~startIndex || ~endIndex);
18326
18611
  const editorHasSelection = editorTextFocus && startIndex !== endIndex;
18327
- const positionContext = this.position.getPositionContext();
18328
- const isInTable = positionContext.isTable;
18329
- const isCrossRowCol = isInTable && !!crossRowCol;
18612
+ const { isTable, trIndex, tdIndex, index: index2 } = this.position.getPositionContext();
18613
+ let tableElement = null;
18614
+ if (isTable) {
18615
+ const originalElementList = this.draw.getOriginalElementList();
18616
+ const originTableElement = originalElementList[index2] || null;
18617
+ if (originTableElement) {
18618
+ tableElement = zipElementList([originTableElement])[0];
18619
+ }
18620
+ }
18621
+ const isCrossRowCol = isTable && !!crossRowCol;
18330
18622
  const elementList = this.draw.getElementList();
18331
18623
  const startElement = elementList[startIndex] || null;
18332
18624
  const endElement = elementList[endIndex] || null;
@@ -18337,9 +18629,12 @@ class ContextMenu {
18337
18629
  isReadonly,
18338
18630
  editorHasSelection,
18339
18631
  editorTextFocus,
18340
- isInTable,
18341
18632
  isCrossRowCol,
18342
- zone: zone2
18633
+ zone: zone2,
18634
+ isInTable: isTable,
18635
+ trIndex: trIndex != null ? trIndex : null,
18636
+ tdIndex: tdIndex != null ? tdIndex : null,
18637
+ tableElement
18343
18638
  };
18344
18639
  }
18345
18640
  _createContextMenuContainer() {
@@ -18480,35 +18775,6 @@ class ContextMenu {
18480
18775
  this.contextMenuRelationShip.clear();
18481
18776
  }
18482
18777
  }
18483
- const defaultHeaderOption = {
18484
- top: 30,
18485
- maxHeightRadio: MaxHeightRatio.HALF,
18486
- disabled: false
18487
- };
18488
- const defaultControlOption = {
18489
- placeholderColor: "#9c9b9b",
18490
- bracketColor: "#000000",
18491
- prefix: "{",
18492
- postfix: "}",
18493
- borderWidth: 1,
18494
- borderColor: "#000000"
18495
- };
18496
- const defaultCheckboxOption = {
18497
- width: 14,
18498
- height: 14,
18499
- gap: 5,
18500
- lineWidth: 1,
18501
- fillStyle: "#5175f4",
18502
- strokeStyle: "#ffffff"
18503
- };
18504
- const defaultRadioOption = {
18505
- width: 14,
18506
- height: 14,
18507
- gap: 5,
18508
- lineWidth: 1,
18509
- fillStyle: "#5175f4",
18510
- strokeStyle: "#000000"
18511
- };
18512
18778
  const richtextKeys = [
18513
18779
  {
18514
18780
  key: KeyMap.X_UPPERCASE,
@@ -18738,18 +19004,6 @@ class Shortcut {
18738
19004
  }
18739
19005
  }
18740
19006
  }
18741
- const defaultFooterOption = {
18742
- bottom: 30,
18743
- maxHeightRadio: MaxHeightRatio.HALF,
18744
- disabled: false
18745
- };
18746
- const defaultPlaceholderOption = {
18747
- data: "",
18748
- color: "#DCDFE6",
18749
- opacity: 1,
18750
- size: 16,
18751
- font: "Microsoft YaHei"
18752
- };
18753
19007
  class Plugin {
18754
19008
  constructor(editor) {
18755
19009
  __publicField(this, "editor");
@@ -18796,42 +19050,12 @@ class EventBus {
18796
19050
  return !!eventSet && eventSet.size > 0;
18797
19051
  }
18798
19052
  }
18799
- const defaultGroupOption = {
18800
- opacity: 0.1,
18801
- backgroundColor: "#E99D00",
18802
- activeOpacity: 0.5,
18803
- activeBackgroundColor: "#E99D00",
18804
- disabled: false
18805
- };
18806
19053
  class Override {
18807
19054
  constructor() {
18808
19055
  __publicField(this, "paste");
18809
19056
  __publicField(this, "copy");
18810
19057
  }
18811
19058
  }
18812
- const defaultPageBreakOption = {
18813
- font: "Microsoft YaHei",
18814
- fontSize: 12,
18815
- lineDash: [3, 1]
18816
- };
18817
- const defaultZoneOption = {
18818
- tipDisabled: true
18819
- };
18820
- const defaultBackground = {
18821
- color: "#FFFFFF",
18822
- image: "",
18823
- size: BackgroundSize.COVER,
18824
- repeat: BackgroundRepeat.NO_REPEAT
18825
- };
18826
- const defaultLineBreak = {
18827
- disabled: true,
18828
- color: "#CCCCCC",
18829
- lineWidth: 1.5
18830
- };
18831
- const defaultSeparatorOption = {
18832
- lineWidth: 1,
18833
- strokeStyle: "#000000"
18834
- };
18835
19059
  class Editor {
18836
19060
  constructor(container, data2, options = {}) {
18837
19061
  __publicField(this, "command");
@@ -18841,83 +19065,7 @@ class Editor {
18841
19065
  __publicField(this, "register");
18842
19066
  __publicField(this, "destroy");
18843
19067
  __publicField(this, "use");
18844
- const headerOptions = __spreadValues(__spreadValues({}, defaultHeaderOption), options.header);
18845
- const footerOptions = __spreadValues(__spreadValues({}, defaultFooterOption), options.footer);
18846
- const pageNumberOptions = __spreadValues(__spreadValues({}, defaultPageNumberOption), options.pageNumber);
18847
- const waterMarkOptions = __spreadValues(__spreadValues({}, defaultWatermarkOption), options.watermark);
18848
- const controlOptions = __spreadValues(__spreadValues({}, defaultControlOption), options.control);
18849
- const checkboxOptions = __spreadValues(__spreadValues({}, defaultCheckboxOption), options.checkbox);
18850
- const radioOptions = __spreadValues(__spreadValues({}, defaultRadioOption), options.radio);
18851
- const cursorOptions = __spreadValues(__spreadValues({}, defaultCursorOption), options.cursor);
18852
- const titleOptions = __spreadValues(__spreadValues({}, defaultTitleOption), options.title);
18853
- const placeholderOptions = __spreadValues(__spreadValues({}, defaultPlaceholderOption), options.placeholder);
18854
- const groupOptions = __spreadValues(__spreadValues({}, defaultGroupOption), options.group);
18855
- const pageBreakOptions = __spreadValues(__spreadValues({}, defaultPageBreakOption), options.pageBreak);
18856
- const zoneOptions = __spreadValues(__spreadValues({}, defaultZoneOption), options.zone);
18857
- const backgroundOptions = __spreadValues(__spreadValues({}, defaultBackground), options.background);
18858
- const lineBreakOptions = __spreadValues(__spreadValues({}, defaultLineBreak), options.lineBreak);
18859
- const separatorOptions = __spreadValues(__spreadValues({}, defaultSeparatorOption), options.separator);
18860
- const editorOptions = __spreadProps(__spreadValues({
18861
- mode: EditorMode.EDIT,
18862
- defaultType: "TEXT",
18863
- defaultColor: "#000000",
18864
- defaultFont: "Microsoft YaHei",
18865
- defaultSize: 16,
18866
- minSize: 5,
18867
- maxSize: 72,
18868
- defaultRowMargin: 1,
18869
- defaultBasicRowMarginHeight: 8,
18870
- defaultTabWidth: 32,
18871
- width: 794,
18872
- height: 1123,
18873
- scale: 1,
18874
- pageGap: 20,
18875
- underlineColor: "#000000",
18876
- strikeoutColor: "#FF0000",
18877
- rangeAlpha: 0.6,
18878
- rangeColor: "#AECBFA",
18879
- rangeMinWidth: 5,
18880
- searchMatchAlpha: 0.6,
18881
- searchMatchColor: "#FFFF00",
18882
- searchNavigateMatchColor: "#AAD280",
18883
- highlightAlpha: 0.6,
18884
- resizerColor: "#4182D9",
18885
- resizerSize: 5,
18886
- marginIndicatorSize: 35,
18887
- marginIndicatorColor: "#BABABA",
18888
- margins: [100, 120, 100, 120],
18889
- pageMode: PageMode.PAGING,
18890
- tdPadding: [0, 5, 5, 5],
18891
- defaultTrMinHeight: 42,
18892
- defaultColMinWidth: 40,
18893
- defaultHyperlinkColor: "#0000FF",
18894
- paperDirection: PaperDirection.VERTICAL,
18895
- inactiveAlpha: 0.6,
18896
- historyMaxRecordCount: 100,
18897
- wordBreak: WordBreak.BREAK_WORD,
18898
- printPixelRatio: 3,
18899
- maskMargin: [0, 0, 0, 0],
18900
- letterClass: [LETTER_CLASS.ENGLISH],
18901
- contextMenuDisableKeys: [],
18902
- scrollContainerSelector: ""
18903
- }, options), {
18904
- header: headerOptions,
18905
- footer: footerOptions,
18906
- pageNumber: pageNumberOptions,
18907
- watermark: waterMarkOptions,
18908
- control: controlOptions,
18909
- checkbox: checkboxOptions,
18910
- radio: radioOptions,
18911
- cursor: cursorOptions,
18912
- title: titleOptions,
18913
- placeholder: placeholderOptions,
18914
- group: groupOptions,
18915
- pageBreak: pageBreakOptions,
18916
- zone: zoneOptions,
18917
- background: backgroundOptions,
18918
- lineBreak: lineBreakOptions,
18919
- separator: separatorOptions
18920
- });
19068
+ const editorOptions = mergeOption(options);
18921
19069
  data2 = deepClone(data2);
18922
19070
  let headerElementList = [];
18923
19071
  let mainElementList = [];