@hufe921/canvas-editor 0.9.91 → 0.9.92

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.91";
26
+ const version = "0.9.92";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -477,6 +477,8 @@ const EDITOR_ELEMENT_ZIP_ATTR = [
477
477
  ];
478
478
  const TABLE_TD_ZIP_ATTR = [
479
479
  "conceptId",
480
+ "extension",
481
+ "externalId",
480
482
  "verticalAlign",
481
483
  "backgroundColor",
482
484
  "borderTypes",
@@ -4356,10 +4358,11 @@ function formatElementContext(sourceElementList, formatElementList2, anchorIndex
4356
4358
  let copyElement = getAnchorElement(sourceElementList, anchorIndex);
4357
4359
  if (!copyElement)
4358
4360
  return;
4359
- if ((_a = copyElement.title) == null ? void 0 : _a.disabled) {
4361
+ const { isBreakWhenWrap = false, editorOptions } = options || {};
4362
+ const { mode } = editorOptions || {};
4363
+ if (mode !== EditorMode.DESIGN && ((_a = copyElement.title) == null ? void 0 : _a.disabled)) {
4360
4364
  copyElement = omitObject(copyElement, TITLE_CONTEXT_ATTR);
4361
4365
  }
4362
- const { isBreakWhenWrap = false } = options || {};
4363
4366
  let isBreakWarped = false;
4364
4367
  for (let e = 0; e < formatElementList2.length; e++) {
4365
4368
  const targetElement = formatElementList2[e];
@@ -4375,7 +4378,7 @@ function formatElementContext(sourceElementList, formatElementList2, anchorIndex
4375
4378
  continue;
4376
4379
  }
4377
4380
  if ((_c = targetElement.valueList) == null ? void 0 : _c.length) {
4378
- formatElementContext(sourceElementList, targetElement.valueList, anchorIndex);
4381
+ formatElementContext(sourceElementList, targetElement.valueList, anchorIndex, options);
4379
4382
  }
4380
4383
  const cloneAttr = [...EDITOR_ELEMENT_CONTEXT_ATTR];
4381
4384
  if (!getIsBlockElement(targetElement)) {
@@ -5028,7 +5031,8 @@ function pasteElement(host, elementList) {
5028
5031
  }
5029
5032
  }
5030
5033
  formatElementContext(originalElementList, elementList, startIndex, {
5031
- isBreakWhenWrap: true
5034
+ isBreakWhenWrap: true,
5035
+ editorOptions: draw.getOptions()
5032
5036
  });
5033
5037
  }
5034
5038
  draw.insertElementList(elementList);
@@ -5063,7 +5067,9 @@ function pasteImage(host, file) {
5063
5067
  height: image.height
5064
5068
  };
5065
5069
  if (~startIndex) {
5066
- formatElementContext(elementList, [imageElement], startIndex);
5070
+ formatElementContext(elementList, [imageElement], startIndex, {
5071
+ editorOptions: draw.getOptions()
5072
+ });
5067
5073
  }
5068
5074
  draw.insertElementList([imageElement]);
5069
5075
  };
@@ -5391,6 +5397,7 @@ var EditorMode;
5391
5397
  EditorMode2["READONLY"] = "readonly";
5392
5398
  EditorMode2["FORM"] = "form";
5393
5399
  EditorMode2["PRINT"] = "print";
5400
+ EditorMode2["DESIGN"] = "design";
5394
5401
  })(EditorMode || (EditorMode = {}));
5395
5402
  var EditorZone;
5396
5403
  (function(EditorZone2) {
@@ -5595,7 +5602,10 @@ class CheckboxControl {
5595
5602
  nextIndex++;
5596
5603
  }
5597
5604
  control.code = codes.join(",");
5598
- this.control.repaintControl();
5605
+ this.control.repaintControl({
5606
+ curIndex: startIndex,
5607
+ isSetCursor: false
5608
+ });
5599
5609
  }
5600
5610
  keydown(evt) {
5601
5611
  if (this.control.getIsDisabledControl()) {
@@ -5647,7 +5657,10 @@ class RadioControl extends CheckboxControl {
5647
5657
  nextIndex++;
5648
5658
  }
5649
5659
  control.code = codes.join(",");
5650
- this.control.repaintControl();
5660
+ this.control.repaintControl({
5661
+ curIndex: startIndex,
5662
+ isSetCursor: false
5663
+ });
5651
5664
  }
5652
5665
  }
5653
5666
  function setRangeCache(host) {
@@ -5935,7 +5948,9 @@ function mouseup(evt, host) {
5935
5948
  return newElement;
5936
5949
  }
5937
5950
  });
5938
- formatElementContext(elementList, replaceElementList, range.startIndex);
5951
+ formatElementContext(elementList, replaceElementList, range.startIndex, {
5952
+ editorOptions: draw.getOptions()
5953
+ });
5939
5954
  const cacheStartElement = cacheElementList[cacheStartIndex];
