@hufe921/canvas-editor 0.9.51 → 0.9.53

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.51";
26
+ const version = "0.9.53";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -257,6 +257,15 @@ function cloneProperty(properties, sourceElement, targetElement) {
257
257
  }
258
258
  }
259
259
  }
260
+ function pickObject(object, pickKeys) {
261
+ const newObject = {};
262
+ for (const key in object) {
263
+ if (pickKeys.includes(key)) {
264
+ newObject[key] = object[key];
265
+ }
266
+ }
267
+ return newObject;
268
+ }
260
269
  function omitObject(object, omitKeys) {
261
270
  const newObject = {};
262
271
  for (const key in object) {
@@ -5320,6 +5329,8 @@ function keydown(evt, host) {
5320
5329
  }
5321
5330
  curIndex = isCollapsed ? index2 - 1 : startIndex;
5322
5331
  }
5332
+ if (curIndex === null)
5333
+ return;
5323
5334
  rangeManager.setRange(curIndex, curIndex);
5324
5335
  draw.render({ curIndex });
5325
5336
  } else if (evt.key === KeyMap.Delete) {
@@ -5338,6 +5349,8 @@ function keydown(evt, host) {
5338
5349
  }
5339
5350
  curIndex = isCollapsed ? index2 : startIndex;
5340
5351
  }
5352
+ if (curIndex === null)
5353
+ return;
5341
5354
  rangeManager.setRange(curIndex, curIndex);
5342
5355
  draw.render({ curIndex });
5343
5356
  } else if (evt.key === KeyMap.Enter) {
@@ -5559,12 +5572,12 @@ function keydown(evt, host) {
5559
5572
  direction: isUp ? MoveDirection.UP : MoveDirection.DOWN
5560
5573
  });
5561
5574
  } else if (isMod(evt) && evt.key === KeyMap.Z) {
5562
- if (isReadonly)
5575
+ if (isReadonly && draw.getMode() !== EditorMode.FORM)
5563
5576
  return;
5564
5577
  historyManager.undo();
5565
5578
  evt.preventDefault();
5566
5579
  } else if (isMod(evt) && evt.key === KeyMap.Y) {
5567
- if (isReadonly)
5580
+ if (isReadonly && draw.getMode() !== EditorMode.FORM)
5568
5581
  return;
5569
5582
  historyManager.redo();
5570
5583
  evt.preventDefault();
@@ -5780,6 +5793,11 @@ function cut(host) {
5780
5793
  }
5781
5794
  function copy(host) {
5782
5795
  const draw = host.getDraw();
5796
+ const { copy: copy2 } = draw.getOverride();
5797
+ if (copy2) {
5798
+ copy2();
5799
+ return;
5800
+ }
5783
5801
  const rangeManager = draw.getRange();
5784
5802
  const copyElementList = rangeManager.getIsCollapsed() ? rangeManager.getRangeRowElementList() : rangeManager.getSelectionElementList();
5785
5803
  if (!(copyElementList == null ? void 0 : copyElementList.length))
@@ -5845,6 +5863,7 @@ function dblclick(host, evt) {
5845
5863
  isSetCursor: false,
5846
5864
  isCompute: false
5847
5865
  });
5866
+ rangeManager.setRangeStyle();
5848
5867
  }
