@hufe921/canvas-editor 0.9.71 → 0.9.72
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 +17 -0
- package/dist/canvas-editor.es.js +56 -21
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +35 -35
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/draw/Draw.d.ts +2 -1
- package/dist/src/editor/core/draw/particle/TextParticle.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Common.d.ts +1 -0
- package/dist/src/editor/interface/Range.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [0.9.72](https://github.com/Hufe921/canvas-editor/compare/v0.9.71...v0.9.72) (2024-04-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* cannot page when merge cells across columns in the same row #41 ([5851e61](https://github.com/Hufe921/canvas-editor/commit/5851e61cfcbb14fa199b507dc429917075659161)), closes [#41](https://github.com/Hufe921/canvas-editor/issues/41)
|
|
7
|
+
* format text class elements boundary error ([95b337d](https://github.com/Hufe921/canvas-editor/commit/95b337de05df74a07d086dbec6c6c52ab95ba43a))
|
|
8
|
+
* strikeout style rendering position #498 ([46e153d](https://github.com/Hufe921/canvas-editor/commit/46e153d588e78302e26827461a06682bbccd75aa)), closes [#498](https://github.com/Hufe921/canvas-editor/issues/498)
|
|
9
|
+
* table range drawing boundary error ([1df98b9](https://github.com/Hufe921/canvas-editor/commit/1df98b9359f3ec4184a7045cfcea93e156ef7f9f))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add isTable property to the RangeContext interface ([9ad991a](https://github.com/Hufe921/canvas-editor/commit/9ad991a3934fc284bb829d2652a739cfbec80eee))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
1
18
|
## [0.9.71](https://github.com/Hufe921/canvas-editor/compare/v0.9.70...v0.9.71) (2024-03-29)
|
|
2
19
|
|
|
3
20
|
|
package/dist/canvas-editor.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
var index = "";
|
|
26
|
-
const version = "0.9.
|
|
26
|
+
const version = "0.9.72";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -79,6 +79,7 @@ const LETTER_CLASS = {
|
|
|
79
79
|
SWEDISH: "A-Za-z\xC5\xE5\xC4\xE4\xD6\xF6",
|
|
80
80
|
GREEK: "\u0391\u03B1\u0392\u03B2\u0393\u03B3\u0394\u03B4\u0395\u03B5\u0396\u03B6\u0397\u03B7\u0398\u03B8\u0399\u03B9\u039A\u03BA\u039B\u03BB\u039C\u03BC\u039D\u03BD\u039E\u03BE\u039F\u03BF\u03A0\u03C0\u03A1\u03C1\u03A3\u03C3\u03C2\u03A4\u03C4\u03A5\u03C5\u03A6\u03C6\u03A7\u03C7\u03A8\u03C8\u03A9\u03C9"
|
|
81
81
|
};
|
|
82
|
+
const METRICS_BASIS_TEXT = "\u65E5";
|
|
82
83
|
var RowFlex;
|
|
83
84
|
(function(RowFlex2) {
|
|
84
85
|
RowFlex2["LEFT"] = "left";
|
|
@@ -3963,7 +3964,7 @@ function formatElementList(elementList, options) {
|
|
|
3963
3964
|
i++;
|
|
3964
3965
|
}
|
|
3965
3966
|
i--;
|
|
3966
|
-
} else if ((!el.type || el.type
|
|
3967
|
+
} else if ((!el.type || TEXTLIKE_ELEMENT_TYPE.includes(el.type)) && el.value.length > 1) {
|
|
3967
3968
|
elementList.splice(i, 1);
|
|
3968
3969
|
const valueList = splitText(el.value);
|
|
3969
3970
|
for (let v = 0; v < valueList.length; v++) {
|
|
@@ -4281,6 +4282,9 @@ function convertElementToDom(element, options) {
|
|
|
4281
4282
|
if (element.underline) {
|
|
4282
4283
|
dom.style.textDecoration = "underline";
|
|
4283
4284
|
}
|
|
4285
|
+
if (element.strikeout) {
|
|
4286
|
+
dom.style.textDecoration += " line-through";
|
|
4287
|
+
}
|
|
4284
4288
|
dom.innerText = element.value.replace(new RegExp(`${ZERO}`, "g"), "\n");
|
|
4285
4289
|
return dom;
|
|
4286
4290
|
}
|
|
@@ -4478,9 +4482,12 @@ function convertTextNodeToElement(textNode) {
|
|
|
4478
4482
|
if (style.backgroundColor !== "rgba(0, 0, 0, 0)") {
|
|
4479
4483
|
element.highlight = style.backgroundColor;
|
|
4480
4484
|
}
|
|
4481
|
-
if (style.textDecorationLine
|
|
4485
|
+
if (style.textDecorationLine.includes("underline")) {
|
|
4482
4486
|
element.underline = true;
|
|
4483
4487
|
}
|
|
4488
|
+
if (style.textDecorationLine.includes("line-through")) {
|
|
4489
|
+
element.strikeout = true;
|
|
4490
|
+
}
|
|
4484
4491
|
return element;
|
|
4485
4492
|
}
|
|
4486
4493
|
function getElementListByHTML(htmlText, options) {
|
|
@@ -8555,9 +8562,10 @@ class Strikeout extends AbstractRichText {
|
|
|
8555
8562
|
render(ctx) {
|
|
8556
8563
|
if (!this.fillRect.width)
|
|
8557
8564
|
return;
|
|
8558
|
-
const { strikeoutColor } = this.options;
|
|
8565
|
+
const { scale, strikeoutColor } = this.options;
|
|
8559
8566
|
const { x, y, width } = this.fillRect;
|
|
8560
8567
|
ctx.save();
|
|
8568
|
+
ctx.lineWidth = scale;
|
|
8561
8569
|
ctx.strokeStyle = strikeoutColor;
|
|
8562
8570
|
const adjustY = y + 0.5;
|
|
8563
8571
|
ctx.beginPath();
|
|
@@ -8678,6 +8686,15 @@ class TextParticle {
|
|
|
8678
8686
|
this.curStyle = "";
|
|
8679
8687
|
this.cacheMeasureText = new Map();
|
|
8680
8688
|
}
|
|
8689
|
+
measureBasisWord(ctx, font) {
|
|
8690
|
+
ctx.save();
|
|
8691
|
+
ctx.font = font;
|
|
8692
|
+
const textMetrics = this.measureText(ctx, {
|
|
8693
|
+
value: METRICS_BASIS_TEXT
|
|
8694
|
+
});
|
|
8695
|
+
ctx.restore();
|
|
8696
|
+
return textMetrics;
|
|
8697
|
+
}
|
|
8681
8698
|
measureWord(ctx, elementList, curIndex) {
|
|
8682
8699
|
const LETTER_REG = this.draw.getLetterReg();
|
|
8683
8700
|
let width = 0;
|
|
@@ -13921,12 +13938,15 @@ class Draw {
|
|
|
13921
13938
|
ctx.wordSpacing = "0px";
|
|
13922
13939
|
ctx.direction = "ltr";
|
|
13923
13940
|
}
|
|
13924
|
-
|
|
13941
|
+
getElementFont(el, scale = 1) {
|
|
13925
13942
|
const { defaultSize, defaultFont } = this.options;
|
|
13926
13943
|
const font = el.font || defaultFont;
|
|
13927
13944
|
const size = el.actualSize || el.size || defaultSize;
|
|
13928
13945
|
return `${el.italic ? "italic " : ""}${el.bold ? "bold " : ""}${size * scale}px ${font}`;
|
|
13929
13946
|
}
|
|
13947
|
+
getElementSize(el) {
|
|
13948
|
+
return el.actualSize || el.size || this.options.defaultSize;
|
|
13949
|
+
}
|
|
13930
13950
|
computeRowList(innerWidth, elementList) {
|
|
13931
13951
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13932
13952
|
const { defaultSize, defaultRowMargin, scale, tdPadding, defaultTabWidth } = this.options;
|
|
@@ -14096,7 +14116,8 @@ class Draw {
|
|
|
14096
14116
|
const tr = trList2[r];
|
|
14097
14117
|
const trHeight = tr.height * scale;
|
|
14098
14118
|
if (curPagePreHeight + rowMarginHeight + preTrHeight + trHeight > height2) {
|
|
14099
|
-
|
|
14119
|
+
const rowColCount = tr.tdList.reduce((pre, cur) => pre + cur.colspan, 0);
|
|
14120
|
+
if (((_d = element.colgroup) == null ? void 0 : _d.length) !== rowColCount) {
|
|
14100
14121
|
deleteCount = 0;
|
|
14101
14122
|
}
|
|
14102
14123
|
break;
|
|
@@ -14184,7 +14205,7 @@ class Draw {
|
|
|
14184
14205
|
element.actualSize = Math.ceil(size * 0.6);
|
|
14185
14206
|
}
|
|
14186
14207
|
metrics.height = (element.actualSize || size) * scale;
|
|
14187
|
-
ctx.font = this.
|
|
14208
|
+
ctx.font = this.getElementFont(element);
|
|
14188
14209
|
const fontMetrics = this.textParticle.measureText(ctx, element);
|
|
14189
14210
|
metrics.width = fontMetrics.width * scale;
|
|
14190
14211
|
if (element.letterSpacing) {
|
|
@@ -14202,7 +14223,7 @@ class Draw {
|
|
|
14202
14223
|
const height = rowMargin + metrics.boundingBoxAscent + metrics.boundingBoxDescent + rowMargin;
|
|
14203
14224
|
const rowElement = Object.assign(element, {
|
|
14204
14225
|
metrics,
|
|
14205
|
-
style: this.
|
|
14226
|
+
style: this.getElementFont(element, scale)
|
|
14206
14227
|
});
|
|
14207
14228
|
if ((_e = rowElement.control) == null ? void 0 : _e.minWidth) {
|
|
14208
14229
|
if (rowElement.controlComponent) {
|
|
@@ -14453,23 +14474,35 @@ class Draw {
|
|
|
14453
14474
|
this.underline.render(ctx);
|
|
14454
14475
|
}
|
|
14455
14476
|
if (element.strikeout) {
|
|
14456
|
-
|
|
14477
|
+
if (!element.type || TEXTLIKE_ELEMENT_TYPE.includes(element.type)) {
|
|
14478
|
+
if (preElement && this.getElementSize(preElement) !== this.getElementSize(element)) {
|
|
14479
|
+
this.strikeout.render(ctx);
|
|
14480
|
+
}
|
|
14481
|
+
const standardMetrics = this.textParticle.measureBasisWord(ctx, this.getElementFont(element));
|
|
14482
|
+
let adjustY = y + offsetY + standardMetrics.actualBoundingBoxDescent * scale - metrics.height / 2;
|
|
14483
|
+
if (element.type === ElementType.SUBSCRIPT) {
|
|
14484
|
+
adjustY += this.subscriptParticle.getOffsetY(element);
|
|
14485
|
+
} else if (element.type === ElementType.SUPERSCRIPT) {
|
|
14486
|
+
adjustY += this.superscriptParticle.getOffsetY(element);
|
|
14487
|
+
}
|
|
14488
|
+
this.strikeout.recordFillInfo(ctx, x, adjustY, metrics.width);
|
|
14489
|
+
}
|
|
14457
14490
|
} else if (preElement == null ? void 0 : preElement.strikeout) {
|
|
14458
14491
|
this.strikeout.render(ctx);
|
|
14459
14492
|
}
|
|
14460
14493
|
const { zone: currentZone, startIndex: startIndex2, endIndex } = this.range.getRange();
|
|
14461
14494
|
if (currentZone === zone2 && startIndex2 !== endIndex && startIndex2 <= index2 && index2 <= endIndex) {
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
if (
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14495
|
+
const positionContext = this.position.getPositionContext();
|
|
14496
|
+
if (!positionContext.isTable && !element.tdId || positionContext.tdId === element.tdId) {
|
|
14497
|
+
if (startIndex2 === index2) {
|
|
14498
|
+
const nextElement = elementList[startIndex2 + 1];
|
|
14499
|
+
if (nextElement && nextElement.value === ZERO) {
|
|
14500
|
+
rangeRecord.x = x + metrics.width;
|
|
14501
|
+
rangeRecord.y = y;
|
|
14502
|
+
rangeRecord.height = curRow.height;
|
|
14503
|
+
rangeRecord.width += this.options.rangeMinWidth;
|
|
14504
|
+
}
|
|
14505
|
+
} else {
|
|
14473
14506
|
let rangeWidth = metrics.width;
|
|
14474
14507
|
if (rangeWidth === 0 && curRow.elementList.length === 1) {
|
|
14475
14508
|
rangeWidth = this.options.rangeMinWidth;
|
|
@@ -16877,6 +16910,7 @@ class CommandAdapt {
|
|
|
16877
16910
|
});
|
|
16878
16911
|
}
|
|
16879
16912
|
const zone2 = this.draw.getZone().getZone();
|
|
16913
|
+
const isTable = this.position.getPositionContext().isTable;
|
|
16880
16914
|
return deepClone({
|
|
16881
16915
|
isCollapsed,
|
|
16882
16916
|
startElement,
|
|
@@ -16884,7 +16918,8 @@ class CommandAdapt {
|
|
|
16884
16918
|
startPageNo,
|
|
16885
16919
|
endPageNo,
|
|
16886
16920
|
rangeRects,
|
|
16887
|
-
zone: zone2
|
|
16921
|
+
zone: zone2,
|
|
16922
|
+
isTable
|
|
16888
16923
|
});
|
|
16889
16924
|
}
|
|
16890
16925
|
getRangeRow() {
|