@hufe921/canvas-editor 0.9.66 → 0.9.68

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,45 @@
1
+ ## [0.9.68](https://github.com/Hufe921/canvas-editor/compare/v0.9.67...v0.9.68) (2024-03-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * dragging element boundary error ([a2d8dd5](https://github.com/Hufe921/canvas-editor/commit/a2d8dd55b36a09b42fae377e06bf667dced3857e))
7
+ * hyperlink word count statistics #449 ([180bd08](https://github.com/Hufe921/canvas-editor/commit/180bd088397159e32dc70da4eefd507721ced432)), closes [#449](https://github.com/Hufe921/canvas-editor/issues/449)
8
+
9
+
10
+ ### Features
11
+
12
+ * set print layout format when printing #448 ([c6534f7](https://github.com/Hufe921/canvas-editor/commit/c6534f766d8640cbea4e441541065d25e0dd8b82)), closes [#448](https://github.com/Hufe921/canvas-editor/issues/448)
13
+
14
+
15
+ ### Performance Improvements
16
+
17
+ * history stack memory ([5044c31](https://github.com/Hufe921/canvas-editor/commit/5044c319211322c0ab2a2db461b029f34b292939))
18
+
19
+
20
+
21
+ ## [0.9.67](https://github.com/Hufe921/canvas-editor/compare/v0.9.66...v0.9.67) (2024-03-01)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * dragging image boundary error within the control ([52590f6](https://github.com/Hufe921/canvas-editor/commit/52590f6d92746e30aaf92efe85b0486ddd3cb467))
27
+ * text control clear value range context error #439 (#443) ([c299290](https://github.com/Hufe921/canvas-editor/commit/c2992909b6c7ff94d6685007d09fa9611b5e6d8d)), closes [#439](https://github.com/Hufe921/canvas-editor/issues/439) [#443](https://github.com/Hufe921/canvas-editor/issues/443)
28
+
29
+
30
+ ### Chores
31
+
32
+ * add underline decoration type demo ([aa12296](https://github.com/Hufe921/canvas-editor/commit/aa12296ef67aa66e46d6615e91833199746c8bae))
33
+ * update FUNDING.yml ([dc2804c](https://github.com/Hufe921/canvas-editor/commit/dc2804c492b1d5d745ec58276e4ff8bc1ed825b3))
34
+
35
+
36
+ ### Features
37
+
38
+ * add text decoration property ([f1570f2](https://github.com/Hufe921/canvas-editor/commit/f1570f2180086c1d4f9bf92e06edf5baecbd436c))
39
+ * add textDecoration property to the rangeStyleChange event ([a7fa847](https://github.com/Hufe921/canvas-editor/commit/a7fa847b198010cc5c7b8af9c860a04fe1c4250d))
40
+
41
+
42
+
1
43
  ## [0.9.66](https://github.com/Hufe921/canvas-editor/compare/v0.9.65...v0.9.66) (2024-02-24)
2
44
 
3
45
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.66";
26
+ const version = "0.9.68";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -119,6 +119,22 @@ function throttle(func, delay) {
119
119
  }
120
120
  };
121
121
  }
122
+ function deepCloneOmitKeys(obj, omitKeys) {
123
+ if (!obj || typeof obj !== "object") {
124
+ return obj;
125
+ }
126
+ let newObj = {};
127
+ if (Array.isArray(obj)) {
128
+ newObj = obj.map((item) => deepCloneOmitKeys(item, omitKeys));
129
+ } else {
130
+ Object.keys(obj).forEach((key) => {
131
+ if (omitKeys.includes(key))
132
+ return;
133
+ return newObj[key] = deepCloneOmitKeys(obj[key], omitKeys);
134
+ });
135
+ }
136
+ return newObj;
137
+ }
122
138
  function deepClone(obj) {
123
139
  if (!obj || typeof obj !== "object") {
124
140
  return obj;
@@ -325,6 +341,16 @@ function isArrayEqual(arr1, arr2) {
325
341
  }
326
342
  return !arr1.some((item) => !arr2.includes(item));
327
343
  }
344
+ function isObjectEqual(obj1, obj2) {
345
+ if (!isObject(obj1) || !isObject(obj2))
346
+ return false;
347
+ const obj1Keys = Object.keys(obj1);
348
+ const obj2Keys = Object.keys(obj2);
349
+ if (obj1Keys.length !== obj2Keys.length) {
350
+ return false;
351
+ }
352
+ return !obj1Keys.some((key) => obj2[key] !== obj1[key]);
353
+ }
328
354
  const CURSOR_AGENT_OFFSET_HEIGHT = 12;
329
355
  const defaultCursorOption = {
330
356
  width: 1,
@@ -369,7 +395,8 @@ const EDITOR_ELEMENT_STYLE_ATTR = [
369
395
  "size",
370
396
  "italic",
371
397
  "underline",
372
- "strikeout"
398
+ "strikeout",
399
+ "textDecoration"
373
400
  ];
374
401
  const EDITOR_ROW_ATTR = ["rowFlex", "rowMargin"];
375
402
  const EDITOR_ELEMENT_COPY_ATTR = [
@@ -389,7 +416,8 @@ const EDITOR_ELEMENT_COPY_ATTR = [
389
416
  "dateFormat",
390
417
  "groupIds",
391
418
  "rowFlex",
392
- "rowMargin"
419
+ "rowMargin",
420
+ "textDecoration"
393
421
  ];
394
422
  const EDITOR_ELEMENT_ZIP_ATTR = [
395
423
  "type",
@@ -422,7 +450,8 @@ const EDITOR_ELEMENT_ZIP_ATTR = [
422
450
  "groupIds",
423
451
  "conceptId",
424
452
  "imgDisplay",
425
- "imgFloatPosition"
453
+ "imgFloatPosition",
454
+ "textDecoration"
426
455
  ];
427
456
  const TABLE_TD_ZIP_ATTR = [
428
457
  "verticalAlign",
@@ -441,6 +470,11 @@ const LIST_CONTEXT_ATTR = [
441
470
  "listType",
442
471
  "listStyle"
443
472
  ];
473
+ const CONTROL_CONTEXT_ATTR = [
474
+ "control",
475
+ "controlId",
476
+ "controlComponent"
477
+ ];
444
478
  const EDITOR_ELEMENT_CONTEXT_ATTR = [
445
479
  ...TABLE_CONTEXT_ATTR,
446
480
  ...TITLE_CONTEXT_ATTR,
@@ -4613,6 +4647,12 @@ ${listIndex + 1}.${buildText(listElementList)}${isLast ? `
4613
4647
  }
4614
4648
  return buildText(zipElementList(elementList));
4615
4649
  }
4650
+ function getSlimCloneElementList(elementList) {
4651
+ return deepCloneOmitKeys(elementList, [
4652
+ "metrics",
4653
+ "style"
4654
+ ]);
4655
+ }
4616
4656
  function setClipboardData(data2) {
4617
4657
  localStorage.setItem(EDITOR_CLIPBOARD, JSON.stringify({
4618
4658
  text: data2.text,
@@ -5232,6 +5272,7 @@ function setRangeCache(host) {
5232
5272
  host.cacheRange = deepClone(rangeManager.getRange());
5233
5273
  host.cacheElementList = draw.getElementList();
5234
5274
  host.cachePositionList = position.getPositionList();
5275
+ host.cachePositionContext = position.getPositionContext();
5235
5276
  }
5236
5277
  function mousedown(evt, host) {
5237
5278
  var _a;
@@ -5369,13 +5410,14 @@ function moveImgPosition(element, evt, host) {
5369
5410
  draw.getImageParticle().destroyFloatImage();
5370
5411
  }
5371
5412
  function mouseup(evt, host) {
5372
- var _a, _b, _c;
5413
+ var _a, _b, _c, _d;
5373
5414
  if (host.isAllowDrop) {
5374
5415
  const draw = host.getDraw();
5375
5416
  if (draw.isReadonly())
5376
5417
  return;
5377
5418
  const position = draw.getPosition();
5378
5419
  const positionList = position.getPositionList();
5420
+ const positionContext = position.getPositionContext();
5379
5421
  const rangeManager = draw.getRange();
5380
5422
  const cacheRange = host.cacheRange;
5381
5423
  const cacheElementList = host.cacheElementList;
@@ -5384,7 +5426,7 @@ function mouseup(evt, host) {
5384
5426
  const isCacheRangeCollapsed = cacheRange.startIndex === cacheRange.endIndex;
5385
5427
  const cacheStartIndex = isCacheRangeCollapsed ? cacheRange.startIndex - 1 : cacheRange.startIndex;
5386
5428
  const cacheEndIndex = cacheRange.endIndex;
5387
- if (range.startIndex >= cacheStartIndex && range.endIndex <= cacheEndIndex) {
5429
+ if (range.startIndex >= cacheStartIndex && range.endIndex <= cacheEndIndex && ((_a = host.cachePositionContext) == null ? void 0 : _a.tdId) === positionContext.tdId) {
5388
5430
  draw.clearSideEffect();
5389
5431
  let isSubmitHistory = false;
5390
5432
  if (isCacheRangeCollapsed) {
@@ -5413,7 +5455,7 @@ function mouseup(evt, host) {
5413
5455
  if (isContainControl) {
5414
5456
  const cacheStartElement2 = cacheElementList[cacheStartIndex + 1];
5415
5457
  const cacheEndElement2 = cacheElementList[cacheEndIndex];
5416
- const isAllowDragControl = (!cacheStartElement2.controlId || cacheStartElement2.controlComponent === ControlComponent.PREFIX) && (!cacheEndElement2.controlId || cacheEndElement2.controlComponent === ControlComponent.POSTFIX) || cacheStartElement2.controlId === cacheEndElement2.controlId && cacheStartElement2.controlComponent === ControlComponent.PREFIX && cacheEndElement2.controlComponent === ControlComponent.POSTFIX || ((_a = cacheStartElement2.control) == null ? void 0 : _a.type) === ControlType.TEXT && cacheStartElement2.controlComponent === ControlComponent.VALUE && ((_b = cacheEndElement2.control) == null ? void 0 : _b.type) === ControlType.TEXT && cacheEndElement2.controlComponent === ControlComponent.VALUE;
5458
+ const isAllowDragControl = (!cacheStartElement2.controlId || cacheStartElement2.controlComponent === ControlComponent.PREFIX) && (!cacheEndElement2.controlId || cacheEndElement2.controlComponent === ControlComponent.POSTFIX) || cacheStartElement2.controlId === cacheEndElement2.controlId && cacheStartElement2.controlComponent === ControlComponent.PREFIX && cacheEndElement2.controlComponent === ControlComponent.POSTFIX || ((_b = cacheStartElement2.control) == null ? void 0 : _b.type) === ControlType.TEXT && cacheStartElement2.controlComponent === ControlComponent.VALUE && ((_c = cacheEndElement2.control) == null ? void 0 : _c.type) === ControlType.TEXT && cacheEndElement2.controlComponent === ControlComponent.VALUE;
5417
5459
  if (!isAllowDragControl) {
5418
5460
  draw.render({
5419
5461
  curIndex: range.startIndex,
@@ -5426,8 +5468,7 @@ function mouseup(evt, host) {
5426
5468
  const editorOptions = draw.getOptions();
5427
5469
  const elementList = draw.getElementList();
5428
5470
  const replaceElementList = dragElementList.map((el) => {
5429
- var _a2;
5430
- if (!el.type || el.type === ElementType.TEXT || ((_a2 = el.control) == null ? void 0 : _a2.type) === ControlType.TEXT) {
5471
+ if (!el.type || el.type === ElementType.TEXT) {
5431
5472
  const newElement = {
5432
5473
  value: el.value
5433
5474
  };
@@ -5439,7 +5480,7 @@ function mouseup(evt, host) {
5439
5480
  });
5440
5481
  return newElement;
5441
5482
  } else {
5442
- const newElement = deepClone(el);
5483
+ const newElement = omitObject(deepClone(el), CONTROL_CONTEXT_ATTR);
5443
5484
  formatElementList([newElement], {
5444
5485
  isHandleFirstElement: false,
5445
5486
  editorOptions
@@ -5448,6 +5489,8 @@ function mouseup(evt, host) {
5448
5489
  }
5449
5490
  });
5450
5491
  formatElementContext(elementList, replaceElementList, range.startIndex);
5492
+ const cacheStartElement = cacheElementList[cacheStartIndex];
5493
+ const cacheStartPosition = cachePositionList[cacheStartIndex];
5451
5494
  const cacheRangeStartId = createDragId(cacheElementList[cacheStartIndex]);
5452
5495
  const cacheRangeEndId = createDragId(cacheElementList[cacheEndIndex]);
5453
5496
  const replaceLength = replaceElementList.length;
@@ -5477,15 +5520,12 @@ function mouseup(evt, host) {
5477
5520
  startIndex: cacheRangeStartIndex,
5478
5521
  endIndex: cacheRangeEndIndex
5479
5522
  }));
5480
- (_c = control.getActiveControl()) == null ? void 0 : _c.cut();
5523
+ (_d = control.getActiveControl()) == null ? void 0 : _d.cut();
5481
5524
  } else {
5482
5525
  draw.spliceElementList(cacheElementList, cacheRangeStartIndex + 1, cacheRangeEndIndex - cacheRangeStartIndex);
5483
5526
  }
5484
5527
  const startElement = elementList[range.startIndex];
5485
- const cacheStartElement = cacheElementList[cacheStartIndex];
5486
5528
  const startPosition = positionList[range.startIndex];
5487
- const cacheStartPosition = cachePositionList[cacheStartIndex];
5488
- const positionContext = position.getPositionContext();
5489
5529
  let positionContextIndex = positionContext.index;
5490
5530
  if (positionContextIndex) {
5491
5531
  if (startElement.tableId && !cacheStartElement.tableId) {
@@ -6378,6 +6418,7 @@ class CanvasEvent {
6378
6418
  __publicField(this, "cacheRange");
6379
6419
  __publicField(this, "cacheElementList");
6380
6420
  __publicField(this, "cachePositionList");
6421
+ __publicField(this, "cachePositionContext");
6381
6422
  __publicField(this, "mouseDownStartPosition");
6382
6423
  __publicField(this, "draw");
6383
6424
  __publicField(this, "pageContainer");
@@ -6397,6 +6438,7 @@ class CanvasEvent {
6397
6438
  this.cacheRange = null;
6398
6439
  this.cacheElementList = null;
6399
6440
  this.cachePositionList = null;
6441
+ this.cachePositionContext = null;
6400
6442
  this.mouseDownStartPosition = null;
6401
6443
  }
6402
6444
  getDraw() {
@@ -7443,6 +7485,7 @@ class RangeManager {
7443
7485
  const level = curElement.level || null;
7444
7486
  const listType = curElement.listType || null;
7445
7487
  const listStyle = curElement.listStyle || null;
7488
+ const textDecoration = underline ? curElement.textDecoration || null : null;
7446
7489
  const painter = !!this.draw.getPainterStyle();
7447
7490
  const undo = this.historyManager.isCanUndo();
7448
7491
  const redo = this.historyManager.isCanRedo();
@@ -7466,7 +7509,8 @@ class RangeManager {
7466
7509
  level,
7467
7510
  listType,
7468
7511
  listStyle,
7469
- groupIds
7512
+ groupIds,
7513
+ textDecoration
7470
7514
  };
7471
7515
  if (rangeStyleChangeListener) {
7472
7516
  rangeStyleChangeListener(rangeStyle);
@@ -7505,7 +7549,8 @@ class RangeManager {
7505
7549
  level: null,
7506
7550
  listType: null,
7507
7551
  listStyle: null,
7508
- groupIds: null
7552
+ groupIds: null,
7553
+ textDecoration: null
7509
7554
  };
7510
7555
  if (rangeStyleChangeListener) {
7511
7556
  rangeStyleChangeListener(rangeStyle);
@@ -7681,10 +7726,12 @@ class AbstractRichText {
7681
7726
  constructor() {
7682
7727
  __publicField(this, "fillRect");
7683
7728
  __publicField(this, "fillColor");
7729
+ __publicField(this, "fillDecorationStyle");
7684
7730
  this.fillRect = this.clearFillInfo();
7685
7731
  }
7686
7732
  clearFillInfo() {
7687
7733
  this.fillColor = void 0;
7734
+ this.fillDecorationStyle = void 0;
7688
7735
  this.fillRect = {
7689
7736
  x: 0,
7690
7737
  y: 0,
@@ -7693,12 +7740,12 @@ class AbstractRichText {
7693
7740
  };
7694
7741
  return this.fillRect;
7695
7742
  }
7696
- recordFillInfo(ctx, x, y, width, height, color) {
7743
+ recordFillInfo(ctx, x, y, width, height, color, decorationStyle) {
7697
7744
  const isFirstRecord = !this.fillRect.width;
7698
- if (!isFirstRecord && this.fillColor !== color) {
7745
+ if (!isFirstRecord && (this.fillColor !== color || this.fillDecorationStyle !== decorationStyle)) {
7699
7746
  this.render(ctx);
7700
7747
  this.clearFillInfo();
7701
- this.recordFillInfo(ctx, x, y, width, height, color);
7748
+ this.recordFillInfo(ctx, x, y, width, height, color, decorationStyle);
7702
7749
  return;
7703
7750
  }
7704
7751
  if (isFirstRecord) {
@@ -7710,6 +7757,7 @@ class AbstractRichText {
7710
7757
  }
7711
7758
  this.fillRect.width += width;
7712
7759
  this.fillColor = color;
7760
+ this.fillDecorationStyle = decorationStyle;
7713
7761
  }
7714
7762
  }
7715
7763
  class Highlight extends AbstractRichText {
@@ -8041,24 +8089,92 @@ class Strikeout extends AbstractRichText {
8041
8089
  this.clearFillInfo();
8042
8090
  }
8043
8091
  }
8092
+ var TextDecorationStyle;
8093
+ (function(TextDecorationStyle2) {
8094
+ TextDecorationStyle2["SOLID"] = "solid";
8095
+ TextDecorationStyle2["DOUBLE"] = "double";
8096
+ TextDecorationStyle2["DASHED"] = "dashed";
8097
+ TextDecorationStyle2["DOTTED"] = "dotted";
8098
+ TextDecorationStyle2["WAVY"] = "wavy";
8099
+ })(TextDecorationStyle || (TextDecorationStyle = {}));
8100
+ var DashType;
8101
+ (function(DashType2) {
8102
+ DashType2["SOLID"] = "solid";
8103
+ DashType2["DASHED"] = "dashed";
8104
+ DashType2["DOTTED"] = "dotted";
8105
+ })(DashType || (DashType = {}));
8044
8106
  class Underline extends AbstractRichText {
8045
8107
  constructor(draw) {
8046
8108
  super();
8047
8109
  __publicField(this, "options");
8048
8110
  this.options = draw.getOptions();
8049
8111
  }
8112
+ _drawLine(ctx, startX, startY, width, dashType) {
8113
+ const endX = startX + width;
8114
+ ctx.beginPath();
8115
+ switch (dashType) {
8116
+ case DashType.DASHED:
8117
+ ctx.setLineDash([3, 1]);
8118
+ break;
8119
+ case DashType.DOTTED:
8120
+ ctx.setLineDash([1, 1]);
8121
+ break;
8122
+ }
8123
+ ctx.moveTo(startX, startY);
8124
+ ctx.lineTo(endX, startY);
8125
+ ctx.stroke();
8126
+ }
8127
+ _drawDouble(ctx, startX, startY, width) {
8128
+ const SPACING = 3;
8129
+ const endX = startX + width;
8130
+ const endY = startY + SPACING * this.options.scale;
8131
+ ctx.beginPath();
8132
+ ctx.moveTo(startX, startY);
8133
+ ctx.lineTo(endX, startY);
8134
+ ctx.stroke();
8135
+ ctx.beginPath();
8136
+ ctx.moveTo(startX, endY);
8137
+ ctx.lineTo(endX, endY);
8138
+ ctx.stroke();
8139
+ }
8140
+ _drawWave(ctx, startX, startY, width) {
8141
+ const { scale } = this.options;
8142
+ const AMPLITUDE = 1.2 * scale;
8143
+ const FREQUENCY = 1 / scale;
8144
+ const adjustY = startY + 2 * AMPLITUDE;
8145
+ ctx.beginPath();
8146
+ for (let x = 0; x < width; x++) {
8147
+ const y = AMPLITUDE * Math.sin(FREQUENCY * x);
8148
+ ctx.lineTo(startX + x, adjustY + y);
8149
+ }
8150
+ ctx.stroke();
8151
+ }
8050
8152
  render(ctx) {
8051
8153
  if (!this.fillRect.width)
8052
8154
  return;
8053
- const { underlineColor } = this.options;
8155
+ const { underlineColor, scale } = this.options;
8054
8156
  const { x, y, width } = this.fillRect;
8055
8157
  ctx.save();
8056
8158
  ctx.strokeStyle = this.fillColor || underlineColor;
8159
+ ctx.lineWidth = scale;
8057
8160
  const adjustY = Math.floor(y + 2 * ctx.lineWidth) + 0.5;
8058
- ctx.beginPath();
8059
- ctx.moveTo(x, adjustY);
8060
- ctx.lineTo(x + width, adjustY);
8061
- ctx.stroke();
8161
+ switch (this.fillDecorationStyle) {
8162
+ case TextDecorationStyle.WAVY:
8163
+ this._drawWave(ctx, x, adjustY, width);
8164
+ break;
8165
+ case TextDecorationStyle.DOUBLE:
8166
+ this._drawDouble(ctx, x, adjustY, width);
8167
+ break;
8168
+ case TextDecorationStyle.DASHED:
8169
+ this._drawLine(ctx, x, adjustY, width, DashType.DASHED);
8170
+ break;
8171
+ case TextDecorationStyle.DOTTED:
8172
+ this._drawLine(ctx, x, adjustY, width, DashType.DOTTED);
8173
+ break;
8174
+ default:
8175
+ this._drawLine(ctx, x, adjustY, width);
8176
+ break;
8177
+ }
8062
8178
  ctx.restore();
8063
8179
  this.clearFillInfo();
8064
8180
  }
@@ -9613,9 +9729,9 @@ class TextControl {
9613
9729
  getElement() {
9614
9730
  return this.element;
9615
9731
  }
9616
- getValue() {
9617
- const elementList = this.control.getElementList();
9618
- const { startIndex } = this.control.getRange();
9732
+ getValue(context = {}) {
9733
+ const elementList = context.elementList || this.control.getElementList();
9734
+ const { startIndex } = context.range || this.control.getRange();
9619
9735
  const startElement = elementList[startIndex];
9620
9736
  const data2 = [];
9621
9737
  let preIndex = startIndex;
@@ -9676,7 +9792,7 @@ class TextControl {
9676
9792
  const range = context.range || this.control.getRange();
9677
9793
  const { startIndex, endIndex } = range;
9678
9794
  this.control.getDraw().spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
9679
- const value = this.getValue();
9795
+ const value = this.getValue(context);
9680
9796
  if (!value.length) {
9681
9797
  this.control.addPlaceholder(startIndex);
9682
9798
  }
@@ -10434,7 +10550,7 @@ class CheckboxParticle {
10434
10550
  ctx.restore();
10435
10551
  }
10436
10552
  }
10437
- const encodedJs$2 = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBmOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuVEFCTEU9InRhYmxlIix0LkhZUEVSTElOSz0iaHlwZXJsaW5rIix0LkNPTlRST0w9ImNvbnRyb2wifSkoZnx8KGY9e30pKTt2YXIgcDsoZnVuY3Rpb24odCl7dC5WQUxVRT0idmFsdWUifSkocHx8KHA9e30pKTtjb25zdCBoPSJcdTIwMEIiLGc9YApgO2Z1bmN0aW9uIGEodCl7bGV0IGw9IiIsbj0wO2Zvcig7bjx0Lmxlbmd0aDspe2NvbnN0IG89dFtuXTtpZihvLnR5cGU9PT1mLlRBQkxFKXtpZihvLnRy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b250cm9sSWQscy5wdXNoKGUpKSxuKyt9bCs9YShzKX1lbHNlKCFvLnR5cGV8fG8udHlwZT09PWYuVEVYVCkmJihsKz1vLnZhbHVlKTtuKyt9cmV0dXJuIGx9ZnVuY3Rpb24gZCh0KXtjb25zdCBsPVtdLG49L1swLTldLyxvPS9bQS1aYS16XS8scj0vXHMvO2xldCBzPSExLGU9ITEsaT0iIjtmdW5jdGlvbiB1KCl7aSYmKGwucHVzaChpKSxpPSIiKX1mb3IoY29uc3QgYyBvZiB0KW8udGVzdChjKT8oc3x8dSgpLGkrPWMscz0hMCxlPSExKTpuLnRlc3QoYyk/KGV8fHUoKSxpKz1jLHM9ITEsZT0hMCk6KHUoKSxzPSExLGU9ITEsci50ZXN0KGMpfHxsLnB1c2goYykpO3JldHVybiB1KCksbH1vbm1lc3NhZ2U9dD0+e2NvbnN0IGw9dC5kYXRhLG89YShsKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke2h9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChoLCJnIiksZykscj1kKG8pO3Bvc3RNZXNzYWdlKHIubGVuZ3RoKX19KSgpO30pKCk7Cg==";
10438
10554
  const blob$2 = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs$2)], { type: "text/javascript;charset=utf-8" });
10439
10555
  function WorkerWrapper$2() {
10440
10556
  const objURL = blob$2 && (window.URL || window.webkitURL).createObjectURL(blob$2);
@@ -13682,7 +13798,7 @@ class Draw {
13682
13798
  this.textParticle.complete();
13683
13799
  }
13684
13800
  drawRow(ctx, payload) {
13685
- var _a, _b;
13801
+ var _a, _b, _c;
13686
13802
  const { rowList, pageNo, elementList, positionList, startIndex, zone: zone2 } = payload;
13687
13803
  const isPrintMode = this.mode === EditorMode.PRINT;
13688
13804
  const { scale, tdPadding, defaultBasicRowMarginHeight, defaultRowMargin, group: group2 } = this.options;
@@ -13776,8 +13892,8 @@ class Draw {
13776
13892
  offsetY2 = this.superscriptParticle.getOffsetY(element);
13777
13893
  }
13778
13894
  const color = element.controlComponent === ControlComponent.PLACEHOLDER ? void 0 : element.color;
13779
- this.underline.recordFillInfo(ctx, x - offsetX, y + curRow.height - rowMargin + offsetY2, metrics.width + offsetX, 0, color);
13780
- } else if ((preElement == null ? void 0 : preElement.underline) || ((_b = preElement == null ? void 0 : preElement.control) == null ? void 0 : _b.underline)) {
13895
+ this.underline.recordFillInfo(ctx, x - offsetX, y + curRow.height - rowMargin + offsetY2, metrics.width + offsetX, 0, color, (_b = element.textDecoration) == null ? void 0 : _b.style);
13896
+ } else if ((preElement == null ? void 0 : preElement.underline) || ((_c = preElement == null ? void 0 : preElement.control) == null ? void 0 : _c.underline)) {
13781
13897
  this.underline.render(ctx);
13782
13898
  }
13783
13899
  if (element.strikeout) {
@@ -14020,23 +14136,22 @@ class Draw {
14020
14136
  this.cursor.drawCursor();
14021
14137
  }
14022
14138
  if (isSubmitHistory) {
14023
- const self = this;
14024
- const oldElementList = deepClone(this.elementList);
14025
- const oldHeaderElementList = deepClone(this.header.getElementList());
14026
- const oldFooterElementList = deepClone(this.footer.getElementList());
14027
- const { startIndex, endIndex } = this.range.getRange();
14139
+ const oldElementList = getSlimCloneElementList(this.elementList);
14140
+ const oldHeaderElementList = getSlimCloneElementList(this.header.getElementList());
14141
+ const oldFooterElementList = getSlimCloneElementList(this.footer.getElementList());
14142
+ const oldRange = deepClone(this.range.getRange());
14028
14143
  const pageNo = this.pageNo;
14029
14144
  const oldPositionContext = deepClone(positionContext);
14030
14145
  const zone2 = this.zone.getZone();
14031
- this.historyManager.execute(function() {
14032
- self.zone.setZone(zone2);
14033
- self.setPageNo(pageNo);
14034
- self.position.setPositionContext(deepClone(oldPositionContext));
14035
- self.header.setElementList(deepClone(oldHeaderElementList));
14036
- self.footer.setElementList(deepClone(oldFooterElementList));
14037
- self.elementList = deepClone(oldElementList);
14038
- self.range.setRange(startIndex, endIndex);
14039
- self.render({
14146
+ this.historyManager.execute(() => {
14147
+ this.zone.setZone(zone2);
14148
+ this.setPageNo(pageNo);
14149
+ this.position.setPositionContext(deepClone(oldPositionContext));
14150
+ this.header.setElementList(deepClone(oldHeaderElementList));
14151
+ this.footer.setElementList(deepClone(oldFooterElementList));
14152
+ this.elementList = deepClone(oldElementList);
14153
+ this.range.replaceRange(deepClone(oldRange));
14154
+ this.render({
14040
14155
  curIndex,
14041
14156
  isSubmitHistory: false,
14042
14157
  isSourceHistory: true
@@ -14310,7 +14425,8 @@ var VerticalAlign;
14310
14425
  VerticalAlign2["MIDDLE"] = "middle";
14311
14426
  VerticalAlign2["BOTTOM"] = "bottom";
14312
14427
  })(VerticalAlign || (VerticalAlign = {}));
14313
- function printImageBase64(base64List, width, height) {
14428
+ function printImageBase64(base64List, options) {
14429
+ const { width, height, direction = PaperDirection.VERTICAL } = options;
14314
14430
  const iframe = document.createElement("iframe");
14315
14431
  iframe.style.visibility = "hidden";
14316
14432
  iframe.style.position = "absolute";
@@ -14332,7 +14448,15 @@ function printImageBase64(base64List, width, height) {
14332
14448
  container.append(image);
14333
14449
  });
14334
14450
  const style = document.createElement("style");
14335
- const stylesheet = `*{margin:0;padding:0;}@page{margin:0;}`;
14451
+ const stylesheet = `
14452
+ * {
14453
+ margin: 0;
14454
+ padding: 0;
14455
+ }
14456
+ @page {
14457
+ margin: 0;
14458
+ size: ${direction === PaperDirection.HORIZONTAL ? `landscape` : `portrait`};
14459
+ }`;
14336
14460
  style.append(document.createTextNode(stylesheet));
14337
14461
  setTimeout(() => {
14338
14462
  doc.write(`${style.outerHTML}${container.innerHTML}`);
@@ -14706,15 +14830,20 @@ class CommandAdapt {
14706
14830
  }
14707
14831
  }
14708
14832
  }
14709
- underline() {
14833
+ underline(textDecoration) {
14710
14834
  const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
14711
14835
  if (isDisabled)
14712
14836
  return;
14713
14837
  const selection = this.range.getSelectionElementList();
14714
14838
  if (selection == null ? void 0 : selection.length) {
14715
- const noUnderlineIndex = selection.findIndex((s) => !s.underline);
14839
+ const isSetUnderline = selection.some((s) => !s.underline || !textDecoration && s.textDecoration || textDecoration && !s.textDecoration || textDecoration && s.textDecoration && !isObjectEqual(s.textDecoration, textDecoration));
14716
14840
  selection.forEach((el) => {
14717
- el.underline = !!~noUnderlineIndex;
14841
+ el.underline = isSetUnderline;
14842
+ if (isSetUnderline && textDecoration) {
14843
+ el.textDecoration = textDecoration;
14844
+ } else {
14845
+ delete el.textDecoration;
14846
+ }
14718
14847
  });
14719
14848
  this.draw.render({
14720
14849
  isSetCursor: false,
@@ -16016,7 +16145,7 @@ class CommandAdapt {
16016
16145
  });
16017
16146
  }
16018
16147
  async print() {
16019
- const { scale, printPixelRatio } = this.options;
16148
+ const { scale, printPixelRatio, paperDirection } = this.options;
16020
16149
  if (scale !== 1) {
16021
16150
  this.draw.setPageScale(1);
16022
16151
  }
@@ -16026,7 +16155,11 @@ class CommandAdapt {
16026
16155
  pixelRatio: printPixelRatio,
16027
16156
  mode: EditorMode.PRINT
16028
16157
  });
16029
- printImageBase64(base64List, width, height);
16158
+ printImageBase64(base64List, {
16159
+ width,
16160
+ height,
16161
+ direction: paperDirection
16162
+ });
16030
16163
  if (scale !== 1) {
16031
16164
  this.draw.setPageScale(scale);
16032
16165
  }
@@ -17626,5 +17759,5 @@ class Editor {
17626
17759
  this.use = plugin.use.bind(plugin);
17627
17760
  }
17628
17761
  }
17629
- 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, TitleLevel, VerticalAlign, WordBreak, Editor as default, splitText };
17762
+ 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 };
17630
17763
  //# sourceMappingURL=canvas-editor.es.js.map