5849
5868
  function threeClick(host) {
5850
5869
  const draw = host.getDraw();
@@ -8680,9 +8699,9 @@ class SelectControl {
8680
8699
  var _a;
8681
8700
  return ((_a = this.element.control) == null ? void 0 : _a.code) || null;
8682
8701
  }
8683
- getValue() {
8684
- const elementList = this.control.getElementList();
8685
- const { startIndex } = this.control.getRange();
8702
+ getValue(context = {}) {
8703
+ const elementList = context.elementList || this.control.getElementList();
8704
+ const { startIndex } = context.range || this.control.getRange();
8686
8705
  const startElement = elementList[startIndex];
8687
8706
  const data2 = [];
8688
8707
  let preIndex = startIndex;
@@ -8791,20 +8810,20 @@ class SelectControl {
8791
8810
  const valueSet = valueSets.find((v) => v.code === code);
8792
8811
  if (!valueSet)
8793
8812
  return;
8794
- const startIndex = this.clearSelect(context);
8795
- this.control.removePlaceholder(startIndex);
8796
8813
  const elementList = context.elementList || this.control.getElementList();
8797
- const startElement = elementList[startIndex];
8798
- const anchorElement = startElement.controlComponent === ControlComponent.PREFIX ? omitObject(startElement, EDITOR_ELEMENT_STYLE_ATTR) : startElement;
8799
- const start = startIndex + 1;
8814
+ const styleElement = pickObject(this.getValue(context)[0], EDITOR_ELEMENT_STYLE_ATTR);
8815
+ const prefixIndex = this.clearSelect(context);
8816
+ this.control.removePlaceholder(prefixIndex);
8817
+ const propertyElement = omitObject(elementList[prefixIndex], EDITOR_ELEMENT_STYLE_ATTR);
8818
+ const start = prefixIndex + 1;
8800
8819
  const data2 = splitText(valueSet.value);
8801
8820
  const draw = this.control.getDraw();
8802
8821
  for (let i = 0; i < data2.length; i++) {
8803
- const newElement = __spreadProps(__spreadValues({}, anchorElement), {
8822
+ const newElement = __spreadProps(__spreadValues(__spreadValues({}, styleElement), propertyElement), {
8804
8823
  value: data2[i],
8805
8824
  controlComponent: ControlComponent.VALUE
8806
8825
  });
8807
- formatElementContext(elementList, [newElement], startIndex);
8826
+ formatElementContext(elementList, [newElement], prefixIndex);
8808
8827
  draw.spliceElementList(elementList, start + i, 0, newElement);
8809
8828
  }
8810
8829
  this.element.control.code = code;
@@ -9233,6 +9252,9 @@ class Control {
9233
9252
  removeControl(startIndex) {
9234
9253
  const elementList = this.getElementList();
9235
9254
  const startElement = elementList[startIndex];
9255
+ const { deletable = true } = startElement.control;
9256
+ if (!deletable)
9257
+ return null;
9236
9258
  let leftIndex = -1;
9237
9259
  let rightIndex = -1;
9238
9260
  let preIndex = startIndex;
@@ -9347,19 +9369,19 @@ class Control {
9347
9369
  j++;
9348
9370
  }
9349
9371
  if (type === ControlType.TEXT) {
9350
- result.push({
9372
+ result.push(__spreadProps(__spreadValues({}, element.control), {
9351
9373
  value: textControlValue || null,
9352
9374
  innerText: textControlValue || null
9353
- });
9375
+ }));
9354
9376
  } else if (type === ControlType.SELECT || type === ControlType.CHECKBOX) {
9355
9377
  const innerText = code == null ? void 0 : code.split(",").map((selectCode) => {
9356
9378
  var _a2;
9357
9379
  return (_a2 = valueSets == null ? void 0 : valueSets.find((valueSet) => valueSet.code === selectCode)) == null ? void 0 : _a2.value;
9358
9380
  }).filter(Boolean).join("");
9359
- result.push({
9381
+ result.push(__spreadProps(__spreadValues({}, element.control), {
9360
9382
  value: code || null,
9361
9383
  innerText: innerText || null
9362
- });
9384
+ }));
9363
9385
  }
9364
9386
  i = j;
9365
9387
  }
@@ -9448,6 +9470,36 @@ class Control {
9448
9470
  });
9449
9471
  }
9450
9472
  }
9473
+ setExtensionByConceptId(payload) {
9474
+ var _a;
9475
+ const isReadonly = this.draw.isReadonly();
9476
+ if (isReadonly)
9477
+ return;
9478
+ const { conceptId, extension } = payload;
9479
+ const data2 = [
9480
+ this.draw.getHeaderElementList(),
9481
+ this.draw.getOriginalMainElementList(),
9482
+ this.draw.getFooterElementList()
9483
+ ];
9484
+ for (const elementList of data2) {
9485
+ let i = 0;
9486
+ while (i < elementList.length) {
9487
+ const element = elementList[i];
9488
+ i++;
9489
+ if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
9490
+ continue;
9491
+ element.control.extension = extension;
9492
+ let newEndIndex = i;
9493
+ while (newEndIndex < elementList.length) {
9494
+ const nextElement = elementList[newEndIndex];
9495
+ if (nextElement.controlId !== element.controlId)
9496
+ break;
9497
+ newEndIndex++;
9498
+ }
9499
+ i = newEndIndex;
9500
+ }
9501
+ }
9502
+ }
9451
9503
  }
9452
9504
  class CheckboxParticle {
9453
9505
  constructor(draw) {
@@ -12824,6 +12876,7 @@ class Command {
12824
12876
  __publicField(this, "executeBackspace");
12825
12877
  __publicField(this, "executeSetRange");
12826
12878
  __publicField(this, "executeForceUpdate");
12879
+ __publicField(this, "executeBlur");
12827
12880
  __publicField(this, "executeUndo");
12828
12881
  __publicField(this, "executeRedo");
12829
12882
  __publicField(this, "executePainter");
@@ -12897,6 +12950,7 @@ class Command {
12897
12950
  __publicField(this, "executeDeleteGroup");
12898
12951
  __publicField(this, "executeLocationGroup");
12899
12952
  __publicField(this, "executeSetControlValue");
12953
+ __publicField(this, "executeSetControlExtension");
12900
12954
  __publicField(this, "getCatalog");
12901
12955
  __publicField(this, "getImage");
12902
12956
  __publicField(this, "getOptions");
@@ -12913,6 +12967,7 @@ class Command {
12913
12967
  __publicField(this, "getLocale");
12914
12968
  __publicField(this, "getGroupIds");
12915
12969
  __publicField(this, "getControlValue");
12970
+ __publicField(this, "getContainer");
12916
12971
  this.executeMode = adapt.mode.bind(adapt);
12917
12972
  this.executeCut = adapt.cut.bind(adapt);
12918
12973
  this.executeCopy = adapt.copy.bind(adapt);
@@ -12921,6 +12976,7 @@ class Command {
12921
12976
  this.executeBackspace = adapt.backspace.bind(adapt);
12922
12977
  this.executeSetRange = adapt.setRange.bind(adapt);
12923
12978
  this.executeForceUpdate = adapt.forceUpdate.bind(adapt);
12979
+ this.executeBlur = adapt.blur.bind(adapt);
12924
12980
  this.executeUndo = adapt.undo.bind(adapt);
12925
12981
  this.executeRedo = adapt.redo.bind(adapt);
12926
12982
  this.executePainter = adapt.painter.bind(adapt);
@@ -13008,7 +13064,9 @@ class Command {
13008
13064
  this.getSearchNavigateInfo = adapt.getSearchNavigateInfo.bind(adapt);
13009
13065
  this.getLocale = adapt.getLocale.bind(adapt);
13010
13066
  this.getGroupIds = adapt.getGroupIds.bind(adapt);
13067
+ this.getContainer = adapt.getContainer.bind(adapt);
13011
13068
  this.executeSetControlValue = adapt.setControlValue.bind(adapt);
13069
+ this.executeSetControlExtension = adapt.setControlExtension.bind(adapt);
13012
13070
  this.getControlValue = adapt.getControlValue.bind(adapt);
13013
13071
  }
13014
13072
  }
@@ -13148,6 +13206,10 @@ class CommandAdapt {
13148
13206
  isSetCursor: false
13149
13207
  });
13150
13208
  }
13209
+ blur() {
13210
+ this.range.clearRange();
13211
+ this.draw.getCursor().recoveryCursor();
13212
+ }
13151
13213
  undo() {
13152
13214
  const isReadonly = this.draw.isReadonly();
13153
13215
  if (isReadonly)
@@ -14697,9 +14759,9 @@ class CommandAdapt {
14697
14759
  currentX = leftTop[0];
14698
14760
  } else {
14699
14761
  rangeRect.width = rightTop[0] - currentX;
14700
- if (p === selectionPositionList.length - 1 && rangeRect) {
14701
- rangeRects.push(rangeRect);
14702
- }
14762
+ }
14763
+ if (p === selectionPositionList.length - 1 && rangeRect) {
14764
+ rangeRects.push(rangeRect);
14703
14765
  }
14704
14766
  }
14705
14767
  }
@@ -14787,6 +14849,8 @@ class CommandAdapt {
14787
14849
  return;
14788
14850
  const control = this.draw.getControl();
14789
14851
  const newIndex = control.removeControl(startIndex);
14852
+ if (newIndex === null)
14853
+ return;
14790
14854
  this.range.setRange(newIndex, newIndex);
14791
14855
  this.draw.render({
14792
14856
  curIndex: newIndex
@@ -14905,6 +14969,15 @@ class CommandAdapt {
14905
14969
  return;
14906
14970
  this.draw.getControl().setValueByConceptId(payload);
14907
14971
  }
14972
+ setControlExtension(payload) {
14973
+ const isReadonly = this.draw.isReadonly();
14974
+ if (isReadonly)
14975
+ return;
14976
+ this.draw.getControl().setExtensionByConceptId(payload);
14977
+ }
14978
+ getContainer() {
14979
+ return this.draw.getContainer();
14980
+ }
14908
14981
  }
14909
14982
  class Listener {
14910
14983
  constructor() {
@@ -14933,10 +15006,12 @@ class Listener {
14933
15006
  class Register {
14934
15007
  constructor(payload) {
14935
15008
  __publicField(this, "contextMenuList");
15009
+ __publicField(this, "getContextMenuList");
14936
15010
  __publicField(this, "shortcutList");
14937
15011
  __publicField(this, "langMap");
14938
15012
  const { contextMenu, shortcut, i18n } = payload;
14939
15013
  this.contextMenuList = contextMenu.registerContextMenuList.bind(contextMenu);
15014
+ this.getContextMenuList = contextMenu.getContextMenuList.bind(contextMenu);
14940
15015
  this.shortcutList = shortcut.registerShortcutList.bind(shortcut);
14941
15016
  this.langMap = i18n.registerLangMap.bind(i18n);
14942
15017
  }
@@ -14944,8 +15019,59 @@ class Register {
14944
15019
  const NAME_PLACEHOLDER = {
14945
15020
  SELECTED_TEXT: "%s"
14946
15021
  };
15022
+ const INTERNAL_CONTEXT_MENU_KEY = {
15023
+ GLOBAL: {
15024
+ CUT: "globalCut",
15025
+ COPY: "globalCopy",
15026
+ PASTE: "globalPaste",
15027
+ SELECT_ALL: "globalSelectAll",
15028
+ PRINT: "globalPrint"
15029
+ },
15030
+ CONTROL: {
15031
+ DELETE: "controlDelete"
15032
+ },
15033
+ HYPERLINK: {
15034
+ DELETE: "hyperlinkDelete",
15035
+ CANCEL: "hyperlinkCancel",
15036
+ EDIT: "hyperEdit"
15037
+ },
15038
+ IMAGE: {
15039
+ CHANGE: "imageChange",
15040
+ SAVE_AS: "imageSaveAs",
15041
+ TEXT_WRAP: "imageTextWrap",
15042
+ TEXT_WRAP_EMBED: "imageTextWrapEmbed",
15043
+ TEXT_WRAP_UP_DOWN: "imageTextWrapUpDown"
15044
+ },
15045
+ TABLE: {
15046
+ BORDER: "border",
15047
+ BORDER_ALL: "tableBorderAll",
15048
+ BORDER_EMPTY: "tableBorderEmpty",
15049
+ BORDER_EXTERNAL: "tableBorderExternal",
15050
+ BORDER_TD: "tableBorderTd",
15051
+ BORDER_TD_BOTTOM: "tableBorderTdBottom",
15052
+ BORDER_TD_FORWARD: "tableBorderTdForward",
15053
+ BORDER_TD_BACK: "tableBorderTdBack",
15054
+ VERTICAL_ALIGN: "tableVerticalAlign",
15055
+ VERTICAL_ALIGN_TOP: "tableVerticalAlignTop",
15056
+ VERTICAL_ALIGN_MIDDLE: "tableVerticalAlignMiddle",
15057
+ VERTICAL_ALIGN_BOTTOM: "tableVerticalAlignBottom",
15058
+ INSERT_ROW_COL: "tableInsertRowCol",
15059
+ INSERT_TOP_ROW: "tableInsertTopRow",
15060
+ INSERT_BOTTOM_ROW: "tableInsertBottomRow",
15061
+ INSERT_LEFT_COL: "tableInsertLeftCol",
15062
+ INSERT_RIGHT_COL: "tableInsertRightCol",
15063
+ DELETE_ROW_COL: "tableDeleteRowCol",
15064
+ DELETE_ROW: "tableDeleteRow",
15065
+ DELETE_COL: "tableDeleteCol",
15066
+ DELETE_TABLE: "tableDeleteTable",
15067
+ MERGE_CELL: "tableMergeCell",
15068
+ CANCEL_MERGE_CELL: "tableCancelMergeCell"
15069
+ }
15070
+ };
15071
+ const { CONTROL: { DELETE: DELETE$1 } } = INTERNAL_CONTEXT_MENU_KEY;
14947
15072
  const controlMenus = [
14948
15073
  {
15074
+ key: DELETE$1,
14949
15075
  i18nPath: "contextmenu.control.delete",
14950
15076
  when: (payload) => {
14951
15077
  var _a;
@@ -14956,8 +15082,10 @@ const controlMenus = [
14956
15082
  }
14957
15083
  }
14958
15084
  ];
15085
+ const { GLOBAL: { CUT, COPY, PASTE, SELECT_ALL, PRINT } } = INTERNAL_CONTEXT_MENU_KEY;
14959
15086
  const globalMenus = [
14960
15087
  {
15088
+ key: CUT,
14961
15089
  i18nPath: "contextmenu.global.cut",
14962
15090
  shortCut: `${isApple ? "\u2318" : "Ctrl"} + X`,
14963
15091
  when: (payload) => {
@@ -14968,6 +15096,7 @@ const globalMenus = [
14968
15096
  }
14969
15097
  },
14970
15098
  {
15099
+ key: COPY,
14971
15100
  i18nPath: "contextmenu.global.copy",
14972
15101
  shortCut: `${isApple ? "\u2318" : "Ctrl"} + C`,
14973
15102
  when: (payload) => {
@@ -14978,6 +15107,7 @@ const globalMenus = [
14978
15107
  }
14979
15108
  },
14980
15109
  {
15110
+ key: PASTE,
14981
15111
  i18nPath: "contextmenu.global.paste",
14982
15112
  shortCut: `${isApple ? "\u2318" : "Ctrl"} + V`,
14983
15113
  when: (payload) => {
@@ -14988,6 +15118,7 @@ const globalMenus = [
14988
15118
  }
14989
15119
  },
14990
15120
  {
15121
+ key: SELECT_ALL,
14991
15122
  i18nPath: "contextmenu.global.selectAll",
14992
15123
  shortCut: `${isApple ? "\u2318" : "Ctrl"} + A`,
14993
15124
  when: (payload) => {
@@ -15001,6 +15132,7 @@ const globalMenus = [
15001
15132
  isDivider: true
15002
15133
  },
15003
15134
  {
15135
+ key: PRINT,
15004
15136
  i18nPath: "contextmenu.global.print",
15005
15137
  icon: "print",
15006
15138
  when: () => true,
@@ -15009,8 +15141,10 @@ const globalMenus = [
15009
15141
  }
15010
15142
  }
15011
15143
  ];
15144
+ const { HYPERLINK: { DELETE, CANCEL, EDIT } } = INTERNAL_CONTEXT_MENU_KEY;
15012
15145
  const hyperlinkMenus = [
15013
15146
  {
15147
+ key: DELETE,
15014
15148
  i18nPath: "contextmenu.hyperlink.delete",
15015
15149
  when: (payload) => {
15016
15150
  var _a;
@@ -15021,6 +15155,7 @@ const hyperlinkMenus = [
15021
15155
  }
15022
15156
  },
15023
15157
  {
15158
+ key: CANCEL,
15024
15159
  i18nPath: "contextmenu.hyperlink.cancel",
15025
15160
  when: (payload) => {
15026
15161
  var _a;
@@ -15031,6 +15166,7 @@ const hyperlinkMenus = [
15031
15166
  }
15032
15167
  },
15033
15168
  {
15169
+ key: EDIT,
15034
15170
  i18nPath: "contextmenu.hyperlink.edit",
15035
15171
  when: (payload) => {
15036
15172
  var _a;
@@ -15045,8 +15181,10 @@ const hyperlinkMenus = [
15045
15181
  }
15046
15182
  }
15047
15183
  ];
15184
+ const { IMAGE: { CHANGE, SAVE_AS, TEXT_WRAP, TEXT_WRAP_EMBED, TEXT_WRAP_UP_DOWN } } = INTERNAL_CONTEXT_MENU_KEY;
15048
15185
  const imageMenus = [
15049
15186
  {
15187
+ key: CHANGE,
15050
15188
  i18nPath: "contextmenu.image.change",
15051
15189
  icon: "image-change",
15052
15190
  when: (payload) => {
@@ -15070,6 +15208,7 @@ const imageMenus = [
15070
15208
  }
15071
15209
  },
15072
15210
  {
15211
+ key: SAVE_AS,
15073
15212
  i18nPath: "contextmenu.image.saveAs",
15074
15213
  icon: "image",
15075
15214
  when: (payload) => {
@@ -15081,6 +15220,7 @@ const imageMenus = [
15081
15220
  }
15082
15221
  },
15083
15222
  {
15223
+ key: TEXT_WRAP,
15084
15224
  i18nPath: "contextmenu.image.textWrap",
15085
15225
  when: (payload) => {
15086
15226
  var _a;
@@ -15088,6 +15228,7 @@ const imageMenus = [
15088
15228
  },
15089
15229
  childMenus: [
15090
15230
  {
15231
+ key: TEXT_WRAP_EMBED,
15091
15232
  i18nPath: "contextmenu.image.textWrapType.embed",
15092
15233
  when: () => true,
15093
15234
  callback: (command, context) => {
@@ -15095,6 +15236,7 @@ const imageMenus = [
15095
15236
  }
15096
15237
  },
15097
15238
  {
15239
+ key: TEXT_WRAP_UP_DOWN,
15098
15240
  i18nPath: "contextmenu.image.textWrapType.upDown",
15099
15241
  when: () => true,
15100
15242
  callback: (command, context) => {
@@ -15104,11 +15246,13 @@ const imageMenus = [
15104
15246
  ]
15105
15247
  }
15106
15248
  ];
15249
+ const { TABLE: { BORDER, BORDER_ALL, BORDER_EMPTY, BORDER_EXTERNAL, BORDER_TD, BORDER_TD_BOTTOM, BORDER_TD_BACK, BORDER_TD_FORWARD, VERTICAL_ALIGN, VERTICAL_ALIGN_TOP, VERTICAL_ALIGN_MIDDLE, VERTICAL_ALIGN_BOTTOM, INSERT_ROW_COL, INSERT_TOP_ROW, INSERT_BOTTOM_ROW, INSERT_LEFT_COL, INSERT_RIGHT_COL, DELETE_ROW_COL, DELETE_ROW, DELETE_COL, DELETE_TABLE, MERGE_CELL, CANCEL_MERGE_CELL } } = INTERNAL_CONTEXT_MENU_KEY;
15107
15250
  const tableMenus = [
15108
15251
  {
15109
15252
  isDivider: true
15110
15253
  },
15111
15254
  {
15255
+ key: BORDER,
15112
15256
  i18nPath: "contextmenu.table.border",
15113
15257
  icon: "border-all",
15114
15258
  when: (payload) => {
@@ -15116,6 +15260,7 @@ const tableMenus = [
15116
15260
  },
15117
15261
  childMenus: [
15118
15262
  {
15263
+ key: BORDER_ALL,
15119
15264
  i18nPath: "contextmenu.table.borderAll",
15120
15265
  icon: "border-all",
15121
15266
  when: () => true,
@@ -15124,6 +15269,7 @@ const tableMenus = [
15124
15269
  }
15125
15270
  },
15126
15271
  {
15272
+ key: BORDER_EMPTY,
15127
15273
  i18nPath: "contextmenu.table.borderEmpty",
15128
15274
  icon: "border-empty",
15129
15275
  when: () => true,
@@ -15132,6 +15278,7 @@ const tableMenus = [
15132
15278
  }
15133
15279
  },
15134
15280
  {
15281
+ key: BORDER_EXTERNAL,
15135
15282
  i18nPath: "contextmenu.table.borderExternal",
15136
15283
  icon: "border-external",
15137
15284
  when: () => true,
@@ -15140,11 +15287,13 @@ const tableMenus = [
15140
15287
  }
15141
15288
  },
15142
15289
  {
15290
+ key: BORDER_TD,
15143
15291
  i18nPath: "contextmenu.table.borderTd",
15144
15292
  icon: "border-td",
15145
15293
  when: () => true,
15146
15294
  childMenus: [
15147
15295
  {
15296
+ key: BORDER_TD_BOTTOM,
15148
15297
  i18nPath: "contextmenu.table.borderTdBottom",
15149
15298
  icon: "border-td-bottom",
15150
15299
  when: () => true,
@@ -15153,6 +15302,7 @@ const tableMenus = [
15153
15302
  }
15154
15303
  },
15155
15304
  {
15305
+ key: BORDER_TD_FORWARD,
15156
15306
  i18nPath: "contextmenu.table.borderTdForward",
15157
15307
  icon: "border-td-forward",
15158
15308
  when: () => true,
@@ -15161,6 +15311,7 @@ const tableMenus = [
15161
15311
  }
15162
15312
  },
15163
15313
  {
15314
+ key: BORDER_TD_BACK,
15164
15315
  i18nPath: "contextmenu.table.borderTdBack",
15165
15316
  icon: "border-td-back",
15166
15317
  when: () => true,
@@ -15173,6 +15324,7 @@ const tableMenus = [
15173
15324
  ]
15174
15325
  },
15175
15326
  {
15327
+ key: VERTICAL_ALIGN,
15176
15328
  i18nPath: "contextmenu.table.verticalAlign",
15177
15329
  icon: "vertical-align",
15178
15330
  when: (payload) => {
@@ -15180,6 +15332,7 @@ const tableMenus = [
15180
15332
  },
15181
15333
  childMenus: [
15182
15334
  {
15335
+ key: VERTICAL_ALIGN_TOP,
15183
15336
  i18nPath: "contextmenu.table.verticalAlignTop",
15184
15337
  icon: "vertical-align-top",
15185
15338
  when: () => true,
@@ -15188,6 +15341,7 @@ const tableMenus = [
15188
15341
  }
15189
15342
  },
15190
15343
  {
15344
+ key: VERTICAL_ALIGN_MIDDLE,
15191
15345
  i18nPath: "contextmenu.table.verticalAlignMiddle",
15192
15346
  icon: "vertical-align-middle",
15193
15347
  when: () => true,
@@ -15196,6 +15350,7 @@ const tableMenus = [
15196
15350
  }
15197
15351
  },
15198
15352
  {
15353
+ key: VERTICAL_ALIGN_BOTTOM,
15199
15354
  i18nPath: "contextmenu.table.verticalAlignBottom",
15200
15355
  icon: "vertical-align-bottom",
15201
15356
  when: () => true,
@@ -15206,6 +15361,7 @@ const tableMenus = [
15206
15361
  ]
15207
15362
  },
15208
15363
  {
15364
+ key: INSERT_ROW_COL,
15209
15365
  i18nPath: "contextmenu.table.insertRowCol",
15210
15366
  icon: "insert-row-col",
15211
15367
  when: (payload) => {
@@ -15213,6 +15369,7 @@ const tableMenus = [
15213
15369
  },
15214
15370
  childMenus: [
15215
15371
  {
15372
+ key: INSERT_TOP_ROW,
15216
15373
  i18nPath: "contextmenu.table.insertTopRow",
15217
15374
  icon: "insert-top-row",
15218
15375
  when: () => true,
@@ -15221,6 +15378,7 @@ const tableMenus = [
15221
15378
  }
15222
15379
  },
15223
15380
  {
15381
+ key: INSERT_BOTTOM_ROW,
15224
15382
  i18nPath: "contextmenu.table.insertBottomRow",
15225
15383
  icon: "insert-bottom-row",
15226
15384
  when: () => true,
@@ -15229,6 +15387,7 @@ const tableMenus = [
15229
15387
  }
15230
15388
  },
15231
15389
  {
15390
+ key: INSERT_LEFT_COL,
15232
15391
  i18nPath: "contextmenu.table.insertLeftCol",
15233
15392
  icon: "insert-left-col",
15234
15393
  when: () => true,
@@ -15237,6 +15396,7 @@ const tableMenus = [
15237
15396
  }
15238
15397
  },
15239
15398
  {
15399
+ key: INSERT_RIGHT_COL,
15240
15400
  i18nPath: "contextmenu.table.insertRightCol",
15241
15401
  icon: "insert-right-col",
15242
15402
  when: () => true,
@@ -15247,6 +15407,7 @@ const tableMenus = [
15247
15407
  ]
15248
15408
  },
15249
15409
  {
15410
+ key: DELETE_ROW_COL,
15250
15411
  i18nPath: "contextmenu.table.deleteRowCol",
15251
15412
  icon: "delete-row-col",
15252
15413
  when: (payload) => {
@@ -15254,6 +15415,7 @@ const tableMenus = [
15254
15415
  },
15255
15416
  childMenus: [
15256
15417
  {
15418
+ key: DELETE_ROW,
15257
15419
  i18nPath: "contextmenu.table.deleteRow",
15258
15420
  icon: "delete-row",
15259
15421
  when: () => true,
@@ -15262,6 +15424,7 @@ const tableMenus = [
15262
15424
  }
15263
15425
  },
15264
15426
  {
15427
+ key: DELETE_COL,
15265
15428
  i18nPath: "contextmenu.table.deleteCol",
15266
15429
  icon: "delete-col",
15267
15430
  when: () => true,
@@ -15270,6 +15433,7 @@ const tableMenus = [
15270
15433
  }
15271
15434
  },
15272
15435
  {
15436
+ key: DELETE_TABLE,
15273
15437
  i18nPath: "contextmenu.table.deleteTable",
15274
15438
  icon: "delete-table",
15275
15439
  when: () => true,
@@ -15280,6 +15444,7 @@ const tableMenus = [
15280
15444
  ]
15281
15445
  },
15282
15446
  {
15447
+ key: MERGE_CELL,
15283
15448
  i18nPath: "contextmenu.table.mergeCell",
15284
15449
  icon: "merge-cell",
15285
15450
  when: (payload) => {
@@ -15290,6 +15455,7 @@ const tableMenus = [
15290
15455
  }
15291
15456
  },
15292
15457
  {
15458
+ key: CANCEL_MERGE_CELL,
15293
15459
  i18nPath: "contextmenu.table.mergeCancelCell",
15294
15460
  icon: "merge-cancel-cell",
15295
15461
  when: (payload) => {
@@ -15302,6 +15468,7 @@ const tableMenus = [
15302
15468
  ];
15303
15469
  class ContextMenu {
15304
15470
  constructor(draw, command) {
15471
+ __publicField(this, "options");
15305
15472
  __publicField(this, "draw");
15306
15473
  __publicField(this, "command");
15307
15474
  __publicField(this, "range");
@@ -15313,22 +15480,9 @@ class ContextMenu {
15313
15480
  __publicField(this, "contextMenuRelationShip");
15314
15481
  __publicField(this, "context");
15315
15482
  __publicField(this, "_proxyContextMenuEvent", (evt) => {
15316
- var _a;
15317
15483
  this.context = this._getContext();
15318
- const renderList = [];
15319
- let isRegisterContextMenu = false;
15320
- for (let c = 0; c < this.contextMenuList.length; c++) {
15321
- const menu = this.contextMenuList[c];
15322
- if (menu.isDivider) {
15323
- renderList.push(menu);
15324
- } else {
15325
- const isMatch = (_a = menu.when) == null ? void 0 : _a.call(menu, this.context);
15326
- if (isMatch) {
15327
- renderList.push(menu);
15328
- isRegisterContextMenu = true;
15329
- }
15330
- }
15331
- }
15484
+ const renderList = this._filterMenuList(this.contextMenuList);
15485
+ const isRegisterContextMenu = renderList.some((menu) => !menu.isDivider);
15332
15486
  if (isRegisterContextMenu) {
15333
15487
  this.dispose();
15334
15488
  this._render({
@@ -15348,6 +15502,7 @@ class ContextMenu {
15348
15502
  }
15349
15503
  }
15350
15504
  });
15505
+ this.options = draw.getOptions();
15351
15506
  this.draw = draw;
15352
15507
  this.command = command;
15353
15508
  this.range = draw.getRange();
@@ -15366,6 +15521,9 @@ class ContextMenu {
15366
15521
  this.contextMenuRelationShip = new Map();
15367
15522
  this._addEvent();
15368
15523
  }
15524
+ getContextMenuList() {
15525
+ return this.contextMenuList;
15526
+ }
15369
15527
  _addEvent() {
15370
15528
  this.container.addEventListener("contextmenu", this._proxyContextMenuEvent);
15371
15529
  document.addEventListener("mousedown", this._handleSideEffect);
@@ -15374,6 +15532,25 @@ class ContextMenu {
15374
15532
  this.container.removeEventListener("contextmenu", this._proxyContextMenuEvent);
15375
15533
  document.removeEventListener("mousedown", this._handleSideEffect);
15376
15534
  }
15535
+ _filterMenuList(menuList) {
15536
+ var _a;
15537
+ const { contextMenuDisableKeys } = this.options;
15538
+ const renderList = [];
15539
+ for (let m = 0; m < menuList.length; m++) {
15540
+ const menu = menuList[m];
15541
+ if (menu.disable || menu.key && contextMenuDisableKeys.includes(menu.key)) {
15542
+ continue;
15543
+ }
15544
+ if (menu.isDivider) {
15545
+ renderList.push(menu);
15546
+ } else {
15547
+ if ((_a = menu.when) == null ? void 0 : _a.call(menu, this.context)) {
15548
+ renderList.push(menu);
15549
+ }
15550
+ }
15551
+ }
15552
+ return renderList;
15553
+ }
15377
15554
  _getContext() {
15378
15555
  const isReadonly = this.draw.isReadonly();
15379
15556
  const { isCrossRowCol: crossRowCol, startIndex, endIndex } = this.range.getRange();
@@ -15405,6 +15582,7 @@ class ContextMenu {
15405
15582
  return contextMenuContainer;
15406
15583
  }
15407
15584
  _render(payload) {
15585
+ var _a;
15408
15586
  const { contextMenuList, left, top, parentMenuContainer } = payload;
15409
15587
  const contextMenuContainer = this._createContextMenuContainer();
15410
15588
  const contextMenuContent = document.createElement("div");
@@ -15416,7 +15594,7 @@ class ContextMenu {
15416
15594
  for (let c = 0; c < contextMenuList.length; c++) {
15417
15595
  const menu = contextMenuList[c];
15418
15596
  if (menu.isDivider) {
15419
- if (c !== 0 && c !== contextMenuList.length - 1) {
15597
+ if (c !== 0 && c !== contextMenuList.length - 1 && !((_a = contextMenuList[c - 1]) == null ? void 0 : _a.isDivider)) {
15420
15598
  const divider = document.createElement("div");
15421
15599
  divider.classList.add(`${EDITOR_PREFIX}-contextmenu-divider`);
15422
15600
  contextMenuContent.append(divider);
@@ -15425,25 +15603,29 @@ class ContextMenu {
15425
15603
  const menuItem = document.createElement("div");
15426
15604
  menuItem.classList.add(`${EDITOR_PREFIX}-contextmenu-item`);
15427
15605
  if (menu.childMenus) {
15428
- menuItem.classList.add(`${EDITOR_PREFIX}-contextmenu-sub-item`);
15429
- menuItem.onmouseenter = () => {
15430
- this._setHoverStatus(menuItem, true);
15431
- this._removeSubMenu(contextMenuContainer);
15432
- const subMenuRect = menuItem.getBoundingClientRect();
15433
- const left2 = subMenuRect.left + subMenuRect.width;
15434
- const top2 = subMenuRect.top;
15435
- childMenuContainer = this._render({
15436
- contextMenuList: menu.childMenus,
15437
- left: left2,
15438
- top: top2,
15439
- parentMenuContainer: contextMenuContainer
15440
- });
15441
- };
15442
- menuItem.onmouseleave = (evt) => {
15443
- if (!childMenuContainer || !childMenuContainer.contains(evt.relatedTarget)) {
15444
- this._setHoverStatus(menuItem, false);
15445
- }
15446
- };
15606
+ const childMenus = this._filterMenuList(menu.childMenus);
15607
+ const isRegisterContextMenu = childMenus.some((menu2) => !menu2.isDivider);
15608
+ if (isRegisterContextMenu) {
15609
+ menuItem.classList.add(`${EDITOR_PREFIX}-contextmenu-sub-item`);
15610
+ menuItem.onmouseenter = () => {
15611
+ this._setHoverStatus(menuItem, true);
15612
+ this._removeSubMenu(contextMenuContainer);
15613
+ const subMenuRect = menuItem.getBoundingClientRect();
15614
+ const left2 = subMenuRect.left + subMenuRect.width;
15615
+ const top2 = subMenuRect.top;
15616
+ childMenuContainer = this._render({
15617
+ contextMenuList: childMenus,
15618
+ left: left2,
15619
+ top: top2,
15620
+ parentMenuContainer: contextMenuContainer
15621
+ });
15622
+ };
15623
+ menuItem.onmouseleave = (evt) => {
15624
+ if (!childMenuContainer || !childMenuContainer.contains(evt.relatedTarget)) {
15625
+ this._setHoverStatus(menuItem, false);
15626
+ }
15627
+ };
15628
+ }
15447
15629
  } else {
15448
15630
  menuItem.onmouseenter = () => {
15449
15631
  this._setHoverStatus(menuItem, true);
@@ -15838,6 +16020,7 @@ const defaultGroupOption = {
15838
16020
  class Override {
15839
16021
  constructor() {
15840
16022
  __publicField(this, "paste");
16023
+ __publicField(this, "copy");
15841
16024
  }
15842
16025
  }
15843
16026
  const defaultPageBreakOption = {
@@ -15905,7 +16088,8 @@ class Editor {
15905
16088
  wordBreak: WordBreak.BREAK_WORD,
15906
16089
  printPixelRatio: 3,
15907
16090
  maskMargin: [0, 0, 0, 0],
15908
- letterClass: [LETTER_CLASS.ENGLISH]
16091
+ letterClass: [LETTER_CLASS.ENGLISH],
16092
+ contextMenuDisableKeys: []
15909
16093
  }, options), {
15910
16094
  header: headerOptions,
15911
16095
  footer: footerOptions,
@@ -15964,5 +16148,5 @@ class Editor {
15964
16148
  this.use = plugin.use.bind(plugin);
15965
16149
  }
15966
16150
  }
15967
- export { BlockType, Command, ControlType, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, ImageDisplay, KeyMap, LETTER_CLASS, ListStyle, ListType, MaxHeightRatio, NumberType, PageMode, PaperDirection, RowFlex, TableBorder, TdBorder, TdSlash, TitleLevel, VerticalAlign, WordBreak, Editor as default };
16151
+ export { BlockType, Command, ControlType, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, INTERNAL_CONTEXT_MENU_KEY, ImageDisplay, KeyMap, LETTER_CLASS, ListStyle, ListType, MaxHeightRatio, NumberType, PageMode, PaperDirection, RowFlex, TableBorder, TdBorder, TdSlash, TitleLevel, VerticalAlign, WordBreak, Editor as default };
15968
16152
  //# sourceMappingURL=canvas-editor.es.js.map