@hufe921/canvas-editor 0.9.84 → 0.9.85

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,30 @@
1
+ ## [0.9.85](https://github.com/Hufe921/canvas-editor/compare/v0.9.84...v0.9.85) (2024-07-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * custom override method removes support for asynchronous #672 ([0e705d6](https://github.com/Hufe921/canvas-editor/commit/0e705d6a0bdb0922efd5c47edd8ca9eba9964199)), closes [#672](https://github.com/Hufe921/canvas-editor/issues/672)
7
+ * set control highlight and re render #678 ([24df9d3](https://github.com/Hufe921/canvas-editor/commit/24df9d3b006a8daf795ada677bfd0159e3ccc3f5)), closes [#678](https://github.com/Hufe921/canvas-editor/issues/678)
8
+
9
+
10
+ ### Chores
11
+
12
+ * update build.yml ([a40441d](https://github.com/Hufe921/canvas-editor/commit/a40441dc3994a41ae29c341a542be6e0e7dada2e))
13
+
14
+
15
+ ### Features
16
+
17
+ * add render mode #667 ([affd191](https://github.com/Hufe921/canvas-editor/commit/affd1911552a73a2b63a13f2c423121637830b99)), closes [#667](https://github.com/Hufe921/canvas-editor/issues/667)
18
+ * add title deletable property #670 ([b3d8413](https://github.com/Hufe921/canvas-editor/commit/b3d8413b35050eac626af1c57beaaf1b8d692a0e)), closes [#670](https://github.com/Hufe921/canvas-editor/issues/670)
19
+ * insert element boundary optimization #669 ([de44bd6](https://github.com/Hufe921/canvas-editor/commit/de44bd68ab01e5ffa8d6a8dc5d566b0cdb8d08e6)), closes [#669](https://github.com/Hufe921/canvas-editor/issues/669)
20
+
21
+
22
+ ### Tests
23
+
24
+ * update text test case ([c24da73](https://github.com/Hufe921/canvas-editor/commit/c24da737b15200775a7d4a5edf4e2224f6ec5429))
25
+
26
+
27
+
1
28
  ## [0.9.84](https://github.com/Hufe921/canvas-editor/compare/v0.9.83...v0.9.84) (2024-06-30)
2
29
 
3
30
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.84";
26
+ const version = "0.9.85";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -364,10 +364,6 @@ 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
- }
371
367
  const CURSOR_AGENT_OFFSET_HEIGHT = 12;
372
368
  const defaultCursorOption = {
373
369
  width: 1,
@@ -4355,7 +4351,7 @@ function formatElementContext(sourceElementList, formatElementList2, anchorIndex
4355
4351
  let isBreakWarped = false;
4356
4352
  for (let e = 0; e < formatElementList2.length; e++) {
4357
4353
  const targetElement = formatElementList2[e];
4358
- if (isBreakWhenWrap && !copyElement.listId && /^\n/.test(targetElement.value)) {
4354
+ if (isBreakWhenWrap && !copyElement.listId && START_LINE_BREAK_REG.test(targetElement.value)) {
4359
4355
  isBreakWarped = true;
4360
4356
  }
4361
4357
  if (isBreakWarped || !copyElement.listId && targetElement.type === ElementType.LIST) {
@@ -5060,7 +5056,7 @@ function pasteImage(host, file) {
5060
5056
  };
5061
5057
  };
5062
5058
  }
5063
- async function pasteByEvent(host, evt) {
5059
+ function pasteByEvent(host, evt) {
5064
5060
  const draw = host.getDraw();
5065
5061
  const isReadonly = draw.isReadonly();
5066
5062
  if (isReadonly)
@@ -5070,7 +5066,7 @@ async function pasteByEvent(host, evt) {
5070
5066
  return;
5071
5067
  const { paste } = draw.getOverride();
5072
5068
  if (paste) {
5073
- const overrideResult = isPromiseFunction(paste) ? await paste(evt) : paste(evt);
5069
+ const overrideResult = paste(evt);
5074
5070
  if ((overrideResult == null ? void 0 : overrideResult.preventDefault) !== false)
5075
5071
  return;
5076
5072
  }
@@ -5123,7 +5119,7 @@ async function pasteByApi(host, options) {
5123
5119
  return;
5124
5120
  const { paste } = draw.getOverride();
5125
5121
  if (paste) {
5126
- const overrideResult = isPromiseFunction(paste) ? await paste() : paste();
5122
+ const overrideResult = paste();
5127
5123
  if ((overrideResult == null ? void 0 : overrideResult.preventDefault) !== false)
5128
5124
  return;
5129
5125
  }
@@ -5404,6 +5400,11 @@ var WordBreak;
5404
5400
  WordBreak2["BREAK_ALL"] = "break-all";
5405
5401
  WordBreak2["BREAK_WORD"] = "break-word";
5406
5402
  })(WordBreak || (WordBreak = {}));
5403
+ var RenderMode;
5404
+ (function(RenderMode2) {
5405
+ RenderMode2["SPEED"] = "speed";
5406
+ RenderMode2["COMPATIBILITY"] = "compatibility";
5407
+ })(RenderMode || (RenderMode = {}));
5407
5408
  var MouseEventButton;
5408
5409
  (function(MouseEventButton2) {
5409
5410
  MouseEventButton2[MouseEventButton2["LEFT"] = 0] = "LEFT";
@@ -6166,8 +6167,10 @@ function enter(evt, host) {
6166
6167
  if (evt.shiftKey && startElement.listId) {
6167
6168
  enterText.listWrap = true;
6168
6169
  }
6170
+ formatElementContext(elementList, [enterText], startIndex, {
6171
+ isBreakWhenWrap: true
6172
+ });
6169
6173
  if (!(endElement.titleId && endElement.titleId !== ((_b = elementList[endIndex + 1]) == null ? void 0 : _b.titleId))) {
6170
- formatElementContext(elementList, [enterText], startIndex);
6171
6174
  const copyElement = getAnchorElement(elementList, endIndex);
6172
6175
  if (copyElement) {
6173
6176
  const copyAttr = [...EDITOR_ROW_ATTR];
@@ -6982,11 +6985,11 @@ function cut(host) {
6982
6985
  rangeManager.setRange(curIndex, curIndex);
6983
6986
  draw.render({ curIndex });
6984
6987
  }
6985
- async function copy(host) {
6988
+ function copy(host) {
6986
6989
  const draw = host.getDraw();
6987
6990
  const { copy: copy2 } = draw.getOverride();
6988
6991
  if (copy2) {
6989
- const overrideResult = isPromiseFunction(copy2) ? await copy2() : copy2();
6992
+ const overrideResult = copy2();
6990
6993
  if ((overrideResult == null ? void 0 : overrideResult.preventDefault) !== false)
6991
6994
  return;
6992
6995
  }
@@ -7034,12 +7037,12 @@ async function copy(host) {
7034
7037
  return;
7035
7038
  writeElementList(copyElementList, draw.getOptions());
7036
7039
  }
7037
- async function drop(evt, host) {
7040
+ function drop(evt, host) {
7038
7041
  var _a, _b;
7039
7042
  const draw = host.getDraw();
7040
7043
  const { drop: drop2 } = draw.getOverride();
7041
7044
  if (drop2) {
7042
- const overrideResult = isPromiseFunction(drop2) ? await drop2(evt) : drop2(evt);
7045
+ const overrideResult = drop2(evt);
7043
7046
  if ((overrideResult == null ? void 0 : overrideResult.preventDefault) !== false)
7044
7047
  return;
7045
7048
  }
@@ -9250,6 +9253,14 @@ class TextParticle {
9250
9253
  }
9251
9254
  record(ctx, element, x, y) {
9252
9255
  this.ctx = ctx;
9256
+ if (this.options.renderMode === RenderMode.COMPATIBILITY) {
9257
+ this._setCurXY(x, y);
9258
+ this.text = element.value;
9259
+ this.curStyle = element.style;
9260
+ this.curColor = element.color;
9261
+ this.complete();
9262
+ return;
9263
+ }
9253
9264
  if (!this.text) {
9254
9265
  this._setCurXY(x, y);
9255
9266
  }
@@ -14951,7 +14962,8 @@ class Draw {
14951
14962
  if (!this.control.getActiveControl()) {
14952
14963
  let deleteIndex = endIndex - 1;
14953
14964
  while (deleteIndex >= start) {
14954
- if (((_c = (_b = elementList[deleteIndex]) == null ? void 0 : _b.control) == null ? void 0 : _c.deletable) !== false) {
14965
+ const deleteElement = elementList[deleteIndex];
14966
+ if (((_b = deleteElement == null ? void 0 : deleteElement.control) == null ? void 0 : _b.deletable) !== false && ((_c = deleteElement == null ? void 0 : deleteElement.title) == null ? void 0 : _c.deletable) !== false) {
14955
14967
  elementList.splice(deleteIndex, 1);
14956
14968
  }
14957
14969
  deleteIndex--;
@@ -16603,6 +16615,7 @@ function mergeOption(options = {}) {
16603
16615
  marginIndicatorColor: "#BABABA",
16604
16616
  margins: [100, 120, 100, 120],
16605
16617
  pageMode: PageMode.PAGING,
16618
+ renderMode: RenderMode.SPEED,
16606
16619
  defaultHyperlinkColor: "#0000FF",
16607
16620
  paperDirection: PaperDirection.VERTICAL,
16608
16621
  inactiveAlpha: 0.6,
@@ -18616,7 +18629,9 @@ class CommandAdapt {
18616
18629
  const cloneElementList = deepClone(payload);
18617
18630
  const { startIndex } = this.range.getRange();
18618
18631
  const elementList = this.draw.getElementList();
18619
- formatElementContext(elementList, cloneElementList, startIndex);
18632
+ formatElementContext(elementList, cloneElementList, startIndex, {
18633
+ isBreakWhenWrap: true
18634
+ });
18620
18635
  this.draw.insertElementList(cloneElementList);
18621
18636
  }
18622
18637
  appendElementList(elementList, options) {
@@ -18808,6 +18823,9 @@ class CommandAdapt {
18808
18823
  }
18809
18824
  setControlHighlight(payload) {
18810
18825
  this.draw.getControl().setHighlightList(payload);
18826
+ this.draw.render({
18827
+ isSubmitHistory: false
18828
+ });
18811
18829
  }
18812
18830
  updateOptions(payload) {
18813
18831
  const newOption = mergeOption(payload);
@@ -20152,5 +20170,5 @@ class Editor {
20152
20170
  this.use = plugin.use.bind(plugin);
20153
20171
  }
20154
20172
  }
20155
- 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, RowFlex, TableBorder, TdBorder, TdSlash, TextDecorationStyle, TitleLevel, VerticalAlign, WordBreak, Editor as default, splitText };
20173
+ 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 };
20156
20174
  //# sourceMappingURL=canvas-editor.es.js.map