5940
5955
  const cacheStartPosition = cachePositionList[cacheStartIndex];
5941
5956
  const cacheRangeStartId = createDragId(cacheElementList[cacheStartIndex]);
@@ -6264,7 +6279,8 @@ function enter(evt, host) {
6264
6279
  enterText.listWrap = true;
6265
6280
  }
6266
6281
  formatElementContext(elementList, [enterText], startIndex, {
6267
- isBreakWhenWrap: true
6282
+ isBreakWhenWrap: true,
6283
+ editorOptions: draw.getOptions()
6268
6284
  });
6269
6285
  if (!(endElement.titleId && endElement.titleId !== ((_b = elementList[endIndex + 1]) == null ? void 0 : _b.titleId))) {
6270
6286
  const copyElement = getAnchorElement(elementList, endIndex);
@@ -6604,7 +6620,9 @@ function tab(evt, host) {
6604
6620
  const rangeManager = draw.getRange();
6605
6621
  const { startIndex } = rangeManager.getRange();
6606
6622
  const elementList = draw.getElementList();
6607
- formatElementContext(elementList, [tabElement], startIndex);
6623
+ formatElementContext(elementList, [tabElement], startIndex, {
6624
+ editorOptions: draw.getOptions()
6625
+ });
6608
6626
  draw.insertElementList([tabElement]);
6609
6627
  }
6610
6628
  }
