@hufe921/canvas-editor 0.9.108 → 0.9.109

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,20 @@
1
+ ## [0.9.109](https://github.com/Hufe921/canvas-editor/compare/v0.9.108...v0.9.109) (2025-05-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * area mode priority error #1119 ([2abd43a](https://github.com/Hufe921/canvas-editor/commit/2abd43a2a4eb156d154c72a7b709cde6aa433fbd)), closes [#1119](https://github.com/Hufe921/canvas-editor/issues/1119)
7
+
8
+
9
+ ### Features
10
+
11
+ * add controlComponent property to getRangeContext api ([6420421](https://github.com/Hufe921/canvas-editor/commit/6420421e2fd01d79ad5be835eac4f2f49359fec6))
12
+ * add disable selection option outside the page #1120 ([f2c61e5](https://github.com/Hufe921/canvas-editor/commit/f2c61e539747c71a6e051fe9f607bf0098b3b22f)), closes [#1120](https://github.com/Hufe921/canvas-editor/issues/1120)
13
+ * add isIgnoreDisabledRule option to richtext style setting apis #1109 ([46d917c](https://github.com/Hufe921/canvas-editor/commit/46d917caa5023c28e692a852f5b036bfbb9a6f0d)), closes [#1109](https://github.com/Hufe921/canvas-editor/issues/1109)
14
+ * add isSubmitHistory option to the insert element apis #1124 ([424e01f](https://github.com/Hufe921/canvas-editor/commit/424e01f9d30d88cf8d749cb169c6733309821d71)), closes [#1124](https://github.com/Hufe921/canvas-editor/issues/1124)
15
+
16
+
17
+
1
18
  ## [0.9.108](https://github.com/Hufe921/canvas-editor/compare/v0.9.107...v0.9.108) (2025-04-30)
2
19
 
3
20
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.108";
26
+ const version = "0.9.109";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -4142,7 +4142,8 @@ function mergeOption(options = {}) {
4142
4142
  maskMargin: [0, 0, 0, 0],
4143
4143
  letterClass: [LETTER_CLASS.ENGLISH],
4144
4144
  contextMenuDisableKeys: [],
4145
- scrollContainerSelector: ""
4145
+ scrollContainerSelector: "",
4146
+ pageOuterSelectionDisable: false
4146
4147
  }, options), {
4147
4148
  table: tableOptions,
4148
4149
  header: headerOptions,
@@ -6648,6 +6649,8 @@ function mouseup(evt, host) {
6648
6649
  }
6649
6650
  function mouseleave(evt, host) {
6650
6651
  const draw = host.getDraw();
6652
+ if (!draw.getOptions().pageOuterSelectionDisable)
6653
+ return;
6651
6654
  const pageContainer = draw.getPageContainer();
6652
6655
  const { x, y, width, height } = pageContainer.getBoundingClientRect();
6653
6656
  if (evt.x >= x && evt.x <= x + width && evt.y >= y && evt.y <= y + height) {
@@ -17604,7 +17607,8 @@ class Draw {
17604
17607
  });
17605
17608
  }
17606
17609
  isReadonly() {
17607
- if (this.area.getActiveAreaId()) {
17610
+ var _a;
17611
+ if ((_a = this.area.getActiveAreaInfo()) == null ? void 0 : _a.area.mode) {
17608
17612
  return this.area.isReadonly();
17609
17613
  }
17610
17614
  switch (this.mode) {
@@ -17873,12 +17877,13 @@ class Draw {
17873
17877
  }
17874
17878
  return null;
17875
17879
  }
17876
- insertElementList(payload) {
17880
+ insertElementList(payload, options = {}) {
17877
17881
  if (!payload.length || !this.range.getIsCanInput())
17878
17882
  return;
17879
17883
  const { startIndex, endIndex } = this.range.getRange();
17880
17884
  if (!~startIndex && !~endIndex)
17881
17885
  return;
17886
+ const { isSubmitHistory = true } = options;
17882
17887
  formatElementList(payload, {
17883
17888
  isHandleFirstElement: false,
17884
17889
  editorOptions: this.options
@@ -17912,7 +17917,8 @@ class Draw {
17912
17917
  if (~curIndex) {
17913
17918
  this.range.setRange(curIndex, curIndex);
17914
17919
  this.render({
17915
- curIndex
17920
+ curIndex,
17921
+ isSubmitHistory
17916
17922
  });
17917
17923
  }
17918
17924
  }
@@ -17924,7 +17930,7 @@ class Draw {
17924
17930
  editorOptions: this.options
17925
17931
  });
17926
17932
  let curIndex;
17927
- const { isPrepend } = options;
17933
+ const { isPrepend, isSubmitHistory = true } = options;
17928
17934
  if (isPrepend) {
17929
17935
  this.elementList.splice(1, 0, ...elementList);
17930
17936
  curIndex = elementList.length;
@@ -17934,7 +17940,8 @@ class Draw {
17934
17940
  }
17935
17941
  this.range.setRange(curIndex, curIndex);
17936
17942
  this.render({
17937
- curIndex
17943
+ curIndex,
17944
+ isSubmitHistory
17938
17945
  });
17939
17946
  }
17940
17947
  spliceElementList(elementList, start, deleteCount, items, options) {
@@ -19907,8 +19914,9 @@ class CommandAdapt {
19907
19914
  return;
19908
19915
  this.canvasEvent.applyPainterStyle();
19909
19916
  }
19910
- format() {
19911
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
19917
+ format(options) {
19918
+ const { isIgnoreDisabledRule = false } = options || {};
19919
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
19912
19920
  if (isDisabled)
19913
19921
  return;
19914
19922
  const selection = this.range.getSelectionElementList();
@@ -19935,8 +19943,9 @@ class CommandAdapt {
19935
19943
  });
19936
19944
  this.draw.render(renderOption);
19937
19945
  }
19938
- font(payload) {
19939
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
19946
+ font(payload, options) {
19947
+ const { isIgnoreDisabledRule = false } = options || {};
19948
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
19940
19949
  if (isDisabled)
19941
19950
  return;
19942
19951
  const selection = this.range.getSelectionElementList();
@@ -19965,13 +19974,14 @@ class CommandAdapt {
19965
19974
  });
19966
19975
  }
19967
19976
  }
19968
- size(payload) {
19977
+ size(payload, options) {
19978
+ const { isIgnoreDisabledRule = false } = options || {};
19979
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
19980
+ if (isDisabled)
19981
+ return;
19969
19982
  const { minSize, maxSize, defaultSize } = this.options;
19970
19983
  if (payload < minSize || payload > maxSize)
19971
19984
  return;
19972
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
19973
- if (isDisabled)
19974
- return;
19975
19985
  let renderOption = {};
19976
19986
  let changeElementList = [];
19977
19987
  const selection = this.range.getTextLikeSelectionElementList();
@@ -20010,8 +20020,9 @@ class CommandAdapt {
20010
20020
  this.draw.render(renderOption);
20011
20021
  }
20012
20022
  }
20013
- sizeAdd() {
20014
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20023
+ sizeAdd(options) {
20024
+ const { isIgnoreDisabledRule = false } = options || {};
20025
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20015
20026
  if (isDisabled)
20016
20027
  return;
20017
20028
  const { defaultSize, maxSize } = this.options;
@@ -20061,8 +20072,9 @@ class CommandAdapt {
20061
20072
  this.draw.render(renderOption);
20062
20073
  }
20063
20074
  }
20064
- sizeMinus() {
20065
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20075
+ sizeMinus(options) {
20076
+ const { isIgnoreDisabledRule = false } = options || {};
20077
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20066
20078
  if (isDisabled)
20067
20079
  return;
20068
20080
  const { defaultSize, minSize } = this.options;
@@ -20112,9 +20124,10 @@ class CommandAdapt {
20112
20124
  this.draw.render(renderOption);
20113
20125
  }
20114
20126
  }
20115
- bold() {
20127
+ bold(options) {
20116
20128
  var _a;
20117
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20129
+ const { isIgnoreDisabledRule = false } = options || {};
20130
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20118
20131
  if (isDisabled)
20119
20132
  return;
20120
20133
  const selection = this.range.getSelectionElementList();
@@ -20144,9 +20157,10 @@ class CommandAdapt {
20144
20157
  });
20145
20158
  }
20146
20159
  }
20147
- italic() {
20160
+ italic(options) {
20148
20161
  var _a;
20149
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20162
+ const { isIgnoreDisabledRule = false } = options || {};
20163
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20150
20164
  if (isDisabled)
20151
20165
  return;
20152
20166
  const selection = this.range.getSelectionElementList();
@@ -20176,9 +20190,10 @@ class CommandAdapt {
20176
20190
  });
20177
20191
  }
20178
20192
  }
20179
- underline(textDecoration) {
20193
+ underline(textDecoration, options) {
20180
20194
  var _a;
20181
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20195
+ const { isIgnoreDisabledRule = false } = options || {};
20196
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20182
20197
  if (isDisabled)
20183
20198
  return;
20184
20199
  const selection = this.range.getSelectionElementList();
@@ -20216,9 +20231,10 @@ class CommandAdapt {
20216
20231
  });
20217
20232
  }
20218
20233
  }
20219
- strikeout() {
20234
+ strikeout(options) {
20220
20235
  var _a;
20221
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20236
+ const { isIgnoreDisabledRule = false } = options || {};
20237
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20222
20238
  if (isDisabled)
20223
20239
  return;
20224
20240
  const selection = this.range.getSelectionElementList();
@@ -20251,8 +20267,9 @@ class CommandAdapt {
20251
20267
  });
20252
20268
  }
20253
20269
  }
20254
- superscript() {
20255
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20270
+ superscript(options) {
20271
+ const { isIgnoreDisabledRule = false } = options || {};
20272
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20256
20273
  if (isDisabled)
20257
20274
  return;
20258
20275
  const selection = this.range.getSelectionElementList();
@@ -20273,8 +20290,9 @@ class CommandAdapt {
20273
20290
  });
20274
20291
  this.draw.render({ isSetCursor: false });
20275
20292
  }
20276
- subscript() {
20277
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20293
+ subscript(options) {
20294
+ const { isIgnoreDisabledRule = false } = options || {};
20295
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20278
20296
  if (isDisabled)
20279
20297
  return;
20280
20298
  const selection = this.range.getSelectionElementList();
@@ -20295,8 +20313,9 @@ class CommandAdapt {
20295
20313
  });
20296
20314
  this.draw.render({ isSetCursor: false });
20297
20315
  }
20298
- color(payload) {
20299
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20316
+ color(payload, options) {
20317
+ const { isIgnoreDisabledRule = false } = options || {};
20318
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20300
20319
  if (isDisabled)
20301
20320
  return;
20302
20321
  const selection = this.range.getSelectionElementList();
@@ -20336,8 +20355,9 @@ class CommandAdapt {
20336
20355
  });
20337
20356
  }
20338
20357
  }
20339
- highlight(payload) {
20340
- const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
20358
+ highlight(payload, options) {
20359
+ const { isIgnoreDisabledRule = false } = options || {};
20360
+ const isDisabled = !isIgnoreDisabledRule && (this.draw.isReadonly() || this.draw.isDisabled());
20341
20361
  if (isDisabled)
20342
20362
  return;
20343
20363
  const selection = this.range.getSelectionElementList();
@@ -20955,10 +20975,10 @@ class CommandAdapt {
20955
20975
  const selectionElementList = zipElementList(this.range.getSelectionElementList() || []);
20956
20976
  const elementList = this.draw.getElementList();
20957
20977
  const startElement = pickElementAttr(elementList[isCollapsed ? startIndex : startIndex + 1], {
20958
- extraPickAttrs: ["id"]
20978
+ extraPickAttrs: ["id", "controlComponent"]
20959
20979
  });
20960
20980
  const endElement = pickElementAttr(elementList[endIndex], {
20961
- extraPickAttrs: ["id"]
20981
+ extraPickAttrs: ["id", "controlComponent"]
20962
20982
  });
20963
20983
  const positionList = this.position.getPositionList();
20964
20984
  const startPosition = positionList[startIndex];
@@ -21160,7 +21180,7 @@ class CommandAdapt {
21160
21180
  isBreakWhenWrap: true,
21161
21181
  editorOptions: this.options
21162
21182
  });
21163
- this.draw.insertElementList(cloneElementList);
21183
+ this.draw.insertElementList(cloneElementList, options);
21164
21184
  }
21165
21185
  appendElementList(elementList, options) {
21166
21186
  if (!elementList.length)
@@ -22971,5 +22991,5 @@ class Editor {
22971
22991
  this.use = plugin.use.bind(plugin);
22972
22992
  }
22973
22993
  }
22974
- export { AreaMode, BackgroundRepeat, BackgroundSize, BlockType, Command, ControlIndentation, ControlState, ControlType, EDITOR_CLIPBOARD, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, FlexDirection, INTERNAL_CONTEXT_MENU_KEY, ImageDisplay, KeyMap, LETTER_CLASS, LineNumberType, ListStyle, ListType, LocationPosition, MaxHeightRatio, NumberType, PageMode, PaperDirection, RenderMode, RowFlex, TableBorder, TdBorder, TdSlash, TextDecorationStyle, TitleLevel, VerticalAlign, WordBreak, createDomFromElementList, Editor as default, getElementListByHTML, getTextFromElementList, splitText };
22994
+ export { AreaMode, BackgroundRepeat, BackgroundSize, BlockType, Command, ControlComponent, ControlIndentation, ControlState, ControlType, EDITOR_CLIPBOARD, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, FlexDirection, INTERNAL_CONTEXT_MENU_KEY, ImageDisplay, KeyMap, LETTER_CLASS, LineNumberType, ListStyle, ListType, LocationPosition, MaxHeightRatio, NumberType, PageMode, PaperDirection, RenderMode, RowFlex, TableBorder, TdBorder, TdSlash, TextDecorationStyle, TitleLevel, VerticalAlign, WordBreak, createDomFromElementList, Editor as default, getElementListByHTML, getTextFromElementList, splitText };
22975
22995
  //# sourceMappingURL=canvas-editor.es.js.map