@hufe921/canvas-editor 0.9.82 → 0.9.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## [0.9.84](https://github.com/Hufe921/canvas-editor/compare/v0.9.83...v0.9.84) (2024-06-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * merge table cell boundary error #661 ([146ac75](https://github.com/Hufe921/canvas-editor/commit/146ac75a002338f13c96900a2849062c29018606)), closes [#661](https://github.com/Hufe921/canvas-editor/issues/661)
7
+ * set default style for control using executeSetControlProperties #658 ([7b5079c](https://github.com/Hufe921/canvas-editor/commit/7b5079c9b638730f7ea609239b3cb91b915d4650)), closes [#658](https://github.com/Hufe921/canvas-editor/issues/658)
8
+
9
+
10
+ ### Features
11
+
12
+ * optimization of table operations in form mode #662 ([b740637](https://github.com/Hufe921/canvas-editor/commit/b74063741f413d5bf6f90c748761f64141405ca7)), closes [#662](https://github.com/Hufe921/canvas-editor/issues/662)
13
+ * override method with default interception behavior #663 ([9a4b4f9](https://github.com/Hufe921/canvas-editor/commit/9a4b4f9a4a70a344740212507e250d9bdea5dd32)), closes [#663](https://github.com/Hufe921/canvas-editor/issues/663)
14
+
15
+
16
+
17
+ ## [0.9.83](https://github.com/Hufe921/canvas-editor/compare/v0.9.82...v0.9.83) (2024-06-21)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * executeSetControlProperties api invalid in table #653 ([fdcf639](https://github.com/Hufe921/canvas-editor/commit/fdcf6397e1ce62ef1ed18a526a0642c3f120df3b)), closes [#653](https://github.com/Hufe921/canvas-editor/issues/653)
23
+
24
+
25
+ ### Features
26
+
27
+ * add clear format attributes ([e21533a](https://github.com/Hufe921/canvas-editor/commit/e21533a3d1cfeecde562aaa6c52ee306e5063a01))
28
+ * add conceptId attribute to table td #654 ([959a062](https://github.com/Hufe921/canvas-editor/commit/959a062f830042b78af498e2d6cbc4e5f82fa3d4)), closes [#654](https://github.com/Hufe921/canvas-editor/issues/654)
29
+ * add mouse event listener #603 ([a2978bd](https://github.com/Hufe921/canvas-editor/commit/a2978bd1f507e9417b995bbb0b7ff756dbe5d2c4)), closes [#603](https://github.com/Hufe921/canvas-editor/issues/603)
30
+ * copy table structure and data #516 ([76c20a6](https://github.com/Hufe921/canvas-editor/commit/76c20a6b44914396ae7dd69a7c97db1b179937c2)), closes [#516](https://github.com/Hufe921/canvas-editor/issues/516)
31
+
32
+
33
+
1
34
  ## [0.9.82](https://github.com/Hufe921/canvas-editor/compare/v0.9.81...v0.9.82) (2024-06-14)
2
35
 
3
36
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.82";
26
+ const version = "0.9.84";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -364,6 +364,10 @@ function isObjectEqual(obj1, obj2) {
364
364
  }
365
365
  return !obj1Keys.some((key) => obj2[key] !== obj1[key]);
366
366
  }
367
+ function isPromiseFunction(fn) {
368
+ var _a;
369
+ return ((_a = fn == null ? void 0 : fn.constructor) == null ? void 0 : _a.name) === "AsyncFunction";
370
+ }
367
371
  const CURSOR_AGENT_OFFSET_HEIGHT = 12;
368
372
  const defaultCursorOption = {
369
373
  width: 1,
@@ -471,6 +475,7 @@ const EDITOR_ELEMENT_ZIP_ATTR = [
471
475
  "externalId"
472
476
  ];
473
477
  const TABLE_TD_ZIP_ATTR = [
478
+ "conceptId",
474
479
  "verticalAlign",
475
480
  "backgroundColor",
476
481
  "borderTypes",
@@ -5055,7 +5060,7 @@ function pasteImage(host, file) {
5055
5060
  };
5056
5061
  };
5057
5062
  }
5058
- function pasteByEvent(host, evt) {
5063
+ async function pasteByEvent(host, evt) {
5059
5064
  const draw = host.getDraw();
5060
5065
  const isReadonly = draw.isReadonly();
5061
5066
  if (isReadonly)
@@ -5065,8 +5070,9 @@ function pasteByEvent(host, evt) {
5065
5070
  return;
5066
5071
  const { paste } = draw.getOverride();
5067
5072
  if (paste) {
5068
- paste(evt);
5069
- return;
5073
+ const overrideResult = isPromiseFunction(paste) ? await paste(evt) : paste(evt);
5074
+ if ((overrideResult == null ? void 0 : overrideResult.preventDefault) !== false)
5075
+ return;
5070
5076
  }
5071
5077
  if (!getIsClipboardContainFile(clipboardData)) {
5072
5078
  const clipboardText = clipboardData.getData("text");
@@ -5117,8 +5123,9 @@ async function pasteByApi(host, options) {
5117
5123
  return;
5118
5124
  const { paste } = draw.getOverride();
5119
5125
  if (paste) {
5120
- paste();
5121
- return;
5126
+ const overrideResult = isPromiseFunction(paste) ? await paste() : paste();
5127
+ if ((overrideResult == null ? void 0 : overrideResult.preventDefault) !== false)
5128
+ return;
5122
5129
  }
5123
5130
  const clipboardText = await navigator.clipboard.readText();
5124
5131
  const editorClipboardData = getClipboardData();
@@ -5189,9 +5196,10 @@ class CursorAgent {
5189
5196
  this.canvasEvent.keydown(evt);
5190
5197
  }
5191
5198
  _input(evt) {
5192
- if (!evt.data)
5199
+ const data2 = evt.data;
5200
+ if (!data2)
5193
5201
  return;
5194
- this.canvasEvent.input(evt.data);
5202
+ this.canvasEvent.input(data2);
5195
5203
  }
5196
5204
  _paste(evt) {
5197
5205
  const isReadonly = this.draw.isReadonly();
@@ -5351,6 +5359,51 @@ class Cursor {
5351
5359
  }
5352
5360
  }
5353
5361
  }
5362
+ var EditorComponent;
5363
+ (function(EditorComponent2) {
5364
+ EditorComponent2["COMPONENT"] = "component";
5365
+ EditorComponent2["MENU"] = "menu";
5366
+ EditorComponent2["MAIN"] = "main";
5367
+ EditorComponent2["FOOTER"] = "footer";
5368
+ EditorComponent2["CONTEXTMENU"] = "contextmenu";
5369
+ EditorComponent2["POPUP"] = "popup";
5370
+ EditorComponent2["CATALOG"] = "catalog";
5371
+ EditorComponent2["COMMENT"] = "comment";
5372
+ })(EditorComponent || (EditorComponent = {}));
5373
+ var EditorContext;
5374
+ (function(EditorContext2) {
5375
+ EditorContext2["PAGE"] = "page";
5376
+ EditorContext2["TABLE"] = "table";
5377
+ })(EditorContext || (EditorContext = {}));
5378
+ var EditorMode;
5379
+ (function(EditorMode2) {
5380
+ EditorMode2["EDIT"] = "edit";
5381
+ EditorMode2["CLEAN"] = "clean";
5382
+ EditorMode2["READONLY"] = "readonly";
5383
+ EditorMode2["FORM"] = "form";
5384
+ EditorMode2["PRINT"] = "print";
5385
+ })(EditorMode || (EditorMode = {}));
5386
+ var EditorZone;
5387
+ (function(EditorZone2) {
5388
+ EditorZone2["HEADER"] = "header";
5389
+ EditorZone2["MAIN"] = "main";
5390
+ EditorZone2["FOOTER"] = "footer";
5391
+ })(EditorZone || (EditorZone = {}));
5392
+ var PageMode;
5393
+ (function(PageMode2) {
5394
+ PageMode2["PAGING"] = "paging";
5395
+ PageMode2["CONTINUITY"] = "continuity";
5396
+ })(PageMode || (PageMode = {}));
5397
+ var PaperDirection;
5398
+ (function(PaperDirection2) {
5399
+ PaperDirection2["VERTICAL"] = "vertical";
5400
+ PaperDirection2["HORIZONTAL"] = "horizontal";
5401
+ })(PaperDirection || (PaperDirection = {}));
5402
+ var WordBreak;
5403
+ (function(WordBreak2) {
5404
+ WordBreak2["BREAK_ALL"] = "break-all";
5405
+ WordBreak2["BREAK_WORD"] = "break-word";
5406
+ })(WordBreak || (WordBreak = {}));
5354
5407
  var MouseEventButton;
5355
5408
  (function(MouseEventButton2) {
5356
5409
  MouseEventButton2[MouseEventButton2["LEFT"] = 0] = "LEFT";
@@ -5688,10 +5741,14 @@ function mousedown(evt, host) {
5688
5741
  const previewer = draw.getPreviewer();
5689
5742
  previewer.clearResizer();
5690
5743
  if (isDirectHitImage) {
5691
- previewer.drawResizer(curElement, positionList[curIndex], curElement.type === ElementType.LATEX ? {
5692
- mime: "svg",
5693
- srcKey: "laTexSVG"
5694
- } : {});
5744
+ const previewerDrawOption = {
5745
+ dragDisable: isReadonly || !curElement.controlId && draw.getMode() === EditorMode.FORM
5746
+ };
5747
+ if (curElement.type === ElementType.LATEX) {
5748
+ previewerDrawOption.mime = "svg";
5749
+ previewerDrawOption.srcKey = "laTexSVG";
5750
+ }
5751
+ previewer.drawResizer(curElement, positionList[curIndex], previewerDrawOption);
5695
5752
  draw.getCursor().drawCursor({
5696
5753
  isShow: false
5697
5754
  });
@@ -5702,7 +5759,7 @@ function mousedown(evt, host) {
5702
5759
  }
5703
5760
  const tableTool = draw.getTableTool();
5704
5761
  tableTool.dispose();
5705
- if (isTable && !isReadonly) {
5762
+ if (isTable && !isReadonly && draw.getMode() !== EditorMode.FORM) {
5706
5763
  tableTool.render();
5707
5764
  }
5708
5765
  const hyperlinkParticle = draw.getHyperlinkParticle();
@@ -5989,51 +6046,6 @@ function mousemove(evt, host) {
5989
6046
  isCompute: false
5990
6047
  });
5991
6048
  }
5992
- var EditorComponent;
5993
- (function(EditorComponent2) {
5994
- EditorComponent2["COMPONENT"] = "component";
5995
- EditorComponent2["MENU"] = "menu";
5996
- EditorComponent2["MAIN"] = "main";
5997
- EditorComponent2["FOOTER"] = "footer";
5998
- EditorComponent2["CONTEXTMENU"] = "contextmenu";
5999
- EditorComponent2["POPUP"] = "popup";
6000
- EditorComponent2["CATALOG"] = "catalog";
6001
- EditorComponent2["COMMENT"] = "comment";
6002
- })(EditorComponent || (EditorComponent = {}));
6003
- var EditorContext;
6004
- (function(EditorContext2) {
6005
- EditorContext2["PAGE"] = "page";
6006
- EditorContext2["TABLE"] = "table";
6007
- })(EditorContext || (EditorContext = {}));
6008
- var EditorMode;
6009
- (function(EditorMode2) {
6010
- EditorMode2["EDIT"] = "edit";
6011
- EditorMode2["CLEAN"] = "clean";
6012
- EditorMode2["READONLY"] = "readonly";
6013
- EditorMode2["FORM"] = "form";
6014
- EditorMode2["PRINT"] = "print";
6015
- })(EditorMode || (EditorMode = {}));
6016
- var EditorZone;
6017
- (function(EditorZone2) {
6018
- EditorZone2["HEADER"] = "header";
6019
- EditorZone2["MAIN"] = "main";
6020
- EditorZone2["FOOTER"] = "footer";
6021
- })(EditorZone || (EditorZone = {}));
6022
- var PageMode;
6023
- (function(PageMode2) {
6024
- PageMode2["PAGING"] = "paging";
6025
- PageMode2["CONTINUITY"] = "continuity";
6026
- })(PageMode || (PageMode = {}));
6027
- var PaperDirection;
6028
- (function(PaperDirection2) {
6029
- PaperDirection2["VERTICAL"] = "vertical";
6030
- PaperDirection2["HORIZONTAL"] = "horizontal";
6031
- })(PaperDirection || (PaperDirection = {}));
6032
- var WordBreak;
6033
- (function(WordBreak2) {
6034
- WordBreak2["BREAK_ALL"] = "break-all";
6035
- WordBreak2["BREAK_WORD"] = "break-word";
6036
- })(WordBreak || (WordBreak = {}));
6037
6049
  function backspace(evt, host) {
6038
6050
  const draw = host.getDraw();
6039
6051
  if (draw.isReadonly())
@@ -6970,26 +6982,66 @@ function cut(host) {
6970
6982
  rangeManager.setRange(curIndex, curIndex);
6971
6983
  draw.render({ curIndex });
6972
6984
  }
6973
- function copy(host) {
6985
+ async function copy(host) {
6974
6986
  const draw = host.getDraw();
6975
6987
  const { copy: copy2 } = draw.getOverride();
6976
6988
  if (copy2) {
6977
- copy2();
6978
- return;
6989
+ const overrideResult = isPromiseFunction(copy2) ? await copy2() : copy2();
6990
+ if ((overrideResult == null ? void 0 : overrideResult.preventDefault) !== false)
6991
+ return;
6979
6992
  }
6980
6993
  const rangeManager = draw.getRange();
6981
- const copyElementList = rangeManager.getIsCollapsed() ? rangeManager.getRangeRowElementList() : rangeManager.getSelectionElementList();
6994
+ let copyElementList = null;
6995
+ const range = rangeManager.getRange();
6996
+ if (range.isCrossRowCol) {
6997
+ const tableElement = rangeManager.getRangeTableElement();
6998
+ if (!tableElement)
6999
+ return;
7000
+ const rowCol = draw.getTableParticle().getRangeRowCol();
7001
+ if (!rowCol)
7002
+ return;
7003
+ const copyTableElement = {
7004
+ type: ElementType.TABLE,
7005
+ value: "",
7006
+ colgroup: [],
7007
+ trList: []
7008
+ };
7009
+ const firstRow = rowCol[0];
7010
+ const colStartIndex = firstRow[0].colIndex;
7011
+ const lastCol = firstRow[firstRow.length - 1];
7012
+ const colEndIndex = lastCol.colIndex + lastCol.colspan - 1;
7013
+ for (let c = colStartIndex; c <= colEndIndex; c++) {
7014
+ copyTableElement.colgroup.push(tableElement.colgroup[c]);
7015
+ }
7016
+ for (let r = 0; r < rowCol.length; r++) {
7017
+ const row = rowCol[r];
7018
+ const tr = tableElement.trList[row[0].rowIndex];
7019
+ const coptTr = {
7020
+ tdList: [],
7021
+ height: tr.height,
7022
+ minHeight: tr.minHeight
7023
+ };
7024
+ for (let c = 0; c < row.length; c++) {
7025
+ coptTr.tdList.push(row[c]);
7026
+ }
7027
+ copyTableElement.trList.push(coptTr);
7028
+ }
7029
+ copyElementList = zipElementList([copyTableElement]);
7030
+ } else {
7031
+ copyElementList = rangeManager.getIsCollapsed() ? rangeManager.getRangeRowElementList() : rangeManager.getSelectionElementList();
7032
+ }
6982
7033
  if (!(copyElementList == null ? void 0 : copyElementList.length))
6983
7034
  return;
6984
7035
  writeElementList(copyElementList, draw.getOptions());
6985
7036
  }
6986
- function drop(evt, host) {
7037
+ async function drop(evt, host) {
6987
7038
  var _a, _b;
6988
7039
  const draw = host.getDraw();
6989
7040
  const { drop: drop2 } = draw.getOverride();
6990
7041
  if (drop2) {
6991
- drop2(evt);
6992
- return;
7042
+ const overrideResult = isPromiseFunction(drop2) ? await drop2(evt) : drop2(evt);
7043
+ if ((overrideResult == null ? void 0 : overrideResult.preventDefault) !== false)
7044
+ return;
6993
7045
  }
6994
7046
  evt.preventDefault();
6995
7047
  const data2 = (_a = evt.dataTransfer) == null ? void 0 : _a.getData("text");
@@ -7824,6 +7876,7 @@ class Position {
7824
7876
  x,
7825
7877
  y,
7826
7878
  td,
7879
+ pageNo: curPageNo,
7827
7880
  tablePosition: positionList[j],
7828
7881
  isTable: true,
7829
7882
  elementList: td.value,
@@ -7884,6 +7937,7 @@ class Position {
7884
7937
  }
7885
7938
  }
7886
7939
  return {
7940
+ isDirectHit: true,
7887
7941
  hitLineStartIndex: hitLineStartIndex2,
7888
7942
  index: curPositionIndex2,
7889
7943
  isControl: !!element.controlId
@@ -8287,6 +8341,13 @@ class RangeManager {
8287
8341
  var _a;
8288
8342
  return ((_a = this.getRangeParagraphInfo()) == null ? void 0 : _a.elementList) || null;
8289
8343
  }
8344
+ getRangeTableElement() {
8345
+ const positionContext = this.position.getPositionContext();
8346
+ if (!positionContext.isTable)
8347
+ return null;
8348
+ const originalElementList = this.draw.getOriginalElementList();
8349
+ return originalElementList[positionContext.index];
8350
+ }
8290
8351
  getIsSelectAll() {
8291
8352
  const elementList = this.draw.getElementList();
8292
8353
  const { startIndex, endIndex } = this.range;
@@ -9719,6 +9780,8 @@ class TableParticle {
9719
9780
  td.height = height;
9720
9781
  td.rowIndex = t;
9721
9782
  td.colIndex = colIndex;
9783
+ td.trIndex = t;
9784
+ td.tdIndex = d;
9722
9785
  preX += width;
9723
9786
  if (isLastRowTd && !isLastTd) {
9724
9787
  preX = 0;
@@ -12251,29 +12314,39 @@ class Control {
12251
12314
  }
12252
12315
  }
12253
12316
  setPropertiesByConceptId(payload) {
12254
- var _a;
12255
12317
  const isReadonly = this.draw.isReadonly();
12256
12318
  if (isReadonly)
12257
12319
  return;
12258
12320
  const { conceptId, properties } = payload;
12259
12321
  let isExistUpdate = false;
12260
- const pageComponentData = {
12261
- header: this.draw.getHeaderElementList(),
12262
- main: this.draw.getOriginalMainElementList(),
12263
- footer: this.draw.getFooterElementList()
12264
- };
12265
- for (const key in pageComponentData) {
12266
- const elementList = pageComponentData[key];
12322
+ function setProperties(elementList) {
12323
+ var _a;
12267
12324
  let i = 0;
12268
12325
  while (i < elementList.length) {
12269
12326
  const element = elementList[i];
12270
12327
  i++;
12328
+ if (element.type === ElementType.TABLE) {
12329
+ const trList = element.trList;
12330
+ for (let r = 0; r < trList.length; r++) {
12331
+ const tr = trList[r];
12332
+ for (let d = 0; d < tr.tdList.length; d++) {
12333
+ const td = tr.tdList[d];
12334
+ setProperties(td.value);
12335
+ }
12336
+ }
12337
+ }
12271
12338
  if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
12272
12339
  continue;
12273
12340
  isExistUpdate = true;
12274
12341
  element.control = __spreadProps(__spreadValues(__spreadValues({}, element.control), properties), {
12275
12342
  value: element.control.value
12276
12343
  });
12344
+ CONTROL_STYLE_ATTR.forEach((key) => {
12345
+ const controlStyleProperty = properties[key];
12346
+ if (controlStyleProperty) {
12347
+ Reflect.set(element, key, controlStyleProperty);
12348
+ }
12349
+ });
12277
12350
  let newEndIndex = i;
12278
12351
  while (newEndIndex < elementList.length) {
12279
12352
  const nextElement = elementList[newEndIndex];
@@ -12284,6 +12357,15 @@ class Control {
12284
12357
  i = newEndIndex;
12285
12358
  }
12286
12359
  }
12360
+ const pageComponentData = {
12361
+ header: this.draw.getHeaderElementList(),
12362
+ main: this.draw.getOriginalMainElementList(),
12363
+ footer: this.draw.getFooterElementList()
12364
+ };
12365
+ for (const key in pageComponentData) {
12366
+ const elementList = pageComponentData[key];
12367
+ setProperties(elementList);
12368
+ }
12287
12369
  if (!isExistUpdate)
12288
12370
  return;
12289
12371
  for (const key in pageComponentData) {
@@ -12875,7 +12957,7 @@ class Previewer {
12875
12957
  document.addEventListener("mousemove", mousemoveFn);
12876
12958
  document.addEventListener("mouseup", () => {
12877
12959
  var _a;
12878
- if (this.curElement) {
12960
+ if (this.curElement && !this.previewerDrawOption.dragDisable) {
12879
12961
  this.curElement.width = this.width;
12880
12962
  this.curElement.height = this.height;
12881
12963
  this.draw.render({
@@ -12893,7 +12975,7 @@ class Previewer {
12893
12975
  evt.preventDefault();
12894
12976
  }
12895
12977
  _mousemove(evt) {
12896
- if (!this.curElement)
12978
+ if (!this.curElement || this.previewerDrawOption.dragDisable)
12897
12979
  return;
12898
12980
  const { scale } = this.options;
12899
12981
  let dx = 0;
@@ -14372,6 +14454,34 @@ class Group {
14372
14454
  this.clearFillInfo();
14373
14455
  }
14374
14456
  }
14457
+ class MouseObserver {
14458
+ constructor(draw) {
14459
+ __publicField(this, "draw");
14460
+ __publicField(this, "eventBus");
14461
+ __publicField(this, "pageContainer");
14462
+ this.draw = draw;
14463
+ this.eventBus = this.draw.getEventBus();
14464
+ this.pageContainer = this.draw.getPageContainer();
14465
+ this.pageContainer.addEventListener("mousemove", this._mousemove.bind(this));
14466
+ this.pageContainer.addEventListener("mouseenter", this._mouseenter.bind(this));
14467
+ this.pageContainer.addEventListener("mouseleave", this._mouseleave.bind(this));
14468
+ }
14469
+ _mousemove(evt) {
14470
+ if (!this.eventBus.isSubscribe("mousemove"))
14471
+ return;
14472
+ this.eventBus.emit("mousemove", evt);
14473
+ }
14474
+ _mouseenter(evt) {
14475
+ if (!this.eventBus.isSubscribe("mouseenter"))
14476
+ return;
14477
+ this.eventBus.emit("mouseenter", evt);
14478
+ }
14479
+ _mouseleave(evt) {
14480
+ if (!this.eventBus.isSubscribe("mouseleave"))
14481
+ return;
14482
+ this.eventBus.emit("mouseleave", evt);
14483
+ }
14484
+ }
14375
14485
  class Draw {
14376
14486
  constructor(rootContainer, options, data2, listener, eventBus, override) {
14377
14487
  __publicField(this, "container");
@@ -14490,6 +14600,7 @@ class Draw {
14490
14600
  this.scrollObserver = new ScrollObserver(this);
14491
14601
  this.selectionObserver = new SelectionObserver(this);
14492
14602
  this.imageObserver = new ImageObserver();
14603
+ new MouseObserver(this);
14493
14604
  this.canvasEvent = new CanvasEvent(this);
14494
14605
  this.cursor = new Cursor(this, this.canvasEvent);
14495
14606
  this.canvasEvent.register();
@@ -14539,6 +14650,7 @@ class Draw {
14539
14650
  this.setEditorData(this.printModeData);
14540
14651
  this.printModeData = null;
14541
14652
  }
14653
+ this.clearSideEffect();
14542
14654
  this.range.clearRange();
14543
14655
  this.mode = payload;
14544
14656
  this.render({
@@ -16237,6 +16349,7 @@ class Command {
16237
16349
  __publicField(this, "getControlList");
16238
16350
  __publicField(this, "getContainer");
16239
16351
  __publicField(this, "getTitleValue");
16352
+ __publicField(this, "getPositionContextByEvent");
16240
16353
  this.executeMode = adapt.mode.bind(adapt);
16241
16354
  this.executeCut = adapt.cut.bind(adapt);
16242
16355
  this.executeCopy = adapt.copy.bind(adapt);
@@ -16343,6 +16456,7 @@ class Command {
16343
16456
  this.getGroupIds = adapt.getGroupIds.bind(adapt);
16344
16457
  this.getContainer = adapt.getContainer.bind(adapt);
16345
16458
  this.getTitleValue = adapt.getTitleValue.bind(adapt);
16459
+ this.getPositionContextByEvent = adapt.getPositionContextByEvent.bind(adapt);
16346
16460
  this.executeSetControlValue = adapt.setControlValue.bind(adapt);
16347
16461
  this.executeSetControlExtension = adapt.setControlExtension.bind(adapt);
16348
16462
  this.executeSetControlProperties = adapt.setControlProperties.bind(adapt);
@@ -16576,6 +16690,7 @@ class CommandAdapt {
16576
16690
  __publicField(this, "workerManager");
16577
16691
  __publicField(this, "searchManager");
16578
16692
  __publicField(this, "i18n");
16693
+ __publicField(this, "zone");
16579
16694
  this.draw = draw;
16580
16695
  this.range = draw.getRange();
16581
16696
  this.position = draw.getPosition();
@@ -16587,6 +16702,7 @@ class CommandAdapt {
16587
16702
  this.workerManager = draw.getWorkerManager();
16588
16703
  this.searchManager = draw.getSearch();
16589
16704
  this.i18n = draw.getI18n();
16705
+ this.zone = draw.getZone();
16590
16706
  }
16591
16707
  mode(payload) {
16592
16708
  this.draw.setMode(payload);
@@ -16740,13 +16856,9 @@ class CommandAdapt {
16740
16856
  if (!changeElementList.length)
16741
16857
  return;
16742
16858
  changeElementList.forEach((el) => {
16743
- delete el.size;
16744
- delete el.font;
16745
- delete el.color;
16746
- delete el.bold;
16747
- delete el.italic;
16748
- delete el.underline;
16749
- delete el.strikeout;
16859
+ EDITOR_ELEMENT_STYLE_ATTR.forEach((attr) => {
16860
+ delete el[attr];
16861
+ });
16750
16862
  });
16751
16863
  this.draw.render(renderOption);
16752
16864
  }
@@ -17684,7 +17796,11 @@ class CommandAdapt {
17684
17796
  d++;
17685
17797
  }
17686
17798
  }
17687
- const curIndex = startTd.value.length - 1;
17799
+ this.position.setPositionContext(__spreadProps(__spreadValues({}, positionContext), {
17800
+ trIndex: anchorTd.trIndex,
17801
+ tdIndex: anchorTd.tdIndex
17802
+ }));
17803
+ const curIndex = anchorTd.value.length - 1;
17688
17804
  this.range.setRange(curIndex, curIndex);
17689
17805
  this.draw.render();
17690
17806
  this.tableTool.render();
@@ -18840,6 +18956,50 @@ class CommandAdapt {
18840
18956
  }
18841
18957
  return result;
18842
18958
  }
18959
+ getPositionContextByEvent(evt) {
18960
+ var _a, _b, _c;
18961
+ const pageIndex = (_a = evt.target) == null ? void 0 : _a.dataset.index;
18962
+ if (!pageIndex)
18963
+ return null;
18964
+ const pageNo = Number(pageIndex);
18965
+ const positionContext = this.position.getPositionByXY({
18966
+ x: evt.offsetX,
18967
+ y: evt.offsetY,
18968
+ pageNo
18969
+ });
18970
+ const { isDirectHit, isTable, index: index2, trIndex, tdIndex, tdValueIndex, zone: zone2 } = positionContext;
18971
+ if (!isDirectHit || zone2 && zone2 !== this.zone.getZone())
18972
+ return null;
18973
+ let element = null;
18974
+ const elementList = this.draw.getOriginalElementList();
18975
+ let position = null;
18976
+ const positionList = this.position.getOriginalPositionList();
18977
+ if (isTable) {
18978
+ const td = (_b = elementList[index2].trList) == null ? void 0 : _b[trIndex].tdList[tdIndex];
18979
+ element = (td == null ? void 0 : td.value[tdValueIndex]) || null;
18980
+ position = ((_c = td == null ? void 0 : td.positionList) == null ? void 0 : _c[tdValueIndex]) || null;
18981
+ } else {
18982
+ element = elementList[index2] || null;
18983
+ position = positionList[index2] || null;
18984
+ }
18985
+ let rangeRect = null;
18986
+ if (position) {
18987
+ const { pageNo: pageNo2, coordinate: { leftTop, rightTop }, lineHeight } = position;
18988
+ const height = this.draw.getOriginalHeight();
18989
+ const pageGap = this.draw.getOriginalPageGap();
18990
+ rangeRect = {
18991
+ x: leftTop[0],
18992
+ y: leftTop[1] + pageNo2 * (height + pageGap),
18993
+ width: rightTop[0] - leftTop[0],
18994
+ height: lineHeight
18995
+ };
18996
+ }
18997
+ return {
18998
+ pageNo,
18999
+ element,
19000
+ rangeRect
19001
+ };
19002
+ }
18843
19003
  insertTitle(payload) {
18844
19004
  var _a;
18845
19005
  const isReadonly = this.draw.isReadonly();
@@ -18963,7 +19123,7 @@ const controlMenus = [
18963
19123
  i18nPath: "contextmenu.control.delete",
18964
19124
  when: (payload) => {
18965
19125
  var _a;
18966
- return !payload.isReadonly && !payload.editorHasSelection && !!((_a = payload.startElement) == null ? void 0 : _a.controlId);
19126
+ return !payload.isReadonly && !payload.editorHasSelection && !!((_a = payload.startElement) == null ? void 0 : _a.controlId) && payload.options.mode !== EditorMode.FORM;
18967
19127
  },
18968
19128
  callback: (command) => {
18969
19129
  command.executeRemoveControl();
@@ -19160,7 +19320,7 @@ const tableMenus = [
19160
19320
  i18nPath: "contextmenu.table.border",
19161
19321
  icon: "border-all",
19162
19322
  when: (payload) => {
19163
- return !payload.isReadonly && payload.isInTable;
19323
+ return !payload.isReadonly && payload.isInTable && payload.options.mode !== EditorMode.FORM;
19164
19324
  },
19165
19325
  childMenus: [
19166
19326
  {
@@ -19259,7 +19419,7 @@ const tableMenus = [
19259
19419
  i18nPath: "contextmenu.table.verticalAlign",
19260
19420
  icon: "vertical-align",
19261
19421
  when: (payload) => {
19262
- return !payload.isReadonly && payload.isInTable;
19422
+ return !payload.isReadonly && payload.isInTable && payload.options.mode !== EditorMode.FORM;
19263
19423
  },
19264
19424
  childMenus: [
19265
19425
  {
@@ -19296,7 +19456,7 @@ const tableMenus = [
19296
19456
  i18nPath: "contextmenu.table.insertRowCol",
19297
19457
  icon: "insert-row-col",
19298
19458
  when: (payload) => {
19299
- return !payload.isReadonly && payload.isInTable;
19459
+ return !payload.isReadonly && payload.isInTable && payload.options.mode !== EditorMode.FORM;
19300
19460
  },
19301
19461
  childMenus: [
19302
19462
  {
@@ -19342,7 +19502,7 @@ const tableMenus = [
19342
19502
  i18nPath: "contextmenu.table.deleteRowCol",
19343
19503
  icon: "delete-row-col",
19344
19504
  when: (payload) => {
19345
- return !payload.isReadonly && payload.isInTable;
19505
+ return !payload.isReadonly && payload.isInTable && payload.options.mode !== EditorMode.FORM;
19346
19506
  },
19347
19507
  childMenus: [
19348
19508
  {
@@ -19379,7 +19539,7 @@ const tableMenus = [
19379
19539
  i18nPath: "contextmenu.table.mergeCell",
19380
19540
  icon: "merge-cell",
19381
19541
  when: (payload) => {
19382
- return !payload.isReadonly && payload.isCrossRowCol;
19542
+ return !payload.isReadonly && payload.isCrossRowCol && payload.options.mode !== EditorMode.FORM;
19383
19543
  },
19384
19544
  callback: (command) => {
19385
19545
  command.executeMergeTableCell();
@@ -19390,7 +19550,7 @@ const tableMenus = [
19390
19550
  i18nPath: "contextmenu.table.mergeCancelCell",
19391
19551
  icon: "merge-cancel-cell",
19392
19552
  when: (payload) => {
19393
- return !payload.isReadonly && payload.isInTable;
19553
+ return !payload.isReadonly && payload.isInTable && payload.options.mode !== EditorMode.FORM;
19394
19554
  },
19395
19555
  callback: (command) => {
19396
19556
  command.executeCancelMergeTableCell();
@@ -19512,7 +19672,8 @@ class ContextMenu {
19512
19672
  isInTable: isTable,
19513
19673
  trIndex: trIndex != null ? trIndex : null,
19514
19674
  tdIndex: tdIndex != null ? tdIndex : null,
19515
- tableElement
19675
+ tableElement,
19676
+ options: this.options
19516
19677
  };
19517
19678
  }
19518
19679
  _createContextMenuContainer() {