@hufe921/canvas-editor 0.9.56 → 0.9.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.56";
26
+ const version = "0.9.57";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -300,7 +300,7 @@ function isArrayEqual(arr1, arr2) {
300
300
  }
301
301
  return !arr1.some((item) => !arr2.includes(item));
302
302
  }
303
- const CURSOR_AGENT_HEIGHT = 12;
303
+ const CURSOR_AGENT_OFFSET_HEIGHT = 12;
304
304
  const defaultCursorOption = {
305
305
  width: 1,
306
306
  color: "#000000",
@@ -3766,7 +3766,6 @@ function formatElementList(elementList, options) {
3766
3766
  elementList.splice(i, 0, __spreadProps(__spreadValues({}, valueStyleList[valueStyleIndex]), {
3767
3767
  controlId,
3768
3768
  value: value2,
3769
- type: el.type,
3770
3769
  letterSpacing: isLastLetter ? checkboxOption.gap : 0,
3771
3770
  control: el.control,
3772
3771
  controlComponent: ControlComponent.VALUE
@@ -3797,7 +3796,7 @@ function formatElementList(elementList, options) {
3797
3796
  elementList.splice(i, 0, __spreadProps(__spreadValues({}, element), {
3798
3797
  controlId,
3799
3798
  value: value2,
3800
- type: el.type,
3799
+ type: element.type || ElementType.TEXT,
3801
3800
  control: el.control,
3802
3801
  controlComponent: ControlComponent.VALUE
3803
3802
  }));
@@ -4241,11 +4240,14 @@ function createDomFromElementList(elementList, options) {
4241
4240
  const tab = document.createElement("span");
4242
4241
  tab.innerHTML = `${NON_BREAKING_SPACE}${NON_BREAKING_SPACE}`;
4243
4242
  clipboardDom.append(tab);
4243
+ } else if (element.type === ElementType.CONTROL) {
4244
+ const controlElement = document.createElement("span");
4245
+ const childDom = buildDom(zipElementList(((_b = element.control) == null ? void 0 : _b.value) || []));
4246
+ controlElement.innerHTML = childDom.innerHTML;
4247
+ clipboardDom.append(controlElement);
4244
4248
  } else if (!element.type || element.type === ElementType.LATEX || TEXTLIKE_ELEMENT_TYPE.includes(element.type)) {
4245
4249
  let text = "";
4246
- if (element.controlId) {
4247
- text = ((_b = element.control.value) == null ? void 0 : _b.filter((v) => !v.type || TEXTLIKE_ELEMENT_TYPE.includes(v.type)).map((v) => v.value).join("")) || "";
4248
- } else if (element.type === ElementType.DATE) {
4250
+ if (element.type === ElementType.DATE) {
4249
4251
  text = ((_c = element.valueList) == null ? void 0 : _c.map((v) => v.value).join("")) || "";
4250
4252
  } else {
4251
4253
  text = element.value;
@@ -4797,8 +4799,9 @@ class Cursor {
4797
4799
  const zoneManager = this.draw.getZone();
4798
4800
  const curPageNo = zoneManager.isMainActive() ? pageNo : this.draw.getPageNo();
4799
4801
  const preY = curPageNo * (height + pageGap);
4800
- const offsetHeight = metrics.height / 4;
4801
- const cursorHeight = metrics.height + offsetHeight * 2;
4802
+ const defaultOffsetHeight = CURSOR_AGENT_OFFSET_HEIGHT * scale;
4803
+ const increaseHeight = Math.min(metrics.height / 4, defaultOffsetHeight);
4804
+ const cursorHeight = metrics.height + increaseHeight * 2;
4802
4805
  const agentCursorDom = this.cursorAgent.getAgentCursorDom();
4803
4806
  if (isFocus) {
4804
4807
  setTimeout(() => {
@@ -4807,14 +4810,14 @@ class Cursor {
4807
4810
  });
4808
4811
  }
4809
4812
  const descent = metrics.boundingBoxDescent < 0 ? 0 : metrics.boundingBoxDescent;
4810
- const cursorTop = leftTop[1] + ascent + descent - (cursorHeight - offsetHeight) + preY;
4813
+ const cursorTop = leftTop[1] + ascent + descent - (cursorHeight - increaseHeight) + preY;
4811
4814
  const cursorLeft = hitLineStartIndex ? leftTop[0] : rightTop[0];
4812
4815
  agentCursorDom.style.left = `${cursorLeft}px`;
4813
- agentCursorDom.style.top = `${cursorTop + cursorHeight - CURSOR_AGENT_HEIGHT * scale}px`;
4816
+ agentCursorDom.style.top = `${cursorTop + cursorHeight - defaultOffsetHeight}px`;
4814
4817
  if (!isShow)
4815
4818
  return;
4816
4819
  const isReadonly = this.draw.isReadonly();
4817
- this.cursorDom.style.width = `${width}px`;
4820
+ this.cursorDom.style.width = `${width * scale}px`;
4818
4821
  this.cursorDom.style.backgroundColor = color;
4819
4822
  this.cursorDom.style.left = `${cursorLeft}px`;
4820
4823
  this.cursorDom.style.top = `${cursorTop}px`;
@@ -5006,12 +5009,14 @@ class CheckboxControl {
5006
5009
  setValue() {
5007
5010
  return -1;
5008
5011
  }
5009
- setSelect(context = {}) {
5012
+ setSelect(codes, context = {}, options = {}) {
5013
+ if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
5014
+ return;
5015
+ }
5010
5016
  const { control } = this.element;
5011
5017
  const elementList = context.elementList || this.control.getElementList();
5012
5018
  const { startIndex } = context.range || this.control.getRange();
5013
5019
  const startElement = elementList[startIndex];
5014
- const data2 = [];
5015
5020
  let preIndex = startIndex;
5016
5021
  while (preIndex > 0) {
5017
5022
  const preElement = elementList[preIndex];
@@ -5020,9 +5025,7 @@ class CheckboxControl {
5020
5025
  }
5021
5026
  if (preElement.controlComponent === ControlComponent.CHECKBOX) {
5022
5027
  const checkbox = preElement.checkbox;
5023
- if (checkbox && checkbox.value && checkbox.code) {
5024
- data2.unshift(checkbox.code);
5025
- }
5028
+ checkbox.value = codes.includes(checkbox.code);
5026
5029
  }
5027
5030
  preIndex--;
5028
5031
  }
@@ -5034,15 +5037,17 @@ class CheckboxControl {
5034
5037
  }
5035
5038
  if (nextElement.controlComponent === ControlComponent.CHECKBOX) {
5036
5039
  const checkbox = nextElement.checkbox;
5037
- if (checkbox && checkbox.value && checkbox.code) {
5038
- data2.push(checkbox.code);
5039
- }
5040
+ checkbox.value = codes.includes(checkbox.code);
5040
5041
  }
5041
5042
  nextIndex++;
5042
5043
  }
5043
- control.code = data2.join(",");
5044
+ control.code = codes.join(",");
5045
+ this.control.repaintControl();
5044
5046
  }
5045
5047
  keydown(evt) {
5048
+ if (this.control.isDisabledControl()) {
5049
+ return null;
5050
+ }
5046
5051
  const range = this.control.getRange();
5047
5052
  this.control.shrinkBoundary();
5048
5053
  const { startIndex, endIndex } = range;
@@ -5056,6 +5061,7 @@ class CheckboxControl {
5056
5061
  }
5057
5062
  }
5058
5063
  function mousedown(evt, host) {
5064
+ var _a;
5059
5065
  if (evt.button === MouseEventButton.RIGHT)
5060
5066
  return;
5061
5067
  const draw = host.getDraw();
@@ -5102,26 +5108,28 @@ function mousedown(evt, host) {
5102
5108
  position.setCursorPosition(positionList[curIndex]);
5103
5109
  const isSetCheckbox = isDirectHitCheckbox && !isReadonly;
5104
5110
  if (isSetCheckbox) {
5105
- const { checkbox } = curElement;
5106
- if (checkbox) {
5107
- checkbox.value = !checkbox.value;
5111
+ const { checkbox, control } = curElement;
5112
+ const codes = ((_a = control == null ? void 0 : control.code) == null ? void 0 : _a.split(",")) || [];
5113
+ if (checkbox == null ? void 0 : checkbox.value) {
5114
+ const codeIndex = codes.findIndex((c) => c === checkbox.code);
5115
+ codes.splice(codeIndex, 1);
5108
5116
  } else {
5109
- curElement.checkbox = {
5110
- value: true
5111
- };
5117
+ if (checkbox == null ? void 0 : checkbox.code) {
5118
+ codes.push(checkbox.code);
5119
+ }
5112
5120
  }
5113
- const control = draw.getControl();
5114
- const activeControl = control.getActiveControl();
5121
+ const activeControl = draw.getControl().getActiveControl();
5115
5122
  if (activeControl instanceof CheckboxControl) {
5116
- activeControl.setSelect();
5123
+ activeControl.setSelect(codes);
5117
5124
  }
5125
+ } else {
5126
+ draw.render({
5127
+ curIndex,
5128
+ isCompute: false,
5129
+ isSubmitHistory: false,
5130
+ isSetCursor: !isDirectHitImage && !isDirectHitCheckbox
5131
+ });
5118
5132
  }
5119
- draw.render({
5120
- curIndex,
5121
- isSubmitHistory: isSetCheckbox,
5122
- isSetCursor: !isDirectHitImage && !isDirectHitCheckbox,
5123
- isCompute: false
5124
- });
5125
5133
  if (hitLineStartIndex) {
5126
5134
  host.getDraw().getCursor().drawCursor({
5127
5135
  hitLineStartIndex
@@ -5716,7 +5724,6 @@ function input(data2, host) {
5716
5724
  const cursor = draw.getCursor();
5717
5725
  cursor.clearAgentDomValue();
5718
5726
  }
5719
- const activeControl = control.getActiveControl();
5720
5727
  const { TEXT, HYPERLINK, SUBSCRIPT, SUPERSCRIPT, DATE } = ElementType;
5721
5728
  const text = data2.replaceAll(`
5722
5729
  `, ZERO);
@@ -5747,7 +5754,7 @@ function input(data2, host) {
5747
5754
  return newElement;
5748
5755
  });
5749
5756
  let curIndex;
5750
- if (activeControl && !control.isRangInPostfix()) {
5757
+ if (control.getActiveControl() && !control.isRangInPostfix()) {
5751
5758
  curIndex = control.setValue(inputData);
5752
5759
  } else {
5753
5760
  const start = startIndex + 1;
@@ -6148,7 +6155,7 @@ class CanvasEvent {
6148
6155
  mousedown(evt, this);
6149
6156
  }
6150
6157
  click() {
6151
- if (isIOS) {
6158
+ if (isIOS && !this.draw.isReadonly()) {
6152
6159
  this.draw.getCursor().getAgentDom().focus();
6153
6160
  }
6154
6161
  }
@@ -6988,6 +6995,35 @@ class RangeManager {
6988
6995
  }
6989
6996
  return false;
6990
6997
  }
6998
+ getKeywordRangeList(payload) {
6999
+ const searchMatchList = this.draw.getSearch().getMatchList(payload);
7000
+ const searchRangeMap = new Map();
7001
+ for (const searchMatch of searchMatchList) {
7002
+ const searchRange = searchRangeMap.get(searchMatch.groupId);
7003
+ if (searchRange) {
7004
+ searchRange.endIndex += 1;
7005
+ } else {
7006
+ const { type, groupId, tableId, index: index2, tdIndex, trIndex } = searchMatch;
7007
+ const range = {
7008
+ startIndex: index2 - 1,
7009
+ endIndex: index2
7010
+ };
7011
+ if (type === EditorContext.TABLE) {
7012
+ range.tableId = tableId;
7013
+ range.startTdIndex = tdIndex;
7014
+ range.endTdIndex = tdIndex;
7015
+ range.startTrIndex = trIndex;
7016
+ range.endTrIndex = trIndex;
7017
+ }
7018
+ searchRangeMap.set(groupId, range);
7019
+ }
7020
+ }
7021
+ const rangeList = [];
7022
+ searchRangeMap.forEach((searchRange) => {
7023
+ rangeList.push(searchRange);
7024
+ });
7025
+ return rangeList;
7026
+ }
6991
7027
  setRange(startIndex, endIndex, tableId, startTdIndex, endTdIndex, startTrIndex, endTrIndex) {
6992
7028
  this.range.startIndex = startIndex;
6993
7029
  this.range.endIndex = endIndex;
@@ -7431,7 +7467,7 @@ class Search {
7431
7467
  count
7432
7468
  };
7433
7469
  }
7434
- compute(payload) {
7470
+ getMatchList(payload) {
7435
7471
  const keyword = payload.toLocaleLowerCase();
7436
7472
  const searchMatchList = [];
7437
7473
  const elementListGroup = [];
@@ -7499,6 +7535,7 @@ class Search {
7499
7535
  for (let d = 0; d < tr.tdList.length; d++) {
7500
7536
  const td = tr.tdList[d];
7501
7537
  const restArgs = {
7538
+ tableId: tableElement.id,
7502
7539
  tableIndex: group2.index,
7503
7540
  trIndex: t,
7504
7541
  tdIndex: d,
@@ -7513,7 +7550,10 @@ class Search {
7513
7550
  });
7514
7551
  }
7515
7552
  }
7516
- this.searchMatchList = searchMatchList;
7553
+ return searchMatchList;
7554
+ }
7555
+ compute(payload) {
7556
+ this.searchMatchList = this.getMatchList(payload);
7517
7557
  }
7518
7558
  render(ctx, pageIndex) {
7519
7559
  var _a, _b;
@@ -8020,6 +8060,7 @@ class TableParticle {
8020
8060
  const isEmptyBorderType = borderType === TableBorder.EMPTY;
8021
8061
  const isExternalBorderType = borderType === TableBorder.EXTERNAL;
8022
8062
  ctx.save();
8063
+ ctx.lineWidth = scale;
8023
8064
  if (!isEmptyBorderType) {
8024
8065
  this._drawOuterBorder({
8025
8066
  ctx,
@@ -8686,30 +8727,41 @@ class Header {
8686
8727
  }
8687
8728
  }
8688
8729
  class SuperscriptParticle {
8730
+ getOffsetY(element) {
8731
+ return -element.metrics.height / 2;
8732
+ }
8689
8733
  render(ctx, element, x, y) {
8690
8734
  ctx.save();
8691
8735
  ctx.font = element.style;
8692
8736
  if (element.color) {
8693
8737
  ctx.fillStyle = element.color;
8694
8738
  }
8695
- ctx.fillText(element.value, x, y - element.metrics.height / 2);
8739
+ ctx.fillText(element.value, x, y + this.getOffsetY(element));
8696
8740
  ctx.restore();
8697
8741
  }
8698
8742
  }
8699
8743
  class SubscriptParticle {
8744
+ getOffsetY(element) {
8745
+ return element.metrics.height / 2;
8746
+ }
8700
8747
  render(ctx, element, x, y) {
8701
8748
  ctx.save();
8702
8749
  ctx.font = element.style;
8703
8750
  if (element.color) {
8704
8751
  ctx.fillStyle = element.color;
8705
8752
  }
8706
- ctx.fillText(element.value, x, y + element.metrics.height / 2);
8753
+ ctx.fillText(element.value, x, y + this.getOffsetY(element));
8707
8754
  ctx.restore();
8708
8755
  }
8709
8756
  }
8710
8757
  class SeparatorParticle {
8758
+ constructor(draw) {
8759
+ __publicField(this, "options");
8760
+ this.options = draw.getOptions();
8761
+ }
8711
8762
  render(ctx, element, x, y) {
8712
8763
  ctx.save();
8764
+ ctx.lineWidth = this.options.scale;
8713
8765
  if (element.color) {
8714
8766
  ctx.strokeStyle = element.color;
8715
8767
  }
@@ -8831,6 +8883,9 @@ class SelectControl {
8831
8883
  return -1;
8832
8884
  }
8833
8885
  keydown(evt) {
8886
+ if (this.control.isDisabledControl()) {
8887
+ return null;
8888
+ }
8834
8889
  const elementList = this.control.getElementList();
8835
8890
  const range = this.control.getRange();
8836
8891
  this.control.shrinkBoundary();
@@ -8862,6 +8917,9 @@ class SelectControl {
8862
8917
  return endIndex;
8863
8918
  }
8864
8919
  cut() {
8920
+ if (this.control.isDisabledControl()) {
8921
+ return -1;
8922
+ }
8865
8923
  this.control.shrinkBoundary();
8866
8924
  const { startIndex, endIndex } = this.control.getRange();
8867
8925
  if (startIndex === endIndex) {
@@ -8869,7 +8927,10 @@ class SelectControl {
8869
8927
  }
8870
8928
  return this.clearSelect();
8871
8929
  }
8872
- clearSelect(context = {}) {
8930
+ clearSelect(context = {}, options = {}) {
8931
+ if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
8932
+ return -1;
8933
+ }
8873
8934
  const elementList = context.elementList || this.control.getElementList();
8874
8935
  const { startIndex } = context.range || this.control.getRange();
8875
8936
  const startElement = elementList[startIndex];
@@ -8901,7 +8962,10 @@ class SelectControl {
8901
8962
  this.element.control.code = null;
8902
8963
  return preIndex;
8903
8964
  }
8904
- setSelect(code, context = {}) {
8965
+ setSelect(code, context = {}, options = {}) {
8966
+ if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
8967
+ return;
8968
+ }
8905
8969
  const control = this.element.control;
8906
8970
  const valueSets = control.valueSets;
8907
8971
  if (!Array.isArray(valueSets) || !valueSets.length)
@@ -8912,6 +8976,8 @@ class SelectControl {
8912
8976
  const elementList = context.elementList || this.control.getElementList();
8913
8977
  const styleElement = pickObject(this.getValue(context)[0], EDITOR_ELEMENT_STYLE_ATTR);
8914
8978
  const prefixIndex = this.clearSelect(context);
8979
+ if (!~prefixIndex)
8980
+ return;
8915
8981
  this.control.removePlaceholder(prefixIndex, context);
8916
8982
  const propertyElement = omitObject(elementList[prefixIndex], EDITOR_ELEMENT_STYLE_ATTR);
8917
8983
  const start = prefixIndex + 1;
@@ -8919,6 +8985,7 @@ class SelectControl {
8919
8985
  const draw = this.control.getDraw();
8920
8986
  for (let i = 0; i < data2.length; i++) {
8921
8987
  const newElement = __spreadProps(__spreadValues(__spreadValues({}, styleElement), propertyElement), {
8988
+ type: ElementType.TEXT,
8922
8989
  value: data2[i],
8923
8990
  controlComponent: ControlComponent.VALUE
8924
8991
  });
@@ -8968,7 +9035,7 @@ class SelectControl {
8968
9035
  }
8969
9036
  awake() {
8970
9037
  var _a;
8971
- if (this.isPopup)
9038
+ if (this.isPopup || this.control.isDisabledControl())
8972
9039
  return;
8973
9040
  const { startIndex } = this.control.getRange();
8974
9041
  const elementList = this.control.getElementList();
@@ -9025,7 +9092,10 @@ class TextControl {
9025
9092
  }
9026
9093
  return data2;
9027
9094
  }
9028
- setValue(data2, context = {}) {
9095
+ setValue(data2, context = {}, options = {}) {
9096
+ if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
9097
+ return -1;
9098
+ }
9029
9099
  const elementList = context.elementList || this.control.getElementList();
9030
9100
  const range = context.range || this.control.getRange();
9031
9101
  this.control.shrinkBoundary();
@@ -9048,7 +9118,10 @@ class TextControl {
9048
9118
  }
9049
9119
  return start + data2.length - 1;
9050
9120
  }
9051
- clearValue(context = {}) {
9121
+ clearValue(context = {}, options = {}) {
9122
+ if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
9123
+ return -1;
9124
+ }
9052
9125
  const elementList = context.elementList || this.control.getElementList();
9053
9126
  const range = context.range || this.control.getRange();
9054
9127
  const { startIndex, endIndex } = range;
@@ -9060,6 +9133,9 @@ class TextControl {
9060
9133
  return startIndex;
9061
9134
  }
9062
9135
  keydown(evt) {
9136
+ if (this.control.isDisabledControl()) {
9137
+ return null;
9138
+ }
9063
9139
  const elementList = this.control.getElementList();
9064
9140
  const range = this.control.getRange();
9065
9141
  this.control.shrinkBoundary();
@@ -9112,6 +9188,9 @@ class TextControl {
9112
9188
  return endIndex;
9113
9189
  }
9114
9190
  cut() {
9191
+ if (this.control.isDisabledControl()) {
9192
+ return -1;
9193
+ }
9115
9194
  this.control.shrinkBoundary();
9116
9195
  const { startIndex, endIndex } = this.control.getRange();
9117
9196
  if (startIndex === endIndex) {
@@ -9198,6 +9277,10 @@ class Control {
9198
9277
  }
9199
9278
  return false;
9200
9279
  }
9280
+ isDisabledControl() {
9281
+ var _a, _b;
9282
+ return !!((_b = (_a = this.activeControl) == null ? void 0 : _a.getElement().control) == null ? void 0 : _b.disabled);
9283
+ }
9201
9284
  getContainer() {
9202
9285
  return this.draw.getContainer();
9203
9286
  }
@@ -9291,10 +9374,17 @@ class Control {
9291
9374
  }
9292
9375
  }
9293
9376
  repaintControl(curIndex) {
9294
- this.range.setRange(curIndex, curIndex);
9295
- this.draw.render({
9296
- curIndex
9297
- });
9377
+ if (curIndex === void 0) {
9378
+ this.range.clearRange();
9379
+ this.draw.render({
9380
+ isSetCursor: false
9381
+ });
9382
+ } else {
9383
+ this.range.setRange(curIndex, curIndex);
9384
+ this.draw.render({
9385
+ curIndex
9386
+ });
9387
+ }
9298
9388
  }
9299
9389
  moveCursor(position) {
9300
9390
  const { index: index2, trIndex, tdIndex, tdValueIndex } = position;
@@ -9546,6 +9636,9 @@ class Control {
9546
9636
  range: fakeRange,
9547
9637
  elementList
9548
9638
  };
9639
+ const controlRule = {
9640
+ isIgnoreDisabledRule: true
9641
+ };
9549
9642
  if (type === ControlType.TEXT) {
9550
9643
  const formatValue = [{ value }];
9551
9644
  formatElementList(formatValue, {
@@ -9554,28 +9647,21 @@ class Control {
9554
9647
  });
9555
9648
  const text = new TextControl(element, this);
9556
9649
  if (value) {
9557
- text.setValue(formatValue, controlContext);
9650
+ text.setValue(formatValue, controlContext, controlRule);
9558
9651
  } else {
9559
- text.clearValue(controlContext);
9652
+ text.clearValue(controlContext, controlRule);
9560
9653
  }
9561
9654
  } else if (type === ControlType.SELECT) {
9562
9655
  const select = new SelectControl(element, this);
9563
9656
  if (value) {
9564
- select.setSelect(value, controlContext);
9657
+ select.setSelect(value, controlContext, controlRule);
9565
9658
  } else {
9566
- select.clearSelect(controlContext);
9659
+ select.clearSelect(controlContext, controlRule);
9567
9660
  }
9568
9661
  } else if (type === ControlType.CHECKBOX) {
9569
9662
  const checkbox = new CheckboxControl(element, this);
9570
- const checkboxElementList = elementList.slice(fakeRange.startIndex + 1, fakeRange.endIndex + 1);
9571
9663
  const codes = (value == null ? void 0 : value.split(",")) || [];
9572
- for (const checkElement of checkboxElementList) {
9573
- if (checkElement.controlComponent === ControlComponent.CHECKBOX) {
9574
- const checkboxItem = checkElement.checkbox;
9575
- checkboxItem.value = codes.includes(checkboxItem.code);
9576
- }
9577
- }
9578
- checkbox.setSelect(controlContext);
9664
+ checkbox.setSelect(codes, controlContext, controlRule);
9579
9665
  }
9580
9666
  let newEndIndex = i;
9581
9667
  while (newEndIndex < elementList.length) {
@@ -9653,7 +9739,7 @@ class CheckboxParticle {
9653
9739
  render(ctx, element, x, y) {
9654
9740
  const { checkbox: { gap, lineWidth, fillStyle, fontStyle }, scale } = this.options;
9655
9741
  const { metrics, checkbox } = element;
9656
- const left = Math.round(x + gap);
9742
+ const left = Math.round(x + gap * scale);
9657
9743
  const top = Math.round(y - metrics.height + lineWidth);
9658
9744
  const width = metrics.width - gap * 2 * scale;
9659
9745
  const height = metrics.height;
@@ -11636,7 +11722,7 @@ class Draw {
11636
11722
  this.footer = new Footer(this, data2.footer);
11637
11723
  this.hyperlinkParticle = new HyperlinkParticle(this);
11638
11724
  this.dateParticle = new DateParticle(this);
11639
- this.separatorParticle = new SeparatorParticle();
11725
+ this.separatorParticle = new SeparatorParticle(this);
11640
11726
  this.pageBreakParticle = new PageBreakParticle(this);
11641
11727
  this.superscriptParticle = new SuperscriptParticle();
11642
11728
  this.subscriptParticle = new SubscriptParticle();
@@ -11922,7 +12008,9 @@ class Draw {
11922
12008
  let curIndex = -1;
11923
12009
  const activeControl = this.control.getActiveControl();
11924
12010
  if (activeControl && !this.control.isRangInPostfix()) {
11925
- curIndex = activeControl.setValue(payload);
12011
+ curIndex = activeControl.setValue(payload, void 0, {
12012
+ isIgnoreDisabledRule: true
12013
+ });
11926
12014
  } else {
11927
12015
  const elementList = this.getElementList();
11928
12016
  const isCollapsed = startIndex === endIndex;
@@ -12384,7 +12472,7 @@ class Draw {
12384
12472
  const rowList2 = this.computeRowList((td.width - tdPaddingWidth) * scale, td.value);
12385
12473
  const rowHeight = rowList2.reduce((pre, cur) => pre + cur.height, 0);
12386
12474
  td.rowList = rowList2;
12387
- const curTdHeight = (rowHeight + tdPaddingHeight) / scale;
12475
+ const curTdHeight = rowHeight / scale + tdPaddingHeight;
12388
12476
  if (td.height < curTdHeight) {
12389
12477
  const extraHeight = curTdHeight - td.height;
12390
12478
  const changeTr = trList[t + td.rowspan - 1];
@@ -12439,7 +12527,7 @@ class Draw {
12439
12527
  metrics.width = elementWidth;
12440
12528
  metrics.height = elementHeight;
12441
12529
  metrics.boundingBoxDescent = elementHeight;
12442
- metrics.boundingBoxAscent = 0;
12530
+ metrics.boundingBoxAscent = -rowMargin;
12443
12531
  const height2 = this.getHeight();
12444
12532
  const marginHeight = this.getMainOuterHeight();
12445
12533
  let curPagePreHeight = marginHeight;
@@ -12747,10 +12835,19 @@ class Draw {
12747
12835
  }
12748
12836
  }
12749
12837
  if (element.underline || ((_a = element.control) == null ? void 0 : _a.underline)) {
12838
+ 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) {
12839
+ this.underline.render(ctx);
12840
+ }
12750
12841
  const rowMargin = defaultBasicRowMarginHeight * (element.rowMargin || defaultRowMargin) * scale;
12751
- const left = element.left || 0;
12842
+ const offsetX = element.left || 0;
12843
+ let offsetY2 = 0;
12844
+ if (element.type === ElementType.SUBSCRIPT) {
12845
+ offsetY2 = this.subscriptParticle.getOffsetY(element);
12846
+ } else if (element.type === ElementType.SUPERSCRIPT) {
12847
+ offsetY2 = this.superscriptParticle.getOffsetY(element);
12848
+ }
12752
12849
  const color = element.controlComponent === ControlComponent.PLACEHOLDER ? void 0 : element.color;
12753
- this.underline.recordFillInfo(ctx, x - left, y + curRow.height - rowMargin, metrics.width + left, 0, color);
12850
+ this.underline.recordFillInfo(ctx, x - offsetX, y + curRow.height - rowMargin + offsetY2, metrics.width + offsetX, 0, color);
12754
12851
  } else if ((preElement == null ? void 0 : preElement.underline) || ((_b = preElement == null ? void 0 : preElement.control) == null ? void 0 : _b.underline)) {
12755
12852
  this.underline.render(ctx);
12756
12853
  }
@@ -13031,6 +13128,8 @@ class Command {
13031
13128
  __publicField(this, "executeSelectAll");
13032
13129
  __publicField(this, "executeBackspace");
13033
13130
  __publicField(this, "executeSetRange");
13131
+ __publicField(this, "executeReplaceRange");
13132
+ __publicField(this, "executeSetPositionContext");
13034
13133
  __publicField(this, "executeForceUpdate");
13035
13134
  __publicField(this, "executeBlur");
13036
13135
  __publicField(this, "executeUndo");
@@ -13105,6 +13204,7 @@ class Command {
13105
13204
  __publicField(this, "executeSetGroup");
13106
13205
  __publicField(this, "executeDeleteGroup");
13107
13206
  __publicField(this, "executeLocationGroup");
13207
+ __publicField(this, "executeSetZone");
13108
13208
  __publicField(this, "executeSetControlValue");
13109
13209
  __publicField(this, "executeSetControlExtension");
13110
13210
  __publicField(this, "getCatalog");
@@ -13118,6 +13218,7 @@ class Command {
13118
13218
  __publicField(this, "getRangeContext");
13119
13219
  __publicField(this, "getRangeRow");
13120
13220
  __publicField(this, "getRangeParagraph");
13221
+ __publicField(this, "getKeywordRangeList");
13121
13222
  __publicField(this, "getPaperMargin");
13122
13223
  __publicField(this, "getSearchNavigateInfo");
13123
13224
  __publicField(this, "getLocale");
@@ -13131,6 +13232,8 @@ class Command {
13131
13232
  this.executeSelectAll = adapt.selectAll.bind(adapt);
13132
13233
  this.executeBackspace = adapt.backspace.bind(adapt);
13133
13234
  this.executeSetRange = adapt.setRange.bind(adapt);
13235
+ this.executeReplaceRange = adapt.replaceRange.bind(adapt);
13236
+ this.executeSetPositionContext = adapt.setPositionContext.bind(adapt);
13134
13237
  this.executeForceUpdate = adapt.forceUpdate.bind(adapt);
13135
13238
  this.executeBlur = adapt.blur.bind(adapt);
13136
13239
  this.executeUndo = adapt.undo.bind(adapt);
@@ -13205,6 +13308,7 @@ class Command {
13205
13308
  this.executeSetGroup = adapt.setGroup.bind(adapt);
13206
13309
  this.executeDeleteGroup = adapt.deleteGroup.bind(adapt);
13207
13310
  this.executeLocationGroup = adapt.locationGroup.bind(adapt);
13311
+ this.executeSetZone = adapt.setZone.bind(adapt);
13208
13312
  this.getImage = adapt.getImage.bind(adapt);
13209
13313
  this.getOptions = adapt.getOptions.bind(adapt);
13210
13314
  this.getValue = adapt.getValue.bind(adapt);
@@ -13215,6 +13319,7 @@ class Command {
13215
13319
  this.getRangeContext = adapt.getRangeContext.bind(adapt);
13216
13320
  this.getRangeRow = adapt.getRangeRow.bind(adapt);
13217
13321
  this.getRangeParagraph = adapt.getRangeParagraph.bind(adapt);
13322
+ this.getKeywordRangeList = adapt.getKeywordRangeList.bind(adapt);
13218
13323
  this.getCatalog = adapt.getCatalog.bind(adapt);
13219
13324
  this.getPaperMargin = adapt.getPaperMargin.bind(adapt);
13220
13325
  this.getSearchNavigateInfo = adapt.getSearchNavigateInfo.bind(adapt);
@@ -13339,10 +13444,10 @@ class CommandAdapt {
13339
13444
  this.range.setRange(curIndex, curIndex);
13340
13445
  this.draw.render({ curIndex });
13341
13446
  }
13342
- setRange(startIndex, endIndex) {
13447
+ setRange(startIndex, endIndex, tableId, startTdIndex, endTdIndex, startTrIndex, endTrIndex) {
13343
13448
  if (startIndex < 0 || endIndex < 0 || endIndex < startIndex)
13344
13449
  return;
13345
- this.range.setRange(startIndex, endIndex);
13450
+ this.range.setRange(startIndex, endIndex, tableId, startTdIndex, endTdIndex, startTrIndex, endTrIndex);
13346
13451
  const isCollapsed = startIndex === endIndex;
13347
13452
  this.draw.render({
13348
13453
  curIndex: isCollapsed ? startIndex : void 0,
@@ -13351,6 +13456,34 @@ class CommandAdapt {
13351
13456
  isSetCursor: isCollapsed
13352
13457
  });
13353
13458
  }
13459
+ replaceRange(range) {
13460
+ this.setRange(range.startIndex, range.endIndex, range.tableId, range.startTdIndex, range.endTdIndex, range.startTrIndex, range.endTrIndex);
13461
+ }
13462
+ setPositionContext(range) {
13463
+ const { tableId, startTrIndex, startTdIndex } = range;
13464
+ const elementList = this.draw.getOriginalElementList();
13465
+ if (tableId) {
13466
+ const tableElementIndex = elementList.findIndex((el) => el.id === tableId);
13467
+ if (!~tableElementIndex)
13468
+ return;
13469
+ const tableElement = elementList[tableElementIndex];
13470
+ const tr = tableElement.trList[startTrIndex];
13471
+ const td = tr.tdList[startTdIndex];
13472
+ this.position.setPositionContext({
13473
+ isTable: true,
13474
+ index: tableElementIndex,
13475
+ trIndex: startTrIndex,
13476
+ tdIndex: startTdIndex,
13477
+ tdId: td.id,
13478
+ trId: tr.id,
13479
+ tableId
13480
+ });
13481
+ } else {
13482
+ this.position.setPositionContext({
13483
+ isTable: false
13484
+ });
13485
+ }
13486
+ }
13354
13487
  forceUpdate(options) {
13355
13488
  const { isSubmitHistory = false } = options || {};
13356
13489
  this.range.clearRange();
@@ -13376,9 +13509,6 @@ class CommandAdapt {
13376
13509
  this.historyManager.redo();
13377
13510
  }
13378
13511
  painter(options) {
13379
- const isReadonly = this.draw.isReadonly();
13380
- if (isReadonly)
13381
- return;
13382
13512
  const selection = this.range.getSelection();
13383
13513
  if (!selection)
13384
13514
  return;
@@ -13395,11 +13525,14 @@ class CommandAdapt {
13395
13525
  this.draw.setPainterStyle(painterStyle, options);
13396
13526
  }
13397
13527
  applyPainterStyle() {
13528
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13529
+ if (isDisabled)
13530
+ return;
13398
13531
  this.canvasEvent.applyPainterStyle();
13399
13532
  }
13400
13533
  format() {
13401
- const isReadonly = this.draw.isReadonly();
13402
- if (isReadonly)
13534
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13535
+ if (isDisabled)
13403
13536
  return;
13404
13537
  const selection = this.range.getSelectionElementList();
13405
13538
  if (!selection)
@@ -13415,8 +13548,8 @@ class CommandAdapt {
13415
13548
  this.draw.render({ isSetCursor: false });
13416
13549
  }
13417
13550
  font(payload) {
13418
- const isReadonly = this.draw.isReadonly();
13419
- if (isReadonly)
13551
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13552
+ if (isDisabled)
13420
13553
  return;
13421
13554
  const selection = this.range.getSelectionElementList();
13422
13555
  if (!selection)
@@ -13430,8 +13563,8 @@ class CommandAdapt {
13430
13563
  const { minSize, maxSize, defaultSize } = this.options;
13431
13564
  if (payload < minSize || payload > maxSize)
13432
13565
  return;
13433
- const isReadonly = this.draw.isReadonly();
13434
- if (isReadonly)
13566
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13567
+ if (isDisabled)
13435
13568
  return;
13436
13569
  const selection = this.range.getTextLikeSelectionElementList();
13437
13570
  if (!selection || !selection.length)
@@ -13449,8 +13582,8 @@ class CommandAdapt {
13449
13582
  }
13450
13583
  }
13451
13584
  sizeAdd() {
13452
- const isReadonly = this.draw.isReadonly();
13453
- if (isReadonly)
13585
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13586
+ if (isDisabled)
13454
13587
  return;
13455
13588
  const selection = this.range.getTextLikeSelectionElementList();
13456
13589
  if (!selection || !selection.length)
@@ -13475,8 +13608,8 @@ class CommandAdapt {
13475
13608
  }
13476
13609
  }
13477
13610
  sizeMinus() {
13478
- const isReadonly = this.draw.isReadonly();
13479
- if (isReadonly)
13611
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13612
+ if (isDisabled)
13480
13613
  return;
13481
13614
  const selection = this.range.getTextLikeSelectionElementList();
13482
13615
  if (!selection || !selection.length)
@@ -13501,8 +13634,8 @@ class CommandAdapt {
13501
13634
  }
13502
13635
  }
13503
13636
  bold() {
13504
- const isReadonly = this.draw.isReadonly();
13505
- if (isReadonly)
13637
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13638
+ if (isDisabled)
13506
13639
  return;
13507
13640
  const selection = this.range.getSelectionElementList();
13508
13641
  if (!selection)
@@ -13514,8 +13647,8 @@ class CommandAdapt {
13514
13647
  this.draw.render({ isSetCursor: false });
13515
13648
  }
13516
13649
  italic() {
13517
- const isReadonly = this.draw.isReadonly();
13518
- if (isReadonly)
13650
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13651
+ if (isDisabled)
13519
13652
  return;
13520
13653
  const selection = this.range.getSelectionElementList();
13521
13654
  if (!selection)
@@ -13527,8 +13660,8 @@ class CommandAdapt {
13527
13660
  this.draw.render({ isSetCursor: false });
13528
13661
  }
13529
13662
  underline() {
13530
- const isReadonly = this.draw.isReadonly();
13531
- if (isReadonly)
13663
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13664
+ if (isDisabled)
13532
13665
  return;
13533
13666
  const selection = this.range.getSelectionElementList();
13534
13667
  if (!selection)
@@ -13543,8 +13676,8 @@ class CommandAdapt {
13543
13676
  });
13544
13677
  }
13545
13678
  strikeout() {
13546
- const isReadonly = this.draw.isReadonly();
13547
- if (isReadonly)
13679
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13680
+ if (isDisabled)
13548
13681
  return;
13549
13682
  const selection = this.range.getSelectionElementList();
13550
13683
  if (!selection)
@@ -13559,8 +13692,8 @@ class CommandAdapt {
13559
13692
  });
13560
13693
  }
13561
13694
  superscript() {
13562
- const isReadonly = this.draw.isReadonly();
13563
- if (isReadonly)
13695
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13696
+ if (isDisabled)
13564
13697
  return;
13565
13698
  const selection = this.range.getSelectionElementList();
13566
13699
  if (!selection)
@@ -13581,8 +13714,8 @@ class CommandAdapt {
13581
13714
  this.draw.render({ isSetCursor: false });
13582
13715
  }
13583
13716
  subscript() {
13584
- const isReadonly = this.draw.isReadonly();
13585
- if (isReadonly)
13717
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13718
+ if (isDisabled)
13586
13719
  return;
13587
13720
  const selection = this.range.getSelectionElementList();
13588
13721
  if (!selection)
@@ -13603,8 +13736,8 @@ class CommandAdapt {
13603
13736
  this.draw.render({ isSetCursor: false });
13604
13737
  }
13605
13738
  color(payload) {
13606
- const isReadonly = this.draw.isReadonly();
13607
- if (isReadonly)
13739
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13740
+ if (isDisabled)
13608
13741
  return;
13609
13742
  const selection = this.range.getSelectionElementList();
13610
13743
  if (!selection)
@@ -13618,8 +13751,8 @@ class CommandAdapt {
13618
13751
  });
13619
13752
  }
13620
13753
  highlight(payload) {
13621
- const isReadonly = this.draw.isReadonly();
13622
- if (isReadonly)
13754
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
13755
+ if (isDisabled)
13623
13756
  return;
13624
13757
  const selection = this.range.getSelectionElementList();
13625
13758
  if (!selection)
@@ -14510,6 +14643,9 @@ class CommandAdapt {
14510
14643
  return [leftIndex, rightIndex];
14511
14644
  }
14512
14645
  deleteHyperlink() {
14646
+ const isReadonly = this.draw.isReadonly();
14647
+ if (isReadonly)
14648
+ return;
14513
14649
  const hyperRange = this.getHyperlinkRange();
14514
14650
  if (!hyperRange)
14515
14651
  return;
@@ -14524,6 +14660,9 @@ class CommandAdapt {
14524
14660
  });
14525
14661
  }
14526
14662
  cancelHyperlink() {
14663
+ const isReadonly = this.draw.isReadonly();
14664
+ if (isReadonly)
14665
+ return;
14527
14666
  const hyperRange = this.getHyperlinkRange();
14528
14667
  if (!hyperRange)
14529
14668
  return;
@@ -14544,6 +14683,9 @@ class CommandAdapt {
14544
14683
  });
14545
14684
  }
14546
14685
  editHyperlink(payload) {
14686
+ const isReadonly = this.draw.isReadonly();
14687
+ if (isReadonly)
14688
+ return;
14547
14689
  const hyperRange = this.getHyperlinkRange();
14548
14690
  if (!hyperRange)
14549
14691
  return;
@@ -14643,8 +14785,8 @@ class CommandAdapt {
14643
14785
  }
14644
14786
  }
14645
14787
  image(payload) {
14646
- const isReadonly = this.draw.isReadonly();
14647
- if (isReadonly)
14788
+ const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
14789
+ if (isDisabled)
14648
14790
  return;
14649
14791
  const activeControl = this.control.getActiveControl();
14650
14792
  if (activeControl)
@@ -14946,6 +15088,9 @@ class CommandAdapt {
14946
15088
  const paragraphElementList = this.range.getRangeParagraphElementList();
14947
15089
  return paragraphElementList ? zipElementList(paragraphElementList) : null;
14948
15090
  }
15091
+ getKeywordRangeList(payload) {
15092
+ return this.range.getKeywordRangeList(payload);
15093
+ }
14949
15094
  pageMode(payload) {
14950
15095
  this.draw.setPageMode(payload);
14951
15096
  }
@@ -15125,6 +15270,9 @@ class CommandAdapt {
15125
15270
  isSubmitHistory: false
15126
15271
  });
15127
15272
  }
15273
+ setZone(zone) {
15274
+ this.draw.getZone().setZone(zone);
15275
+ }
15128
15276
  getControlValue(payload) {
15129
15277
  return this.draw.getControl().getValueByConceptId(payload);
15130
15278
  }