@@ -6980,12 +6998,13 @@ function input(data2, host) {
6980
6998
  const copyElement = getAnchorElement(elementList, endIndex);
6981
6999
  if (!copyElement)
6982
7000
  return;
7001
+ const isDesignMode = draw.isDesignMode();
6983
7002
  const inputData = splitText(text).map((value) => {
6984
7003
  var _a2, _b;
6985
7004
  const newElement = {
6986
7005
  value
6987
7006
  };
6988
- if (!((_a2 = copyElement.title) == null ? void 0 : _a2.disabled) && !((_b = copyElement.control) == null ? void 0 : _b.disabled)) {
7007
+ if (isDesignMode || !((_a2 = copyElement.title) == null ? void 0 : _a2.disabled) && !((_b = copyElement.control) == null ? void 0 : _b.disabled)) {
6989
7008
  const nextElement = elementList[endIndex + 1];
6990
7009
  if (!copyElement.type || copyElement.type === TEXT || copyElement.type === HYPERLINK && (nextElement == null ? void 0 : nextElement.type) === HYPERLINK || copyElement.type === DATE && (nextElement == null ? void 0 : nextElement.type) === DATE || copyElement.type === SUBSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUBSCRIPT || copyElement.type === SUPERSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUPERSCRIPT) {
6991
7010
  EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
@@ -7012,7 +7031,9 @@ function input(data2, host) {
7012
7031
  if (startIndex !== endIndex) {
7013
7032
  draw.spliceElementList(elementList, start, endIndex - startIndex);
7014
7033
  }
7015
- formatElementContext(elementList, inputData, startIndex);
7034
+ formatElementContext(elementList, inputData, startIndex, {
7035
+ editorOptions: draw.getOptions()
7036
+ });
7016
7037
  draw.spliceElementList(elementList, start, 0, ...inputData);
7017
7038
  curIndex = startIndex + inputData.length;
7018
7039
  }
@@ -7715,6 +7736,7 @@ class Position {
7715
7736
  __publicField(this, "positionList");
7716
7737
  __publicField(this, "floatPositionList");
7717
7738
  __publicField(this, "draw");
7739
+ __publicField(this, "eventBus");
7718
7740
  __publicField(this, "options");
7719
7741
  this.positionList = [];
7720
7742
  this.floatPositionList = [];
@@ -7724,6 +7746,7 @@ class Position {
7724
7746
  isControl: false
7725
7747
  };
7726
7748
  this.draw = draw;
7749
+ this.eventBus = draw.getEventBus();
7727
7750
  this.options = draw.getOptions();
7728
7751
  }
7729
7752
  getFloatPositionList() {
@@ -7940,6 +7963,10 @@ class Position {
7940
7963
  return this.positionContext;
7941
7964
  }
7942
7965
  setPositionContext(payload) {
7966
+ this.eventBus.emit("positionContextChange", {
7967
+ value: payload,
7968
+ oldValue: this.positionContext
7969
+ });
7943
7970
  this.positionContext = payload;
7944
7971
  }
7945
7972
  getPositionByXY(payload) {
@@ -10701,6 +10728,8 @@ class SelectControl {
10701
10728
  __publicField(this, "control");
10702
10729
  __publicField(this, "isPopup");
10703
10730
  __publicField(this, "selectDom");
10731
+ __publicField(this, "options");
10732
+ this.options = control.getDraw().getOptions();
10704
10733
  this.element = element;
10705
10734
  this.control = control;
10706
10735
  this.isPopup = false;
@@ -10877,7 +10906,9 @@ class SelectControl {
10877
10906
  value: data2[i],
10878
10907
  controlComponent: ControlComponent.VALUE
10879
10908
  });
10880
- formatElementContext(elementList, [newElement], prefixIndex);
10909
+ formatElementContext(elementList, [newElement], prefixIndex, {
10910
+ editorOptions: this.options
10911
+ });
10881
10912
  draw.spliceElementList(elementList, start + i, 0, newElement);
10882
10913
  }
10883
10914
  control.code = code;
@@ -10947,6 +10978,8 @@ class TextControl {
10947
10978
  constructor(element, control) {
10948
10979
  __publicField(this, "element");
10949
10980
  __publicField(this, "control");
10981
+ __publicField(this, "options");
10982
+ this.options = control.getDraw().getOptions();
10950
10983
  this.element = element;
10951
10984
  this.control = control;
10952
10985
  }
@@ -11010,7 +11043,9 @@ class TextControl {
11010
11043
  const newElement = __spreadProps(__spreadValues(__spreadValues({}, anchorElement), data2[i]), {
11011
11044
  controlComponent: ControlComponent.VALUE
11012
11045
  });
11013
- formatElementContext(elementList, [newElement], startIndex);
11046
+ formatElementContext(elementList, [newElement], startIndex, {
11047
+ editorOptions: this.options
11048
+ });
11014
11049
  draw.spliceElementList(elementList, start + i, 0, newElement);
11015
11050
  }
11016
11051
  return start + data2.length - 1;
@@ -11568,8 +11603,10 @@ class DateControl {
11568
11603
  __publicField(this, "control");
11569
11604
  __publicField(this, "isPopup");
11570
11605
  __publicField(this, "datePicker");
11606
+ __publicField(this, "options");
11571
11607
  const draw = control.getDraw();
11572
11608
  this.draw = draw;
11609
+ this.options = draw.getOptions();
11573
11610
  this.element = element;
11574
11611
  this.control = control;
11575
11612
  this.isPopup = false;
@@ -11648,7 +11685,9 @@ class DateControl {
11648
11685
  const newElement = __spreadProps(__spreadValues(__spreadValues({}, anchorElement), data2[i]), {
11649
11686
  controlComponent: ControlComponent.VALUE
11650
11687
  });
11651
- formatElementContext(elementList, [newElement], startIndex);
11688
+ formatElementContext(elementList, [newElement], startIndex, {
11689
+ editorOptions: this.options
11690
+ });
11652
11691
  draw.spliceElementList(elementList, start + i, 0, newElement);
11653
11692
  }
11654
11693
  return start + data2.length - 1;
@@ -11694,7 +11733,9 @@ class DateControl {
11694
11733
  value: date[i],
11695
11734
  controlComponent: ControlComponent.VALUE
11696
11735
  });
11697
- formatElementContext(elementList, [newElement], prefixIndex);
11736
+ formatElementContext(elementList, [newElement], prefixIndex, {
11737
+ editorOptions: this.options
11738
+ });
11698
11739
  draw.spliceElementList(elementList, start + i, 0, newElement);
11699
11740
  }
11700
11741
  if (!context.range) {
@@ -11939,7 +11980,7 @@ class Control {
11939
11980
  }
11940
11981
  getIsDisabledControl(context = {}) {
11941
11982
  var _a, _b;
11942
- if (!this.activeControl)
11983
+ if (this.draw.isDesignMode() || !this.activeControl)
11943
11984
  return false;
11944
11985
  const { startIndex, endIndex } = context.range || this.range.getRange();
11945
11986
  if (startIndex === endIndex && ~startIndex && ~endIndex) {
@@ -12056,7 +12097,7 @@ class Control {
12056
12097
  }
12057
12098
  }
12058
12099
  repaintControl(options = {}) {
12059
- const { curIndex, isCompute = true, isSubmitHistory = true } = options;
12100
+ const { curIndex, isCompute = true, isSubmitHistory = true, isSetCursor = true } = options;
12060
12101
  if (curIndex === void 0) {
12061
12102
  this.range.clearRange();
12062
12103
  this.draw.render({
@@ -12069,6 +12110,7 @@ class Control {
12069
12110
  this.draw.render({
12070
12111
  curIndex,
12071
12112
  isCompute,
12113
+ isSetCursor,
12072
12114
  isSubmitHistory
12073
12115
  });
12074
12116
  }
@@ -12146,9 +12188,11 @@ class Control {
12146
12188
  removeControl(startIndex, context = {}) {
12147
12189
  const elementList = context.elementList || this.getElementList();
12148
12190
  const startElement = elementList[startIndex];
12149
- const { deletable = true } = startElement.control;
12150
- if (!deletable)
12151
- return null;
12191
+ if (!this.draw.isDesignMode()) {
12192
+ const { deletable = true } = startElement.control;
12193
+ if (!deletable)
12194
+ return null;
12195
+ }
12152
12196
  let leftIndex = -1;
12153
12197
  let rightIndex = -1;
12154
12198
  let preIndex = startIndex;
@@ -12220,7 +12264,9 @@ class Control {
12220
12264
  controlComponent: ControlComponent.PLACEHOLDER,
12221
12265
  color: this.controlOptions.placeholderColor
12222
12266
  });
12223
- formatElementContext(elementList, [newElement], startIndex);
12267
+ formatElementContext(elementList, [newElement], startIndex, {
12268
+ editorOptions: this.options
12269
+ });
12224
12270
  this.draw.spliceElementList(elementList, startIndex + p + 1, 0, newElement);
12225
12271
  }
12226
12272
  }
@@ -13109,10 +13155,12 @@ class Previewer {
13109
13155
  return { x, y };
13110
13156
  }
13111
13157
  _createResizerDom() {
13158
+ const { scale } = this.options;
13112
13159
  const resizerSelection = document.createElement("div");
13113
13160
  resizerSelection.classList.add(`${EDITOR_PREFIX}-resizer-selection`);
13114
13161
  resizerSelection.style.display = "none";
13115
13162
  resizerSelection.style.borderColor = this.options.resizerColor;
13163
+ resizerSelection.style.borderWidth = `${scale}px`;
13116
13164
  const resizerHandleList = [];
13117
13165
  for (let i = 0; i < 8; i++) {
13118
13166
  const handleDom = document.createElement("div");
@@ -13365,12 +13413,13 @@ class Previewer {
13365
13413
  document.body.style.overflow = "auto";
13366
13414
  }
13367
13415
  _updateResizerRect(width, height) {
13368
- const handleSize = this.options.resizerSize;
13416
+ const { resizerSize: handleSize, scale } = this.options;
13369
13417
  this.resizerSelection.style.width = `${width}px`;
13370
13418
  this.resizerSelection.style.height = `${height}px`;
13371
13419
  for (let i = 0; i < 8; i++) {
13372
13420
  const left2 = i === 0 || i === 6 || i === 7 ? -handleSize : i === 1 || i === 5 ? width / 2 : width - handleSize;
13373
13421
  const top = i === 0 || i === 1 || i === 2 ? -handleSize : i === 3 || i === 7 ? height / 2 - handleSize : height - handleSize;
13422
+ this.resizerHandleList[i].style.transform = `scale(${scale})`;
13374
13423
  this.resizerHandleList[i].style.left = `${left2}px`;
13375
13424
  this.resizerHandleList[i].style.top = `${top}px`;
13376
13425
  }
@@ -13396,6 +13445,7 @@ class Previewer {
13396
13445
  const { x: resizerLeft, y: resizerTop } = this._getElementPosition(element, position);
13397
13446
  this.resizerSelection.style.left = `${resizerLeft}px`;
13398
13447
  this.resizerSelection.style.top = `${resizerTop}px`;
13448
+ this.resizerSelection.style.borderWidth = `${scale}px`;
13399
13449
  this._updateResizerRect(elementWidth, elementHeight);
13400
13450
  this.resizerSelection.style.display = "block";
13401
13451
  this.curElement = element;
@@ -13413,7 +13463,9 @@ class DateParticle {
13413
13463
  __publicField(this, "draw");
13414
13464
  __publicField(this, "range");
13415
13465
  __publicField(this, "datePicker");
13466
+ __publicField(this, "options");
13416
13467
  this.draw = draw;
13468
+ this.options = draw.getOptions();
13417
13469
  this.range = draw.getRange();
13418
13470
  this.datePicker = new DatePicker(draw, {
13419
13471
  onSubmit: this._setValue.bind(this)
@@ -13440,7 +13492,9 @@ class DateParticle {
13440
13492
  }
13441
13493
  ]
13442
13494
  };
13443
- formatElementContext(elementList, [dateElement], leftIndex);
13495
+ formatElementContext(elementList, [dateElement], leftIndex, {
13496
+ editorOptions: this.options
13497
+ });
13444
13498
  this.draw.insertElementList([dateElement]);
13445
13499
  }
13446
13500
  getDateElementRange() {
@@ -14764,6 +14818,26 @@ class PageBorder {
14764
14818
  ctx.restore();
14765
14819
  }
14766
14820
  }
14821
+ function positionContextChange(draw, payload) {
14822
+ const { value, oldValue } = payload;
14823
+ if (oldValue.isTable && !value.isTable) {
14824
+ draw.getTableTool().dispose();
14825
+ }
14826
+ }
14827
+ class Actuator {
14828
+ constructor(draw) {
14829
+ __publicField(this, "draw");
14830
+ __publicField(this, "eventBus");
14831
+ this.draw = draw;
14832
+ this.eventBus = draw.getEventBus();
14833
+ this.execute();
14834
+ }
14835
+ execute() {
14836
+ this.eventBus.on("positionContextChange", (payload) => {
14837
+ positionContextChange(this.draw, payload);
14838
+ });
14839
+ }
14840
+ }
14767
14841
  class Draw {
14768
14842
  constructor(rootContainer, options, data2, listener, eventBus, override) {
14769
14843
  __publicField(this, "container");
@@ -14893,6 +14967,7 @@ class Draw {
14893
14967
  this.globalEvent = new GlobalEvent(this, this.canvasEvent);
14894
14968
  this.globalEvent.register();
14895
14969
  this.workerManager = new WorkerManager(this);
14970
+ new Actuator(this);
14896
14971
  const { letterClass } = options;
14897
14972
  this.LETTER_REG = new RegExp(`[${letterClass.join("")}]`);
14898
14973
  this.WORD_LIKE_REG = new RegExp(`${letterClass.map((letter) => `[^${letter}][${letter}]`).join("|")}`);
@@ -14947,6 +15022,8 @@ class Draw {
14947
15022
  }
14948
15023
  isReadonly() {
14949
15024
  switch (this.mode) {
15025
+ case EditorMode.DESIGN:
15026
+ return false;
14950
15027
  case EditorMode.READONLY:
14951
15028
  case EditorMode.PRINT:
14952
15029
  return true;
@@ -14957,13 +15034,17 @@ class Draw {
14957
15034
  }
14958
15035
  }
14959
15036
  isDisabled() {
14960
- var _a, _b, _c, _d;
15037
+ var _a, _b, _c, _d, _e;
15038
+ if (this.mode === EditorMode.DESIGN)
15039
+ return false;
14961
15040
  const { startIndex, endIndex } = this.range.getRange();
14962
15041
  const elementList = this.getElementList();
15042
+ if ((_a = this.getTd()) == null ? void 0 : _a.disabled)
15043
+ return true;
14963
15044
  if (startIndex === endIndex) {
14964
15045
  const startElement = elementList[startIndex];
14965
15046
  const nextElement = elementList[startIndex + 1];
14966
- return !!(((_a = startElement == null ? void 0 : startElement.title) == null ? void 0 : _a.disabled) && ((_b = nextElement == null ? void 0 : nextElement.title) == null ? void 0 : _b.disabled) || ((_c = startElement == null ? void 0 : startElement.control) == null ? void 0 : _c.disabled) && ((_d = nextElement == null ? void 0 : nextElement.control) == null ? void 0 : _d.disabled));
15047
+ return !!(((_b = startElement == null ? void 0 : startElement.title) == null ? void 0 : _b.disabled) && ((_c = nextElement == null ? void 0 : nextElement.title) == null ? void 0 : _c.disabled) || ((_d = startElement == null ? void 0 : startElement.control) == null ? void 0 : _d.disabled) && ((_e = nextElement == null ? void 0 : nextElement.control) == null ? void 0 : _e.disabled));
14967
15048
  }
14968
15049
  const selectionElementList = elementList.slice(startIndex + 1, endIndex + 1);
14969
15050
  return selectionElementList.some((element) => {
@@ -14971,6 +15052,9 @@ class Draw {
14971
15052
  return ((_a2 = element.title) == null ? void 0 : _a2.disabled) || ((_b2 = element.control) == null ? void 0 : _b2.disabled);
14972
15053
  });
14973
15054
  }
15055
+ isDesignMode() {
15056
+ return this.mode === EditorMode.DESIGN;
15057
+ }
14974
15058
  getOriginalWidth() {
14975
15059
  const { paperDirection, width, height } = this.options;
14976
15060
  return paperDirection === PaperDirection.VERTICAL ? width : height;
@@ -15182,6 +15266,15 @@ class Draw {
15182
15266
  getFooterElementList() {
15183
15267
  return this.footer.getElementList();
15184
15268
  }
15269
+ getTd() {
15270
+ const positionContext = this.position.getPositionContext();
15271
+ const { index: index2, trIndex, tdIndex, isTable } = positionContext;
15272
+ if (isTable) {
15273
+ const elementList = this.getOriginalElementList();
15274
+ return elementList[index2].trList[trIndex].tdList[tdIndex];
15275
+ }
15276
+ return null;
15277
+ }
15185
15278
  insertElementList(payload) {
15186
15279
  if (!payload.length || !this.range.getIsCanInput())
15187
15280
  return;
@@ -15246,7 +15339,8 @@ class Draw {
15246
15339
  });
15247
15340
  }
15248
15341
  spliceElementList(elementList, start, deleteCount, ...items) {
15249
- var _a, _b, _c;
15342
+ var _a, _b, _c, _d;
15343
+ const isDesignMode = this.isDesignMode();
15250
15344
  if (deleteCount > 0) {
15251
15345
  const endIndex = start + deleteCount;
15252
15346
  const endElement = elementList[endIndex];
@@ -15265,10 +15359,11 @@ class Draw {
15265
15359
  }
15266
15360
  }
15267
15361
  if (!this.control.getActiveControl()) {
15362
+ const tdDeletable = (_b = this.getTd()) == null ? void 0 : _b.deletable;
15268
15363
  let deleteIndex = endIndex - 1;
15269
15364
  while (deleteIndex >= start) {
15270
15365
  const deleteElement = elementList[deleteIndex];
15271
- if (((_b = deleteElement == null ? void 0 : deleteElement.control) == null ? void 0 : _b.deletable) !== false && ((_c = deleteElement == null ? void 0 : deleteElement.title) == null ? void 0 : _c.deletable) !== false) {
15366
+ if (isDesignMode || tdDeletable !== false && ((_c = deleteElement == null ? void 0 : deleteElement.control) == null ? void 0 : _c.deletable) !== false && ((_d = deleteElement == null ? void 0 : deleteElement.title) == null ? void 0 : _d.deletable) !== false) {
15272
15367
  elementList.splice(deleteIndex, 1);
15273
15368
  }
15274
15369
  deleteIndex--;
@@ -16096,18 +16191,22 @@ class Draw {
16096
16191
  return pageRowList;
16097
16192
  }
16098
16193
  _drawHighlight(ctx, payload) {
16194
+ var _a;
16195
+ const { control: { activeBackgroundColor } } = this.options;
16099
16196
  const { rowList, positionList } = payload;
16197
+ const activeControlElement = (_a = this.control.getActiveControl()) == null ? void 0 : _a.getElement();
16100
16198
  for (let i = 0; i < rowList.length; i++) {
16101
16199
  const curRow = rowList[i];
16102
16200
  for (let j = 0; j < curRow.elementList.length; j++) {
16103
16201
  const element = curRow.elementList[j];
16104
16202
  const preElement = curRow.elementList[j - 1];
16105
- if (element.highlight) {
16203
+ if (element.highlight || activeBackgroundColor && activeControlElement && element.controlId === activeControlElement.controlId && !this.control.getIsRangeInPostfix()) {
16106
16204
  if (preElement && preElement.highlight && preElement.highlight !== element.highlight) {
16107
16205
  this.highlight.render(ctx);
16108
16206
  }
16109
16207
  const { coordinate: { leftTop: [x, y] } } = positionList[curRow.startIndex + j];
16110
- this.highlight.recordFillInfo(ctx, x, y, element.metrics.width, curRow.height, element.highlight);
16208
+ const offsetX = element.left || 0;
16209
+ this.highlight.recordFillInfo(ctx, x - offsetX, y, element.metrics.width + offsetX, curRow.height, element.highlight || activeBackgroundColor);
16111
16210
  } else if (preElement == null ? void 0 : preElement.highlight) {
16112
16211
  this.highlight.render(ctx);
16113
16212
  }
@@ -16683,6 +16782,7 @@ class Command {
16683
16782
  __publicField(this, "executeInsertControl");
16684
16783
  __publicField(this, "executeUpdateOptions");
16685
16784
  __publicField(this, "executeInsertTitle");
16785
+ __publicField(this, "executeFocus");
16686
16786
  __publicField(this, "getCatalog");
16687
16787
  __publicField(this, "getImage");
16688
16788
  __publicField(this, "getOptions");
@@ -16792,6 +16892,7 @@ class Command {
16792
16892
  this.executeSetZone = adapt.setZone.bind(adapt);
16793
16893
  this.executeUpdateOptions = adapt.updateOptions.bind(adapt);
16794
16894
  this.executeInsertTitle = adapt.insertTitle.bind(adapt);
16895
+ this.executeFocus = adapt.focus.bind(adapt);
16795
16896
  this.getImage = adapt.getImage.bind(adapt);
16796
16897
  this.getOptions = adapt.getOptions.bind(adapt);
16797
16898
  this.getValue = adapt.getValue.bind(adapt);
@@ -16851,7 +16952,8 @@ const defaultControlOption = {
16851
16952
  prefix: "{",
16852
16953
  postfix: "}",
16853
16954
  borderWidth: 1,
16854
- borderColor: "#000000"
16955
+ borderColor: "#000000",
16956
+ activeBackgroundColor: ""
16855
16957
  };
16856
16958
  const defaultFooterOption = {
16857
16959
  bottom: 30,
@@ -17109,8 +17211,8 @@ class CommandAdapt {
17109
17211
  this.draw.setMode(payload);
17110
17212
  }
17111
17213
  cut() {
17112
- const isReadonly = this.draw.isReadonly();
17113
- if (isReadonly)
17214
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17215
+ if (isDisabled)
17114
17216
  return;
17115
17217
  this.canvasEvent.cut();
17116
17218
  }
@@ -17118,8 +17220,8 @@ class CommandAdapt {
17118
17220
  this.canvasEvent.copy();
17119
17221
  }
17120
17222
  paste(payload) {
17121
- const isReadonly = this.draw.isReadonly();
17122
- if (isReadonly)
17223
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17224
+ if (isDisabled)
17123
17225
  return;
17124
17226
  pasteByApi(this.canvasEvent, payload);
17125
17227
  }
@@ -17127,8 +17229,8 @@ class CommandAdapt {
17127
17229
  this.canvasEvent.selectAll();
17128
17230
  }
17129
17231
  backspace() {
17130
- const isReadonly = this.draw.isReadonly();
17131
- if (isReadonly)
17232
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17233
+ if (isDisabled)
17132
17234
  return;
17133
17235
  const elementList = this.draw.getElementList();
17134
17236
  const { startIndex, endIndex } = this.range.getRange();
@@ -17601,8 +17703,8 @@ class CommandAdapt {
17601
17703
  }
17602
17704
  }
17603
17705
  title(payload) {
17604
- const isReadonly = this.draw.isReadonly();
17605
- if (isReadonly)
17706
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17707
+ if (isDisabled)
17606
17708
  return;
17607
17709
  const { startIndex, endIndex } = this.range.getRange();
17608
17710
  if (!~startIndex && !~endIndex)
@@ -17679,8 +17781,8 @@ class CommandAdapt {
17679
17781
  }
17680
17782
  insertTable(row, col) {
17681
17783
  var _a;
17682
- const isReadonly = this.draw.isReadonly();
17683
- if (isReadonly)
17784
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17785
+ if (isDisabled)
17684
17786
  return;
17685
17787
  const activeControl = this.control.getActiveControl();
17686
17788
  if (activeControl)
@@ -17731,7 +17833,9 @@ class CommandAdapt {
17731
17833
  formatElementList([element], {
17732
17834
  editorOptions: this.options
17733
17835
  });
17734
- formatElementContext(elementList, [element], startIndex);
17836
+ formatElementContext(elementList, [element], startIndex, {
17837
+ editorOptions: this.options
17838
+ });
17735
17839
  const curIndex = startIndex + 1;
17736
17840
  this.draw.spliceElementList(elementList, curIndex, startIndex === endIndex ? 0 : endIndex - startIndex, element);
17737
17841
  this.range.setRange(curIndex, curIndex);
@@ -18414,8 +18518,8 @@ class CommandAdapt {
18414
18518
  });
18415
18519
  }
18416
18520
  hyperlink(payload) {
18417
- const isReadonly = this.draw.isReadonly();
18418
- if (isReadonly)
18521
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
18522
+ if (isDisabled)
18419
18523
  return;
18420
18524
  const activeControl = this.control.getActiveControl();
18421
18525
  if (activeControl)
@@ -18435,7 +18539,9 @@ class CommandAdapt {
18435
18539
  if (!newElementList)
18436
18540
  return;
18437
18541
  const start = startIndex + 1;
18438
- formatElementContext(elementList, newElementList, startIndex);
18542
+ formatElementContext(elementList, newElementList, startIndex, {
18543
+ editorOptions: this.options
18544
+ });
18439
18545
  this.draw.spliceElementList(elementList, start, startIndex === endIndex ? 0 : endIndex - startIndex, ...newElementList);
18440
18546
  const curIndex = start + newElementList.length - 1;
18441
18547
  this.range.setRange(curIndex, curIndex);
@@ -18477,8 +18583,8 @@ class CommandAdapt {
18477
18583
  return [leftIndex, rightIndex];
18478
18584
  }
18479
18585
  deleteHyperlink() {
18480
- const isReadonly = this.draw.isReadonly();
18481
- if (isReadonly)
18586
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
18587
+ if (isDisabled)
18482
18588
  return;
18483
18589
  const hyperRange = this.getHyperlinkRange();
18484
18590
  if (!hyperRange)
@@ -18494,8 +18600,8 @@ class CommandAdapt {
18494
18600
  });
18495
18601
  }
18496
18602
  cancelHyperlink() {
18497
- const isReadonly = this.draw.isReadonly();
18498
- if (isReadonly)
18603
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
18604
+ if (isDisabled)
18499
18605
  return;
18500
18606
  const hyperRange = this.getHyperlinkRange();
18501
18607
  if (!hyperRange)
@@ -18517,8 +18623,8 @@ class CommandAdapt {
18517
18623
  });
18518
18624
  }
18519
18625
  editHyperlink(payload) {
18520
- const isReadonly = this.draw.isReadonly();
18521
- if (isReadonly)
18626
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
18627
+ if (isDisabled)
18522
18628
  return;
18523
18629
  const hyperRange = this.getHyperlinkRange();
18524
18630
  if (!hyperRange)
@@ -18537,8 +18643,8 @@ class CommandAdapt {
18537
18643
  });
18538
18644
  }
18539
18645
  separator(payload) {
18540
- const isReadonly = this.draw.isReadonly();
18541
- if (isReadonly)
18646
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
18647
+ if (isDisabled)
18542
18648
  return;
18543
18649
  const activeControl = this.control.getActiveControl();
18544
18650
  if (activeControl)
@@ -18561,7 +18667,9 @@ class CommandAdapt {
18561
18667
  type: ElementType.SEPARATOR,
18562
18668
  dashArray: payload
18563
18669
  };
18564
- formatElementContext(elementList, [newElement], startIndex);
18670
+ formatElementContext(elementList, [newElement], startIndex, {
18671
+ editorOptions: this.options
18672
+ });
18565
18673
  if (startIndex !== 0 && elementList[startIndex].value === ZERO) {
18566
18674
  this.draw.spliceElementList(elementList, startIndex, 1, newElement);
18567
18675
  curIndex = startIndex - 1;
@@ -18574,8 +18682,8 @@ class CommandAdapt {
18574
18682
  this.draw.render({ curIndex });
18575
18683
  }
18576
18684
  pageBreak() {
18577
- const isReadonly = this.draw.isReadonly();
18578
- if (isReadonly)
18685
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
18686
+ if (isDisabled)
18579
18687
  return;
18580
18688
  const activeControl = this.control.getActiveControl();
18581
18689
  if (activeControl)
@@ -18997,14 +19105,15 @@ class CommandAdapt {
18997
19105
  insertElementList(payload) {
18998
19106
  if (!payload.length)
18999
19107
  return;
19000
- const isReadonly = this.draw.isReadonly();
19001
- if (isReadonly)
19108
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
19109
+ if (isDisabled)
19002
19110
  return;
19003
19111
  const cloneElementList = deepClone(payload);
19004
19112
  const { startIndex } = this.range.getRange();
19005
19113
  const elementList = this.draw.getElementList();
19006
19114
  formatElementContext(elementList, cloneElementList, startIndex, {
19007
- isBreakWhenWrap: true
19115
+ isBreakWhenWrap: true,
19116
+ editorOptions: this.options
19008
19117
  });
19009
19118
  this.draw.insertElementList(cloneElementList);
19010
19119
  }
@@ -19284,8 +19393,8 @@ class CommandAdapt {
19284
19393
  }
19285
19394
  }
19286
19395
  insertControl(payload) {
19287
- const isReadonly = this.draw.isReadonly();
19288
- if (isReadonly)
19396
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
19397
+ if (isDisabled)
19289
19398
  return;
19290
19399
  const cloneElement = deepClone(payload);
19291
19400
  const { startIndex } = this.range.getRange();
@@ -19410,8 +19519,8 @@ class CommandAdapt {
19410
19519
  }
19411
19520
  insertTitle(payload) {
19412
19521
  var _a;
19413
- const isReadonly = this.draw.isReadonly();
19414
- if (isReadonly)
19522
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
19523
+ if (isDisabled)
19415
19524
  return;
19416
19525
  const cloneElement = deepClone(payload);
19417
19526
  const { startIndex } = this.range.getRange();
@@ -19429,6 +19538,21 @@ class CommandAdapt {
19429
19538
  });
19430
19539
  this.draw.insertElementList([cloneElement]);
19431
19540
  }
19541
+ focus(payload) {
19542
+ const { position = LocationPosition.AFTER } = payload || {};
19543
+ const curIndex = position === LocationPosition.BEFORE ? 0 : this.draw.getOriginalMainElementList().length - 1;
19544
+ this.range.setRange(curIndex, curIndex);
19545
+ this.draw.render({
19546
+ curIndex,
19547
+ isCompute: false,
19548
+ isSubmitHistory: false
19549
+ });
19550
+ const positionList = this.draw.getPosition().getPositionList();
19551
+ this.draw.getCursor().moveCursorToVisible({
19552
+ cursorPosition: positionList[curIndex],
19553
+ direction: MoveDirection.DOWN
19554
+ });
19555
+ }
19432
19556
  }
19433
19557
  class Listener {
19434
19558
  constructor() {