@hufe921/canvas-editor 0.9.87 → 0.9.89

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.87";
26
+ const version = "0.9.89";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -4343,10 +4343,13 @@ function getAnchorElement(elementList, anchorIndex) {
4343
4343
  return !anchorElement.listId && anchorElement.value === ZERO && anchorNextElement && anchorNextElement.value !== ZERO ? anchorNextElement : anchorElement;
4344
4344
  }
4345
4345
  function formatElementContext(sourceElementList, formatElementList2, anchorIndex, options) {
4346
- var _a, _b;
4347
- const copyElement = getAnchorElement(sourceElementList, anchorIndex);
4346
+ var _a, _b, _c;
4347
+ let copyElement = getAnchorElement(sourceElementList, anchorIndex);
4348
4348
  if (!copyElement)
4349
4349
  return;
4350
+ if ((_a = copyElement.title) == null ? void 0 : _a.disabled) {
4351
+ copyElement = omitObject(copyElement, TITLE_CONTEXT_ATTR);
4352
+ }
4350
4353
  const { isBreakWhenWrap = false } = options || {};
4351
4354
  let isBreakWarped = false;
4352
4355
  for (let e = 0; e < formatElementList2.length; e++) {
@@ -4357,12 +4360,12 @@ function formatElementContext(sourceElementList, formatElementList2, anchorIndex
4357
4360
  if (isBreakWarped || !copyElement.listId && targetElement.type === ElementType.LIST) {
4358
4361
  const cloneAttr = [...TABLE_CONTEXT_ATTR, ...EDITOR_ROW_ATTR];
4359
4362
  cloneProperty(cloneAttr, copyElement, targetElement);
4360
- (_a = targetElement.valueList) == null ? void 0 : _a.forEach((valueItem) => {
4363
+ (_b = targetElement.valueList) == null ? void 0 : _b.forEach((valueItem) => {
4361
4364
  cloneProperty(cloneAttr, copyElement, valueItem);
4362
4365
  });
4363
4366
  continue;
4364
4367
  }
4365
- if ((_b = targetElement.valueList) == null ? void 0 : _b.length) {
4368
+ if ((_c = targetElement.valueList) == null ? void 0 : _c.length) {
4366
4369
  formatElementContext(sourceElementList, targetElement.valueList, anchorIndex);
4367
4370
  }
4368
4371
  cloneProperty(EDITOR_ELEMENT_CONTEXT_ATTR, copyElement, targetElement);
@@ -4980,8 +4983,7 @@ function getIsClipboardContainFile(clipboardData) {
4980
4983
  }
4981
4984
  function pasteElement(host, elementList) {
4982
4985
  const draw = host.getDraw();
4983
- const isReadonly = draw.isReadonly();
4984
- if (isReadonly)
4986
+ if (draw.isReadonly() || draw.isDisabled())
4985
4987
  return;
4986
4988
  const rangeManager = draw.getRange();
4987
4989
  const { startIndex } = rangeManager.getRange();
@@ -5020,8 +5022,7 @@ function pasteElement(host, elementList) {
5020
5022
  }
5021
5023
  function pasteHTML(host, htmlText) {
5022
5024
  const draw = host.getDraw();
5023
- const isReadonly = draw.isReadonly();
5024
- if (isReadonly)
5025
+ if (draw.isReadonly() || draw.isDisabled())
5025
5026
  return;
5026
5027
  const elementList = getElementListByHTML(htmlText, {
5027
5028
  innerWidth: draw.getOriginalInnerWidth()
@@ -5030,8 +5031,7 @@ function pasteHTML(host, htmlText) {
5030
5031
  }
5031
5032
  function pasteImage(host, file) {
5032
5033
  const draw = host.getDraw();
5033
- const isReadonly = draw.isReadonly();
5034
- if (isReadonly)
5034
+ if (draw.isReadonly() || draw.isDisabled())
5035
5035
  return;
5036
5036
  const rangeManager = draw.getRange();
5037
5037
  const { startIndex } = rangeManager.getRange();
@@ -5058,8 +5058,7 @@ function pasteImage(host, file) {
5058
5058
  }
5059
5059
  function pasteByEvent(host, evt) {
5060
5060
  const draw = host.getDraw();
5061
- const isReadonly = draw.isReadonly();
5062
- if (isReadonly)
5061
+ if (draw.isReadonly() || draw.isDisabled())
5063
5062
  return;
5064
5063
  const clipboardData = evt.clipboardData;
5065
5064
  if (!clipboardData)
@@ -5114,8 +5113,7 @@ function pasteByEvent(host, evt) {
5114
5113
  }
5115
5114
  async function pasteByApi(host, options) {
5116
5115
  const draw = host.getDraw();
5117
- const isReadonly = draw.isReadonly();
5118
- if (isReadonly)
5116
+ if (draw.isReadonly() || draw.isDisabled())
5119
5117
  return;
5120
5118
  const { paste } = draw.getOverride();
5121
5119
  if (paste) {
@@ -5552,7 +5550,7 @@ class CheckboxControl {
5552
5550
  return -1;
5553
5551
  }
5554
5552
  setSelect(codes, context = {}, options = {}) {
5555
- if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
5553
+ if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
5556
5554
  return;
5557
5555
  }
5558
5556
  const { control } = this.element;
@@ -5604,7 +5602,7 @@ class CheckboxControl {
5604
5602
  }
5605
5603
  class RadioControl extends CheckboxControl {
5606
5604
  setSelect(codes, context = {}, options = {}) {
5607
- if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
5605
+ if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
5608
5606
  return;
5609
5607
  }
5610
5608
  const { control } = this.element;
@@ -5672,6 +5670,7 @@ function mousedown(evt, host) {
5672
5670
  draw.setPageNo(Number(pageIndex));
5673
5671
  }
5674
5672
  host.isAllowSelection = true;
5673
+ const oldPositionContext = deepClone(position.getPositionContext());
5675
5674
  const positionResult = position.adjustPositionContext({
5676
5675
  x: evt.offsetX,
5677
5676
  y: evt.offsetY
@@ -5692,7 +5691,22 @@ function mousedown(evt, host) {
5692
5691
  const isDirectHitCheckbox = !!(isDirectHit && isCheckbox);
5693
5692
  const isDirectHitRadio = !!(isDirectHit && isRadio);
5694
5693
  if (~index2) {
5695
- rangeManager.setRange(curIndex, curIndex);
5694
+ let startIndex = curIndex;
5695
+ let endIndex = curIndex;
5696
+ if (evt.shiftKey) {
5697
+ const { startIndex: oldStartIndex } = rangeManager.getRange();
5698
+ if (~oldStartIndex) {
5699
+ const newPositionContext = position.getPositionContext();
5700
+ if (newPositionContext.tdId === oldPositionContext.tdId) {
5701
+ if (curIndex > oldStartIndex) {
5702
+ startIndex = oldStartIndex;
5703
+ } else {
5704
+ endIndex = oldStartIndex;
5705
+ }
5706
+ }
5707
+ }
5708
+ }
5709
+ rangeManager.setRange(startIndex, endIndex);
5696
5710
  position.setCursorPosition(positionList[curIndex]);
5697
5711
  const isSetCheckbox = isDirectHitCheckbox && !isReadonly;
5698
5712
  const isSetRadio = isDirectHitRadio && !isReadonly;
@@ -5804,8 +5818,10 @@ function mouseup(evt, host) {
5804
5818
  var _a, _b, _c, _d;
5805
5819
  if (host.isAllowDrop) {
5806
5820
  const draw = host.getDraw();
5807
- if (draw.isReadonly())
5821
+ if (draw.isReadonly() || draw.isDisabled()) {
5822
+ host.mousedown(evt);
5808
5823
  return;
5824
+ }
5809
5825
  const position = draw.getPosition();
5810
5826
  const positionList = position.getPositionList();
5811
5827
  const positionContext = position.getPositionContext();
@@ -6908,7 +6924,7 @@ function keydown(evt, host) {
6908
6924
  function input(data2, host) {
6909
6925
  var _a;
6910
6926
  const draw = host.getDraw();
6911
- if (draw.isReadonly())
6927
+ if (draw.isReadonly() || draw.isDisabled())
6912
6928
  return;
6913
6929
  const position = draw.getPosition();
6914
6930
  const cursorPosition = position.getCursorPosition();
@@ -6934,22 +6950,25 @@ function input(data2, host) {
6934
6950
  if (!copyElement)
6935
6951
  return;
6936
6952
  const inputData = splitText(text).map((value) => {
6953
+ var _a2, _b;
6937
6954
  const newElement = {
6938
6955
  value
6939
6956
  };
6940
- const nextElement = elementList[endIndex + 1];
6941
- 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) {
6942
- EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
6943
- if (attr === "groupIds" && !(nextElement == null ? void 0 : nextElement.groupIds))
6944
- return;
6945
- const value2 = copyElement[attr];
6946
- if (value2 !== void 0) {
6947
- newElement[attr] = value2;
6948
- }
6949
- });
6950
- }
6951
- if (isComposing) {
6952
- newElement.underline = true;
6957
+ if (!((_a2 = copyElement.title) == null ? void 0 : _a2.disabled) && !((_b = copyElement.control) == null ? void 0 : _b.disabled)) {
6958
+ const nextElement = elementList[endIndex + 1];
6959
+ 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) {
6960
+ EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
6961
+ if (attr === "groupIds" && !(nextElement == null ? void 0 : nextElement.groupIds))
6962
+ return;
6963
+ const value2 = copyElement[attr];
6964
+ if (value2 !== void 0) {
6965
+ newElement[attr] = value2;
6966
+ }
6967
+ });
6968
+ }
6969
+ if (isComposing) {
6970
+ newElement.underline = true;
6971
+ }
6953
6972
  }
6954
6973
  return newElement;
6955
6974
  });
@@ -7258,7 +7277,7 @@ function threeClick(host) {
7258
7277
  if (newStartIndex < 0)
7259
7278
  return;
7260
7279
  let newEndIndex = index2 + downCount + 1;
7261
- if (((_b = elementList[newEndIndex]) == null ? void 0 : _b.value) === ZERO) {
7280
+ if (((_b = elementList[newEndIndex]) == null ? void 0 : _b.value) === ZERO || newEndIndex > elementList.length - 1) {
7262
7281
  newEndIndex -= 1;
7263
7282
  }
7264
7283
  rangeManager.setRange(newStartIndex, newEndIndex);
@@ -7408,6 +7427,9 @@ class CanvasEvent {
7408
7427
  const painterStyle = this.draw.getPainterStyle();
7409
7428
  if (!painterStyle)
7410
7429
  return;
7430
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
7431
+ if (isDisabled)
7432
+ return;
7411
7433
  const selection = this.range.getSelection();
7412
7434
  if (!selection)
7413
7435
  return;
@@ -8125,11 +8147,13 @@ class Position {
8125
8147
  };
8126
8148
  }
8127
8149
  getFloatPositionByXY(payload) {
8150
+ var _a;
8128
8151
  const { x, y } = payload;
8152
+ const currentPageNo = (_a = payload.pageNo) != null ? _a : this.draw.getPageNo();
8129
8153
  const currentZone = this.draw.getZone().getZone();
8130
8154
  for (let f = 0; f < this.floatPositionList.length; f++) {
8131
- const { position, element, isTable, index: index2, trIndex, tdIndex, tdValueIndex, zone: floatElementZone } = this.floatPositionList[f];
8132
- if (element.type === ElementType.IMAGE && element.imgDisplay === payload.imgDisplay && (!floatElementZone || floatElementZone === currentZone)) {
8155
+ const { position, element, isTable, index: index2, trIndex, tdIndex, tdValueIndex, zone: floatElementZone, pageNo } = this.floatPositionList[f];
8156
+ if (currentPageNo === pageNo && element.type === ElementType.IMAGE && element.imgDisplay === payload.imgDisplay && (!floatElementZone || floatElementZone === currentZone)) {
8133
8157
  const imgFloatPosition = element.imgFloatPosition;
8134
8158
  if (x >= imgFloatPosition.x && x <= imgFloatPosition.x + element.width && y >= imgFloatPosition.y && y <= imgFloatPosition.y + element.height) {
8135
8159
  if (isTable) {
@@ -8755,14 +8779,14 @@ class Background {
8755
8779
  }
8756
8780
  }
8757
8781
  render(ctx, pageNo) {
8758
- const { background } = this.options;
8759
- if (background.image) {
8782
+ const { background: { image, color, applyPageNumbers } } = this.options;
8783
+ if (image && (!(applyPageNumbers == null ? void 0 : applyPageNumbers.length) || applyPageNumbers.includes(pageNo))) {
8760
8784
  const { width, height } = this.options;
8761
8785
  this._renderBackgroundImage(ctx, width, height);
8762
8786
  } else {
8763
8787
  const width = this.draw.getCanvasWidth(pageNo);
8764
8788
  const height = this.draw.getCanvasHeight(pageNo);
8765
- this._renderBackgroundColor(ctx, background.color, width, height);
8789
+ this._renderBackgroundColor(ctx, color, width, height);
8766
8790
  }
8767
8791
  }
8768
8792
  }
@@ -10511,7 +10535,6 @@ class ControlSearch {
10511
10535
  computeHighlightList() {
10512
10536
  const search = this.draw.getSearch();
10513
10537
  const computeHighlight = (elementList, restArgs) => {
10514
- var _a;
10515
10538
  let i = 0;
10516
10539
  while (i < elementList.length) {
10517
10540
  const element = elementList[i];
@@ -10533,10 +10556,10 @@ class ControlSearch {
10533
10556
  }
10534
10557
  }
10535
10558
  }
10536
- const controlConceptId = (_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId;
10537
- if (!controlConceptId)
10559
+ const currentControl = element == null ? void 0 : element.control;
10560
+ if (!currentControl)
10538
10561
  continue;
10539
- const highlightIndex = this.highlightList.findIndex((highlight2) => highlight2.conceptId === controlConceptId);
10562
+ const highlightIndex = this.highlightList.findIndex((highlight2) => highlight2.id === element.controlId || currentControl.conceptId && currentControl.conceptId === highlight2.conceptId);
10540
10563
  if (!~highlightIndex)
10541
10564
  continue;
10542
10565
  const startIndex = i;
@@ -10740,7 +10763,7 @@ class SelectControl {
10740
10763
  }
10741
10764
  clearSelect(context = {}, options = {}) {
10742
10765
  const { isIgnoreDisabledRule = false, isAddPlaceholder = true } = options;
10743
- if (!isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
10766
+ if (!isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
10744
10767
  return -1;
10745
10768
  }
10746
10769
  const elementList = context.elementList || this.control.getElementList();
@@ -10777,7 +10800,7 @@ class SelectControl {
10777
10800
  return preIndex;
10778
10801
  }
10779
10802
  setSelect(code, context = {}, options = {}) {
10780
- if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
10803
+ if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
10781
10804
  return;
10782
10805
  }
10783
10806
  const elementList = context.elementList || this.control.getElementList();
@@ -10928,7 +10951,7 @@ class TextControl {
10928
10951
  return data2;
10929
10952
  }
10930
10953
  setValue(data2, context = {}, options = {}) {
10931
- if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
10954
+ if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
10932
10955
  return -1;
10933
10956
  }
10934
10957
  const elementList = context.elementList || this.control.getElementList();
@@ -10958,7 +10981,7 @@ class TextControl {
10958
10981
  return start + data2.length - 1;
10959
10982
  }
10960
10983
  clearValue(context = {}, options = {}) {
10961
- if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
10984
+ if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
10962
10985
  return -1;
10963
10986
  }
10964
10987
  const elementList = context.elementList || this.control.getElementList();
@@ -11566,7 +11589,7 @@ class DateControl {
11566
11589
  return data2;
11567
11590
  }
11568
11591
  setValue(data2, context = {}, options = {}) {
11569
- if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
11592
+ if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
11570
11593
  return -1;
11571
11594
  }
11572
11595
  const elementList = context.elementList || this.control.getElementList();
@@ -11597,7 +11620,7 @@ class DateControl {
11597
11620
  }
11598
11621
  clearSelect(context = {}, options = {}) {
11599
11622
  const { isIgnoreDisabledRule = false, isAddPlaceholder = true } = options;
11600
- if (!isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
11623
+ if (!isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
11601
11624
  return -1;
11602
11625
  }
11603
11626
  const range = this.getValueRange(context);
@@ -11615,7 +11638,7 @@ class DateControl {
11615
11638
  return leftIndex;
11616
11639
  }
11617
11640
  setSelect(date, context = {}, options = {}) {
11618
- if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
11641
+ if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl(context)) {
11619
11642
  return;
11620
11643
  }
11621
11644
  const elementList = context.elementList || this.control.getElementList();
@@ -11879,9 +11902,19 @@ class Control {
11879
11902
  return false;
11880
11903
  return prefixCount === postfixCount;
11881
11904
  }
11882
- getIsDisabledControl() {
11905
+ getIsDisabledControl(context = {}) {
11883
11906
  var _a, _b;
11884
- return !!((_b = (_a = this.activeControl) == null ? void 0 : _a.getElement().control) == null ? void 0 : _b.disabled);
11907
+ if (!this.activeControl)
11908
+ return false;
11909
+ const { startIndex, endIndex } = context.range || this.range.getRange();
11910
+ if (startIndex === endIndex && ~startIndex && ~endIndex) {
11911
+ const elementList = context.elementList || this.getElementList();
11912
+ const startElement = elementList[startIndex];
11913
+ if (startElement.controlComponent === ControlComponent.POSTFIX) {
11914
+ return false;
11915
+ }
11916
+ }
11917
+ return !!((_b = (_a = this.activeControl.getElement()) == null ? void 0 : _a.control) == null ? void 0 : _b.disabled);
11885
11918
  }
11886
11919
  getContainer() {
11887
11920
  return this.draw.getContainer();
@@ -12174,11 +12207,12 @@ class Control {
12174
12207
  }
12175
12208
  return this.activeControl.cut();
12176
12209
  }
12177
- getValueByConceptId(payload) {
12178
- const { conceptId } = payload;
12210
+ getValueById(payload) {
12211
+ const { id, conceptId } = payload;
12179
12212
  const result = [];
12213
+ if (!id && !conceptId)
12214
+ return result;
12180
12215
  const getValue = (elementList, zone2) => {
12181
- var _a;
12182
12216
  let i = 0;
12183
12217
  while (i < elementList.length) {
12184
12218
  const element = elementList[i];
@@ -12193,8 +12227,9 @@ class Control {
12193
12227
  }
12194
12228
  }
12195
12229
  }
12196
- if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
12230
+ if (!element.control || id && element.controlId !== id || conceptId && element.control.conceptId !== conceptId) {
12197
12231
  continue;
12232
+ }
12198
12233
  const { type, code, valueSets } = element.control;
12199
12234
  let j = i;
12200
12235
  let textControlValue = "";
@@ -12215,8 +12250,8 @@ class Control {
12215
12250
  }));
12216
12251
  } else if (type === ControlType.SELECT || type === ControlType.CHECKBOX || type === ControlType.RADIO) {
12217
12252
  const innerText = code == null ? void 0 : code.split(",").map((selectCode) => {
12218
- var _a2;
12219
- return (_a2 = valueSets == null ? void 0 : valueSets.find((valueSet) => valueSet.code === selectCode)) == null ? void 0 : _a2.value;
12253
+ var _a;
12254
+ return (_a = valueSets == null ? void 0 : valueSets.find((valueSet) => valueSet.code === selectCode)) == null ? void 0 : _a.value;
12220
12255
  }).filter(Boolean).join("");
12221
12256
  result.push(__spreadProps(__spreadValues({}, element.control), {
12222
12257
  zone: zone2,
@@ -12246,11 +12281,12 @@ class Control {
12246
12281
  }
12247
12282
  return result;
12248
12283
  }
12249
- setValueByConceptId(payload) {
12284
+ setValueById(payload) {
12250
12285
  let isExistSet = false;
12251
- const { conceptId, value } = payload;
12286
+ const { id, conceptId, value } = payload;
12287
+ if (!id && !conceptId)
12288
+ return;
12252
12289
  const setValue = (elementList) => {
12253
- var _a;
12254
12290
  let i = 0;
12255
12291
  while (i < elementList.length) {
12256
12292
  const element = elementList[i];
@@ -12265,8 +12301,9 @@ class Control {
12265
12301
  }
12266
12302
  }
12267
12303
  }
12268
- if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
12304
+ if (!element.control || id && element.controlId !== id || conceptId && element.control.conceptId !== conceptId) {
12269
12305
  continue;
12306
+ }
12270
12307
  isExistSet = true;
12271
12308
  const { type } = element.control;
12272
12309
  let currentEndIndex = i;
@@ -12353,10 +12390,11 @@ class Control {
12353
12390
  });
12354
12391
  }
12355
12392
  }
12356
- setExtensionByConceptId(payload) {
12357
- const { conceptId, extension } = payload;
12393
+ setExtensionById(payload) {
12394
+ const { id, conceptId, extension } = payload;
12395
+ if (!id && !conceptId)
12396
+ return;
12358
12397
  const setExtension = (elementList) => {
12359
- var _a;
12360
12398
  let i = 0;
12361
12399
  while (i < elementList.length) {
12362
12400
  const element = elementList[i];
@@ -12371,8 +12409,9 @@ class Control {
12371
12409
  }
12372
12410
  }
12373
12411
  }
12374
- if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
12412
+ if (!element.control || id && element.controlId !== id || conceptId && element.control.conceptId !== conceptId) {
12375
12413
  continue;
12414
+ }
12376
12415
  element.control.extension = extension;
12377
12416
  let newEndIndex = i;
12378
12417
  while (newEndIndex < elementList.length) {
@@ -12393,11 +12432,12 @@ class Control {
12393
12432
  setExtension(elementList);
12394
12433
  }
12395
12434
  }
12396
- setPropertiesByConceptId(payload) {
12397
- const { conceptId, properties } = payload;
12435
+ setPropertiesById(payload) {
12436
+ const { id, conceptId, properties } = payload;
12437
+ if (!id && !conceptId)
12438
+ return;
12398
12439
  let isExistUpdate = false;
12399
12440
  function setProperties(elementList) {
12400
- var _a;
12401
12441
  let i = 0;
12402
12442
  while (i < elementList.length) {
12403
12443
  const element = elementList[i];
@@ -12412,8 +12452,9 @@ class Control {
12412
12452
  }
12413
12453
  }
12414
12454
  }
12415
- if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
12455
+ if (!element.control || id && element.controlId !== id || conceptId && element.control.conceptId !== conceptId) {
12416
12456
  continue;
12457
+ }
12417
12458
  isExistUpdate = true;
12418
12459
  element.control = __spreadProps(__spreadValues(__spreadValues({}, element.control), properties), {
12419
12460
  value: element.control.value
@@ -14563,6 +14604,42 @@ class MouseObserver {
14563
14604
  this.eventBus.emit("mouseleave", evt);
14564
14605
  }
14565
14606
  }
14607
+ var LineNumberType;
14608
+ (function(LineNumberType2) {
14609
+ LineNumberType2["PAGE"] = "page";
14610
+ LineNumberType2["CONTINUITY"] = "continuity";
14611
+ })(LineNumberType || (LineNumberType = {}));
14612
+ class LineNumber {
14613
+ constructor(draw) {
14614
+ __publicField(this, "draw");
14615
+ __publicField(this, "options");
14616
+ this.draw = draw;
14617
+ this.options = draw.getOptions();
14618
+ }
14619
+ render(ctx, pageNo) {
14620
+ const { scale, lineNumber: { color, size, font, right: right2, type } } = this.options;
14621
+ const textParticle = this.draw.getTextParticle();
14622
+ const margins = this.draw.getMargins();
14623
+ const positionList = this.draw.getPosition().getOriginalMainPositionList();
14624
+ const pageRowList = this.draw.getPageRowList();
14625
+ const rowList = pageRowList[pageNo];
14626
+ ctx.save();
14627
+ ctx.fillStyle = color;
14628
+ ctx.font = `${size * scale}px ${font}`;
14629
+ for (let i = 0; i < rowList.length; i++) {
14630
+ const row = rowList[i];
14631
+ const { coordinate: { leftBottom } } = positionList[row.startIndex];
14632
+ const seq = type === LineNumberType.PAGE ? i + 1 : row.rowIndex + 1;
14633
+ const textMetrics = textParticle.measureText(ctx, {
14634
+ value: `${seq}`
14635
+ });
14636
+ const x = margins[3] - (textMetrics.width + right2) * scale;
14637
+ const y = leftBottom[1] - textMetrics.actualBoundingBoxAscent * scale;
14638
+ ctx.fillText(`${seq}`, x, y);
14639
+ }
14640
+ ctx.restore();
14641
+ }
14642
+ }
14566
14643
  class Draw {
14567
14644
  constructor(rootContainer, options, data2, listener, eventBus, override) {
14568
14645
  __publicField(this, "container");
@@ -14599,6 +14676,7 @@ class Draw {
14599
14676
  __publicField(this, "tableParticle");
14600
14677
  __publicField(this, "tableTool");
14601
14678
  __publicField(this, "pageNumber");
14679
+ __publicField(this, "lineNumber");
14602
14680
  __publicField(this, "waterMark");
14603
14681
  __publicField(this, "placeholder");
14604
14682
  __publicField(this, "header");
@@ -14662,6 +14740,7 @@ class Draw {
14662
14740
  this.tableParticle = new TableParticle(this);
14663
14741
  this.tableTool = new TableTool(this);
14664
14742
  this.pageNumber = new PageNumber(this);
14743
+ this.lineNumber = new LineNumber(this);
14665
14744
  this.waterMark = new Watermark(this);
14666
14745
  this.placeholder = new Placeholder(this);
14667
14746
  this.header = new Header(this, data2.header);
@@ -14750,6 +14829,21 @@ class Draw {
14750
14829
  return false;
14751
14830
  }
14752
14831
  }
14832
+ isDisabled() {
14833
+ var _a, _b, _c, _d;
14834
+ const { startIndex, endIndex } = this.range.getRange();
14835
+ const elementList = this.getElementList();
14836
+ if (startIndex === endIndex) {
14837
+ const startElement = elementList[startIndex];
14838
+ const nextElement = elementList[startIndex + 1];
14839
+ 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));
14840
+ }
14841
+ const selectionElementList = elementList.slice(startIndex + 1, endIndex + 1);
14842
+ return selectionElementList.some((element) => {
14843
+ var _a2, _b2;
14844
+ return ((_a2 = element.title) == null ? void 0 : _a2.disabled) || ((_b2 = element.control) == null ? void 0 : _b2.disabled);
14845
+ });
14846
+ }
14753
14847
  getOriginalWidth() {
14754
14848
  const { paperDirection, width, height } = this.options;
14755
14849
  return paperDirection === PaperDirection.VERTICAL ? width : height;
@@ -14913,6 +15007,9 @@ class Draw {
14913
15007
  getLineBreakParticle() {
14914
15008
  return this.lineBreakParticle;
14915
15009
  }
15010
+ getTextParticle() {
15011
+ return this.textParticle;
15012
+ }
14916
15013
  getHeaderElementList() {
14917
15014
  return this.header.getElementList();
14918
15015
  }
@@ -15319,10 +15416,11 @@ class Draw {
15319
15416
  options: deepClone(this.options)
15320
15417
  };
15321
15418
  }
15322
- setValue(payload) {
15419
+ setValue(payload, options) {
15323
15420
  const { header, main, footer } = deepClone(payload);
15324
15421
  if (!header && !main && !footer)
15325
15422
  return;
15423
+ const { isSetCursor = false } = options || {};
15326
15424
  const pageComponentData = [header, main, footer];
15327
15425
  pageComponentData.forEach((data2) => {
15328
15426
  if (!data2)
@@ -15337,8 +15435,13 @@ class Draw {
15337
15435
  footer
15338
15436
  });
15339
15437
  this.historyManager.recovery();
15438
+ const curIndex = isSetCursor ? (main == null ? void 0 : main.length) ? main.length - 1 : 0 : void 0;
15439
+ if (curIndex !== void 0) {
15440
+ this.range.setRange(curIndex, curIndex);
15441
+ }
15340
15442
  this.render({
15341
- isSetCursor: false,
15443
+ curIndex,
15444
+ isSetCursor,
15342
15445
  isFirstRender: true
15343
15446
  });
15344
15447
  }
@@ -15426,6 +15529,7 @@ class Draw {
15426
15529
  ascent: 0,
15427
15530
  elementList: [],
15428
15531
  startIndex: 0,
15532
+ rowIndex: 0,
15429
15533
  rowFlex: ((_a = elementList == null ? void 0 : elementList[0]) == null ? void 0 : _a.rowFlex) || ((_b = elementList == null ? void 0 : elementList[1]) == null ? void 0 : _b.rowFlex)
15430
15534
  });
15431
15535
  }
@@ -15760,6 +15864,7 @@ class Draw {
15760
15864
  startIndex: i,
15761
15865
  elementList: [rowElement],
15762
15866
  ascent,
15867
+ rowIndex: curRow.rowIndex + 1,
15763
15868
  rowFlex: ((_g = elementList[i]) == null ? void 0 : _g.rowFlex) || ((_h = elementList[i + 1]) == null ? void 0 : _h.rowFlex),
15764
15869
  isPageBreak: element.type === ElementType.PAGE_BREAK
15765
15870
  };
@@ -16090,7 +16195,7 @@ class Draw {
16090
16195
  _drawPage(payload) {
16091
16196
  var _a, _b;
16092
16197
  const { elementList, positionList, rowList, pageNo } = payload;
16093
- const { inactiveAlpha, pageMode, header, footer, pageNumber } = this.options;
16198
+ const { inactiveAlpha, pageMode, header, footer, pageNumber, lineNumber } = this.options;
16094
16199
  const innerWidth = this.getInnerWidth();
16095
16200
  const ctx = this.ctxList[pageNo];
16096
16201
  ctx.globalAlpha = !this.zone.isMainActive() ? inactiveAlpha : 1;
@@ -16138,6 +16243,9 @@ class Draw {
16138
16243
  if (this.elementList.length <= 1 && !((_b = this.elementList[0]) == null ? void 0 : _b.listId)) {
16139
16244
  this.placeholder.render(ctx);
16140
16245
  }
16246
+ if (!lineNumber.disabled) {
16247
+ this.lineNumber.render(ctx, pageNo);
16248
+ }
16141
16249
  }
16142
16250
  _disconnectLazyRender() {
16143
16251
  var _a;
@@ -16575,7 +16683,8 @@ const defaultBackground = {
16575
16683
  color: "#FFFFFF",
16576
16684
  image: "",
16577
16685
  size: BackgroundSize.COVER,
16578
- repeat: BackgroundRepeat.NO_REPEAT
16686
+ repeat: BackgroundRepeat.NO_REPEAT,
16687
+ applyPageNumbers: []
16579
16688
  };
16580
16689
  const defaultCheckboxOption = {
16581
16690
  width: 14,
@@ -16647,6 +16756,14 @@ const defaultTableOption = {
16647
16756
  const defaultZoneOption = {
16648
16757
  tipDisabled: true
16649
16758
  };
16759
+ const defaultLineNumberOption = {
16760
+ size: 12,
16761
+ font: "Microsoft YaHei",
16762
+ color: "#000000",
16763
+ disabled: true,
16764
+ right: 20,
16765
+ type: LineNumberType.CONTINUITY
16766
+ };
16650
16767
  function mergeOption(options = {}) {
16651
16768
  const tableOptions = __spreadValues(__spreadValues({}, defaultTableOption), options.table);
16652
16769
  const headerOptions = __spreadValues(__spreadValues({}, defaultHeaderOption), options.header);
@@ -16665,6 +16782,7 @@ function mergeOption(options = {}) {
16665
16782
  const backgroundOptions = __spreadValues(__spreadValues({}, defaultBackground), options.background);
16666
16783
  const lineBreakOptions = __spreadValues(__spreadValues({}, defaultLineBreak), options.lineBreak);
16667
16784
  const separatorOptions = __spreadValues(__spreadValues({}, defaultSeparatorOption), options.separator);
16785
+ const lineNumberOptions = __spreadValues(__spreadValues({}, defaultLineNumberOption), options.lineNumber);
16668
16786
  return __spreadProps(__spreadValues({
16669
16787
  mode: EditorMode.EDIT,
16670
16788
  defaultType: "TEXT",
@@ -16723,7 +16841,8 @@ function mergeOption(options = {}) {
16723
16841
  zone: zoneOptions,
16724
16842
  background: backgroundOptions,
16725
16843
  lineBreak: lineBreakOptions,
16726
- separator: separatorOptions
16844
+ separator: separatorOptions,
16845
+ lineNumber: lineNumberOptions
16727
16846
  });
16728
16847
  }
16729
16848
  function printImageBase64(base64List, options) {
@@ -16922,13 +17041,13 @@ class CommandAdapt {
16922
17041
  this.draw.setPainterStyle(painterStyle, options);
16923
17042
  }
16924
17043
  applyPainterStyle() {
16925
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17044
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16926
17045
  if (isDisabled)
16927
17046
  return;
16928
17047
  this.canvasEvent.applyPainterStyle();
16929
17048
  }
16930
17049
  format() {
16931
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17050
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16932
17051
  if (isDisabled)
16933
17052
  return;
16934
17053
  const selection = this.range.getSelectionElementList();
@@ -16956,7 +17075,7 @@ class CommandAdapt {
16956
17075
  this.draw.render(renderOption);
16957
17076
  }
16958
17077
  font(payload) {
16959
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17078
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16960
17079
  if (isDisabled)
16961
17080
  return;
16962
17081
  const selection = this.range.getSelectionElementList();
@@ -16979,7 +17098,7 @@ class CommandAdapt {
16979
17098
  const { minSize, maxSize, defaultSize } = this.options;
16980
17099
  if (payload < minSize || payload > maxSize)
16981
17100
  return;
16982
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17101
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
16983
17102
  if (isDisabled)
16984
17103
  return;
16985
17104
  let renderOption = {};
@@ -17012,7 +17131,7 @@ class CommandAdapt {
17012
17131
  }
17013
17132
  }
17014
17133
  sizeAdd() {
17015
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17134
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17016
17135
  if (isDisabled)
17017
17136
  return;
17018
17137
  const selection = this.range.getTextLikeSelectionElementList();
@@ -17052,7 +17171,7 @@ class CommandAdapt {
17052
17171
  }
17053
17172
  }
17054
17173
  sizeMinus() {
17055
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17174
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17056
17175
  if (isDisabled)
17057
17176
  return;
17058
17177
  const selection = this.range.getTextLikeSelectionElementList();
@@ -17092,7 +17211,7 @@ class CommandAdapt {
17092
17211
  }
17093
17212
  }
17094
17213
  bold() {
17095
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17214
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17096
17215
  if (isDisabled)
17097
17216
  return;
17098
17217
  const selection = this.range.getSelectionElementList();
@@ -17113,7 +17232,7 @@ class CommandAdapt {
17113
17232
  }
17114
17233
  }
17115
17234
  italic() {
17116
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17235
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17117
17236
  if (isDisabled)
17118
17237
  return;
17119
17238
  const selection = this.range.getSelectionElementList();
@@ -17134,7 +17253,7 @@ class CommandAdapt {
17134
17253
  }
17135
17254
  }
17136
17255
  underline(textDecoration) {
17137
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17256
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17138
17257
  if (isDisabled)
17139
17258
  return;
17140
17259
  const selection = this.range.getSelectionElementList();
@@ -17163,7 +17282,7 @@ class CommandAdapt {
17163
17282
  }
17164
17283
  }
17165
17284
  strikeout() {
17166
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17285
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17167
17286
  if (isDisabled)
17168
17287
  return;
17169
17288
  const selection = this.range.getSelectionElementList();
@@ -17187,7 +17306,7 @@ class CommandAdapt {
17187
17306
  }
17188
17307
  }
17189
17308
  superscript() {
17190
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17309
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17191
17310
  if (isDisabled)
17192
17311
  return;
17193
17312
  const selection = this.range.getSelectionElementList();
@@ -17209,7 +17328,7 @@ class CommandAdapt {
17209
17328
  this.draw.render({ isSetCursor: false });
17210
17329
  }
17211
17330
  subscript() {
17212
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17331
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17213
17332
  if (isDisabled)
17214
17333
  return;
17215
17334
  const selection = this.range.getSelectionElementList();
@@ -17231,7 +17350,7 @@ class CommandAdapt {
17231
17350
  this.draw.render({ isSetCursor: false });
17232
17351
  }
17233
17352
  color(payload) {
17234
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17353
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17235
17354
  if (isDisabled)
17236
17355
  return;
17237
17356
  const selection = this.range.getSelectionElementList();
@@ -17262,7 +17381,7 @@ class CommandAdapt {
17262
17381
  }
17263
17382
  }
17264
17383
  highlight(payload) {
17265
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
17384
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
17266
17385
  if (isDisabled)
17267
17386
  return;
17268
17387
  const selection = this.range.getSelectionElementList();
@@ -18311,7 +18430,7 @@ class CommandAdapt {
18311
18430
  }
18312
18431
  }
18313
18432
  image(payload) {
18314
- const isDisabled = this.draw.isReadonly() || this.control.getIsDisabledControl();
18433
+ const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
18315
18434
  if (isDisabled)
18316
18435
  return;
18317
18436
  const { startIndex, endIndex } = this.range.getRange();
@@ -18741,8 +18860,8 @@ class CommandAdapt {
18741
18860
  }
18742
18861
  }
18743
18862
  }
18744
- setValue(payload) {
18745
- this.draw.setValue(payload);
18863
+ setValue(payload, options) {
18864
+ this.draw.setValue(payload, options);
18746
18865
  }
18747
18866
  removeControl() {
18748
18867
  const { startIndex, endIndex } = this.range.getRange();
@@ -18869,16 +18988,16 @@ class CommandAdapt {
18869
18988
  this.draw.getZone().setZone(zone2);
18870
18989
  }
18871
18990
  getControlValue(payload) {
18872
- return this.draw.getControl().getValueByConceptId(payload);
18991
+ return this.draw.getControl().getValueById(payload);
18873
18992
  }
18874
18993
  setControlValue(payload) {
18875
- this.draw.getControl().setValueByConceptId(payload);
18994
+ this.draw.getControl().setValueById(payload);
18876
18995
  }
18877
18996
  setControlExtension(payload) {
18878
- this.draw.getControl().setExtensionByConceptId(payload);
18997
+ this.draw.getControl().setExtensionById(payload);
18879
18998
  }
18880
18999
  setControlProperties(payload) {
18881
- this.draw.getControl().setPropertiesByConceptId(payload);
19000
+ this.draw.getControl().setPropertiesById(payload);
18882
19001
  }
18883
19002
  setControlHighlight(payload) {
18884
19003
  this.draw.getControl().setHighlightList(payload);
@@ -19748,7 +19867,9 @@ class ContextMenu {
19748
19867
  const originalElementList = this.draw.getOriginalElementList();
19749
19868
  const originTableElement = originalElementList[index2] || null;
19750
19869
  if (originTableElement) {
19751
- tableElement = zipElementList([originTableElement])[0];
19870
+ tableElement = zipElementList([originTableElement], {
19871
+ extraPickAttrs: ["id"]
19872
+ })[0];
19752
19873
  }
19753
19874
  }
19754
19875
  const isCrossRowCol = isTable && !!crossRowCol;
@@ -20247,5 +20368,5 @@ class Editor {
20247
20368
  this.use = plugin.use.bind(plugin);
20248
20369
  }
20249
20370
  }
20250
- export { BackgroundRepeat, BackgroundSize, BlockType, Command, ControlIndentation, ControlType, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, INTERNAL_CONTEXT_MENU_KEY, ImageDisplay, KeyMap, LETTER_CLASS, ListStyle, ListType, MaxHeightRatio, NumberType, PageMode, PaperDirection, RenderMode, RowFlex, TableBorder, TdBorder, TdSlash, TextDecorationStyle, TitleLevel, VerticalAlign, WordBreak, Editor as default, splitText };
20371
+ export { BackgroundRepeat, BackgroundSize, BlockType, Command, ControlIndentation, ControlType, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, INTERNAL_CONTEXT_MENU_KEY, ImageDisplay, KeyMap, LETTER_CLASS, LineNumberType, ListStyle, ListType, MaxHeightRatio, NumberType, PageMode, PaperDirection, RenderMode, RowFlex, TableBorder, TdBorder, TdSlash, TextDecorationStyle, TitleLevel, VerticalAlign, WordBreak, Editor as default, splitText };
20251
20372
  //# sourceMappingURL=canvas-editor.es.js.map