@hufe921/canvas-editor 0.9.57 → 0.9.58

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,26 @@
1
+ ## [0.9.58](https://github.com/Hufe921/canvas-editor/compare/v0.9.57...v0.9.58) (2023-12-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * empty list don't render placeholder ([910f756](https://github.com/Hufe921/canvas-editor/commit/910f75662f62dc38f068a71feb4cd68150b83341))
7
+ * multiple empty lists render error in first row ([1487033](https://github.com/Hufe921/canvas-editor/commit/1487033d75e7c94c2fdf748217f79642181eaaf1))
8
+ * not render margin indicator in print mode #354 ([3f1babe](https://github.com/Hufe921/canvas-editor/commit/3f1babec68b5d22babade28214ca9a7212d3cf8a)), closes [#354](https://github.com/Hufe921/canvas-editor/issues/354)
9
+ * repeated input in firefox browser #357 ([6de3ad8](https://github.com/Hufe921/canvas-editor/commit/6de3ad8b21b557ddc9e218d22b283348dcbd9211)), closes [#357](https://github.com/Hufe921/canvas-editor/issues/357)
10
+
11
+
12
+ ### Chores
13
+
14
+ * export splitText function ([bcbd879](https://github.com/Hufe921/canvas-editor/commit/bcbd879e0f44443f0bcac71402330b37def434b2))
15
+ * update eslint fixAll option ([bba0b09](https://github.com/Hufe921/canvas-editor/commit/bba0b090f33e4f3e391a14e22c2b579f132b5348))
16
+
17
+
18
+ ### Features
19
+
20
+ * add control indentation option #345 ([5f1cf3a](https://github.com/Hufe921/canvas-editor/commit/5f1cf3ab37aa22180eee45c02486b478dfbc6b99)), closes [#345](https://github.com/Hufe921/canvas-editor/issues/345)
21
+
22
+
23
+
1
24
  ## [0.9.57](https://github.com/Hufe921/canvas-editor/compare/v0.9.56...v0.9.57) (2023-12-03)
2
25
 
3
26
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.57";
26
+ const version = "0.9.58";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -3589,6 +3589,11 @@ var ImageDisplay;
3589
3589
  ImageDisplay2["INLINE"] = "inline";
3590
3590
  ImageDisplay2["BLOCK"] = "block";
3591
3591
  })(ImageDisplay || (ImageDisplay = {}));
3592
+ var ControlIndentation;
3593
+ (function(ControlIndentation2) {
3594
+ ControlIndentation2["ROW_START"] = "rowStart";
3595
+ ControlIndentation2["VALUE_START"] = "valueStart";
3596
+ })(ControlIndentation || (ControlIndentation = {}));
3592
3597
  function unzipElementList(elementList) {
3593
3598
  const result = [];
3594
3599
  for (let v = 0; v < elementList.length; v++) {
@@ -3765,7 +3770,7 @@ function formatElementList(elementList, options) {
3765
3770
  const isLastLetter = e === valueStrList.length - 1;
3766
3771
  elementList.splice(i, 0, __spreadProps(__spreadValues({}, valueStyleList[valueStyleIndex]), {
3767
3772
  controlId,
3768
- value: value2,
3773
+ value: value2 === "\n" ? ZERO : value2,
3769
3774
  letterSpacing: isLastLetter ? checkboxOption.gap : 0,
3770
3775
  control: el.control,
3771
3776
  controlComponent: ControlComponent.VALUE
@@ -3795,7 +3800,7 @@ function formatElementList(elementList, options) {
3795
3800
  const value2 = valueStrList[e];
3796
3801
  elementList.splice(i, 0, __spreadProps(__spreadValues({}, element), {
3797
3802
  controlId,
3798
- value: value2,
3803
+ value: value2 === "\n" ? ZERO : value2,
3799
3804
  type: element.type || ElementType.TEXT,
3800
3805
  control: el.control,
3801
3806
  controlComponent: ControlComponent.VALUE
@@ -3814,7 +3819,7 @@ function formatElementList(elementList, options) {
3814
3819
  const value2 = placeholderStrList[p];
3815
3820
  elementList.splice(i, 0, __spreadValues({
3816
3821
  controlId,
3817
- value: value2,
3822
+ value: value2 === "\n" ? ZERO : value2,
3818
3823
  type: el.type,
3819
3824
  control: el.control,
3820
3825
  controlComponent: ControlComponent.PLACEHOLDER
@@ -6008,7 +6013,7 @@ function compositionend(host, evt) {
6008
6013
  if (host.compositionInfo) {
6009
6014
  input(evt.data, host);
6010
6015
  }
6011
- });
6016
+ }, 1);
6012
6017
  }
6013
6018
  const cursor = draw.getCursor();
6014
6019
  cursor.clearAgentDomValue();
@@ -6469,9 +6474,7 @@ class Position {
6469
6474
  } else if (curRow.rowFlex === RowFlex.RIGHT) {
6470
6475
  x += innerWidth - curRow.width;
6471
6476
  }
6472
- if (curRow.isList) {
6473
- x += curRow.offsetX || 0;
6474
- }
6477
+ x += curRow.offsetX || 0;
6475
6478
  const tablePreX = x;
6476
6479
  const tablePreY = y;
6477
6480
  for (let j = 0; j < curRow.elementList.length; j++) {
@@ -6575,6 +6578,21 @@ class Position {
6575
6578
  startRowIndex += rowList.length;
6576
6579
  }
6577
6580
  }
6581
+ computeRowPosition(payload) {
6582
+ const { row, innerWidth } = payload;
6583
+ const positionList = [];
6584
+ this.computePageRowPosition({
6585
+ positionList,
6586
+ innerWidth,
6587
+ rowList: [deepClone(row)],
6588
+ pageNo: 0,
6589
+ startX: 0,
6590
+ startY: 0,
6591
+ startIndex: 0,
6592
+ startRowIndex: 0
6593
+ });
6594
+ return positionList;
6595
+ }
6578
6596
  setCursorPosition(position) {
6579
6597
  this.cursorPosition = position;
6580
6598
  }
@@ -12410,7 +12428,7 @@ class Draw {
12410
12428
  return `${el.italic ? "italic " : ""}${el.bold ? "bold " : ""}${size * scale}px ${font}`;
12411
12429
  }
12412
12430
  computeRowList(innerWidth, elementList) {
12413
- var _a, _b, _c, _d, _e;
12431
+ var _a, _b, _c, _d, _e, _f;
12414
12432
  const { defaultSize, defaultRowMargin, scale, tdPadding, defaultTabWidth } = this.options;
12415
12433
  const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight();
12416
12434
  const canvas = document.createElement("canvas");
@@ -12440,7 +12458,7 @@ class Draw {
12440
12458
  boundingBoxAscent: 0,
12441
12459
  boundingBoxDescent: 0
12442
12460
  };
12443
- const offsetX = element.listId ? listStyleMap.get(element.listId) || 0 : 0;
12461
+ const offsetX = curRow.offsetX || element.listId && listStyleMap.get(element.listId) || 0;
12444
12462
  const availableWidth = innerWidth - offsetX;
12445
12463
  if (element.type === ElementType.IMAGE || element.type === ElementType.LATEX) {
12446
12464
  const elementWidth = element.width * scale;
@@ -12676,7 +12694,7 @@ class Draw {
12676
12694
  }
12677
12695
  listId = element.listId;
12678
12696
  if (element.type === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.BLOCK || element.type === ElementType.BLOCK || (preElement == null ? void 0 : preElement.imgDisplay) === ImageDisplay.INLINE || element.imgDisplay === ImageDisplay.INLINE || curRowWidth > availableWidth || i !== 0 && element.value === ZERO || (preElement == null ? void 0 : preElement.listId) !== element.listId) {
12679
- if (curRow.startIndex === 0 && curRow.elementList.length === 1 && (INLINE_ELEMENT_TYPE.includes(element.type) || element.listId)) {
12697
+ if (curRow.startIndex === 0 && curRow.elementList.length === 1 && INLINE_ELEMENT_TYPE.includes(element.type)) {
12680
12698
  curRow.height = defaultBasicRowMarginHeight;
12681
12699
  }
12682
12700
  if ((preElement == null ? void 0 : preElement.rowFlex) === RowFlex.ALIGNMENT && curRowWidth > availableWidth) {
@@ -12696,6 +12714,19 @@ class Draw {
12696
12714
  rowFlex: (_e = elementList[i + 1]) == null ? void 0 : _e.rowFlex,
12697
12715
  isPageBreak: element.type === ElementType.PAGE_BREAK
12698
12716
  };
12717
+ if (rowElement.controlComponent !== ControlComponent.PREFIX && ((_f = rowElement.control) == null ? void 0 : _f.indentation) === ControlIndentation.VALUE_START) {
12718
+ const preStartIndex = curRow.elementList.findIndex((el) => el.controlId === rowElement.controlId && el.controlComponent !== ControlComponent.PREFIX);
12719
+ if (~preStartIndex) {
12720
+ const preRowPositionList = this.position.computeRowPosition({
12721
+ row: curRow,
12722
+ innerWidth: this.getInnerWidth()
12723
+ });
12724
+ const valueStartPosition = preRowPositionList[preStartIndex];
12725
+ if (valueStartPosition) {
12726
+ row.offsetX = valueStartPosition.coordinate.leftTop[0];
12727
+ }
12728
+ }
12729
+ }
12699
12730
  if (element.listId) {
12700
12731
  row.isList = true;
12701
12732
  row.offsetX = listStyleMap.get(element.listId);
@@ -12929,6 +12960,7 @@ class Draw {
12929
12960
  this.blockParticle.clear();
12930
12961
  }
12931
12962
  _drawPage(payload) {
12963
+ var _a;
12932
12964
  const { elementList, positionList, rowList, pageNo } = payload;
12933
12965
  const { inactiveAlpha, pageMode, header, footer, pageNumber } = this.options;
12934
12966
  const innerWidth = this.getInnerWidth();
@@ -12936,7 +12968,9 @@ class Draw {
12936
12968
  ctx.globalAlpha = !this.zone.isMainActive() ? inactiveAlpha : 1;
12937
12969
  this._clearPage(pageNo);
12938
12970
  this.background.render(ctx, pageNo);
12939
- this.margin.render(ctx, pageNo);
12971
+ if (this.mode !== EditorMode.PRINT) {
12972
+ this.margin.render(ctx, pageNo);
12973
+ }
12940
12974
  const index2 = rowList[0].startIndex;
12941
12975
  this.drawRow(ctx, {
12942
12976
  elementList,
@@ -12964,7 +12998,7 @@ class Draw {
12964
12998
  if (pageMode !== PageMode.CONTINUITY && this.options.watermark.data) {
12965
12999
  this.waterMark.render(ctx);
12966
13000
  }
12967
- if (this.elementList.length <= 1) {
13001
+ if (this.elementList.length <= 1 && !((_a = this.elementList[0]) == null ? void 0 : _a.listId)) {
12968
13002
  this.placeholder.render(ctx);
12969
13003
  }
12970
13004
  }
@@ -16462,5 +16496,5 @@ class Editor {
16462
16496
  this.use = plugin.use.bind(plugin);
16463
16497
  }
16464
16498
  }
16465
- 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 };
16499
+ export { 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, TitleLevel, VerticalAlign, WordBreak, Editor as default, splitText };
16466
16500
  //# sourceMappingURL=canvas-editor.es.js.map